SAS 宏命令 循环 15
这是我的宏命令cut(x,y,out),我想不断变化x(10-100,by1),y(0.1-9,by0.1),out(每一对x,y生成不同的out数据集),试了半天说循环...
这是我的宏命令cut(x,y,out),我想不断变化x(10-100, by 1),y(0.1-9, by 0.1),out(每一对x,y生成不同的out数据集),试了半天说循环不闭合,求高人给一个让下面这个宏不断对 x, y, out循环的SAS命令。奉上所有财富值,虽然不多……
%macro cut(x,y,out);
data abc2;
set sasuser.abc;
if risk>=&x then dag1=1; /*step1:risk score筛选结果*/
else dag1=2;
if fpg>=&y then dag2=1; /*step2:FPG筛选结果*/
else dag2=2;
if dag1=1 and dag2=1 then dag=1;
else dag=2;
if FPG>=7 or OGTT>=11.1 then WHO=1; /*按照WHO标准诊断结果*/
else WHO=2;
ods listing;
ods output Freq.Table1.CrossTabFreqs=out1;
proc freq;
tables dag*WHO;
run;
quit;
ods output close;
ods listing;
data out2;
set out1;
keep Frequency dag WHO ColPercent;
run;
data &out;
merge out2(where=(dag=1 and WHO=1) rename=(Frequency=n)) out2(where=(dag=2 and WHO=2) rename=(ColPercent=ColPercent2)) ;
youdex=ColPercent+ColPercent2-100;
s1=&x ;
s2=&y;
run;
%mend cut; 展开
%macro cut(x,y,out);
data abc2;
set sasuser.abc;
if risk>=&x then dag1=1; /*step1:risk score筛选结果*/
else dag1=2;
if fpg>=&y then dag2=1; /*step2:FPG筛选结果*/
else dag2=2;
if dag1=1 and dag2=1 then dag=1;
else dag=2;
if FPG>=7 or OGTT>=11.1 then WHO=1; /*按照WHO标准诊断结果*/
else WHO=2;
ods listing;
ods output Freq.Table1.CrossTabFreqs=out1;
proc freq;
tables dag*WHO;
run;
quit;
ods output close;
ods listing;
data out2;
set out1;
keep Frequency dag WHO ColPercent;
run;
data &out;
merge out2(where=(dag=1 and WHO=1) rename=(Frequency=n)) out2(where=(dag=2 and WHO=2) rename=(ColPercent=ColPercent2)) ;
youdex=ColPercent+ColPercent2-100;
s1=&x ;
s2=&y;
run;
%mend cut; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询