作者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