SAS中文论坛

标题: 我的程序那里出错了,为什么的VAR1值总是MISSING [打印本页]

作者: shiyiming    时间: 2011-7-4 23:12
标题: 我的程序那里出错了,为什么的VAR1值总是MISSING
%macro comb(n=,m=);
ods output plan=comb&n._&m.;
ods listing close;
proc plan;
factors block=%eval(%sysfunc(comb(&n.,&m.))) ordered
         treat= &m. of &n. comb
;
run;
quit;
ods listing;
ods output close;
%mend;
%comb(n=10, m=1)
%comb(n=10, m=2)
%comb(n=10, m=3)
%comb(n=10, m=4)
%comb(n=10, m=5)
%comb(n=10, m=6)
%comb(n=10, m=7)
%comb(n=10, m=8)
%comb(n=10, m=9)
%comb(n=10, m=10)


%MACRO varlist(m);
%DO I = 1 %TO &m;
var&I $10
%END;
%MEND varlist;

%MACRO varassign(m);
%do i=1 %to &m;
%if treat&i=1 %then var&i=year_2;
%else %if treat&i=2 %then var&i=year_3;
%else %if treat&i=3 %then var&i=hydro;
%else %if treat&i=4 %then var&i=nuke;
%else %if treat&i=5 %then var&i=wind;
%else %if treat&i=6 %then var&i=biomass;
%else %if treat&i=7 %then var&i=estcp_pc;
%else %if treat&i=8 %then var&i=gdp;
%else %if treat&i=9 %then var&i=solar;
%else %if treat&i=10 %then var&i=ngeid;
%end;
%mend varassign;

data var3;
set comb10_3;
length %varlist(3);
%varassign(3);
run;
作者: shiyiming    时间: 2011-7-5 00:53
标题: Re: 我的程序那里出错了,为什么的VAR1值总是MISSING
%MACRO varassign(m);
%do i=1 %to &m;
if treat&i=1 then var&i="year_2";
else if treat&i=2 then var&i="year_3";
else if treat&i=3 then var&i='hydro';
else if treat&i=4 then var&i='nuke';
else if treat&i=5 then var&i='wind';
else if treat&i=6 then var&i='biomass';
else if treat&i=7 then var&i='estcp_pc';
else if treat&i=8 then var&i='gdp';
else if treat&i=9 then var&i='solar';
else if treat&i=10 then var&i='ngeid';
%end;
%mend varassign;




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2