作者carrotree (carrot)
看板Statistics
標題[問題] SAS巨集
時間Wed Jul 22 23:00:24 2009
請教一下版上的高手 感謝
我寫了一個巨集 但是 跑出來不是我要的(我是SAS新手)>"<
不曉得是哪裡錯了=.=
% macro age(a);
% macro icd(b);
data test.rate_&a;
set test.rate_&b;
by sex year agesub;
retain count count_total;
if first.agesub then do;
count=1;
count_total=count;
end;
else do;
count=count+1;
count_total=count_total+count;
end;
if last.agesub;
% mend icd;
% icd(140);
% icd(150);
% icd(151);
% mend age;
% age(1401);
% age(1501);
% age(1511);
run;
我想要上面巨集跑出來的結果
跟下面分開寫跑出來的結果 一樣
但是 不曉得我巨集哪裡寫錯了 跑不出我要的結果
data test.rate_1401;
set test.rate_140;
by sex year agesub;
retain count count_total;
if first.agesub then do;
count=1;
count_total=count;
end;
else do;
count=count+1;
count_total=count_total+count;
end;
if last.agesub;
run;
-------------------------------------------
data test.rate_1501;
set test.rate_150;
by sex year agesub;
retain count count_total;
if first.agesub then do;
count=1;
count_total=count;
end;
else do;
count=count+1;
count_total=count_total+count;
end;
if last.agesub;
run;
--------------------------------------------
data test.rate_1511;
set test.rate_151;
by sex year agesub;
retain count count_total;
if first.agesub then do;
count=1;
count_total=count;
end;
else do;
count=count+1;
count_total=count_total+count;
end;
if last.agesub;
run;
--
◢█◢▊◢◣◢◣◢▉ ▋ ◢◣◢◣◢◣
█ ▊▊▉ ▉ ▊▉█▋▊ ▊▉▊▉
◥◣◥▉▉ ▉ █◤ ▋ ▊ ◥◣◥◣ 擁抱讓距離更接近
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.231.152.142
※ 編輯: carrotree 來自: 61.231.152.142 (07/22 23:01)
1F:→ kingbee:印象marco age ice 不能連包 07/22 23:06
2F:→ kingbee:寫的話可能改 macro age(a,b) 這樣吧 07/22 23:07
3F:→ kingbee:不過最好把log 貼出來 大概知道哪裡有問題 07/22 23:36
4F:→ kingbee:妳語法中if first.agesub then do; 沒指定 條件 07/22 23:36
5F:→ kingbee:if last.agesub; 也沒寫條件 你知道 by 的用途嗎? 07/22 23:38
6F:→ kingbee:by sex year agesub; 這個用途知道嗎 07/22 23:39
7F:→ west1996:試試看把ice拿到外面來定義 age裡面直接呼叫ice可不可行 07/23 00:05
8F:推 qfchi:請問if first.agesub then do; 沒指定條件的意思是指? 07/24 00:00
9F:→ kingbee:last.agesub 會產生內定預設值 0 或 1 07/24 09:28
10F:→ qfchi:請問指定條件的意思是說像 if x>3 then 大於3就是指定條見? 07/24 22:53