【发布时间】:2016-10-10 16:15:58
【问题描述】:
我对曾经有效的代码有疑问(比如一周前) 现在在一台新电脑上,它不再是了
我用 SQL 创建我的宏变量
proc sql noprint;
select count(distinct(num_nation)) into :nb_country from AFGp
;
%let nb_country = &nb_country;
select distinct(num_nation) into :pays1 - :pays&nb_country from AFGp;
select count(*) into :nbvar from variables;
%let nbvar=&nbvar;
select variable, var_label, lbl_categ into :var1 - :var&nbvar, :lab1 - :lab&nbvar, :labc1 - :labc&nbvar from variables
;
quit;
run;
而且这个宏不能识别以 var 开头的宏变量:
%macro testtest();
%do j = 1 %to %eval(&nb_country);
%do i = 2 %to %eval(&nbvar);
proc freq data=AFGp noprint;
tables &&var&i. / nocol nocum nofreq nowarn out=_TFP_&j._&i;
where num_nation = &j;
run;
%end;
%end;
%mend;
例如: 这个
%let j=4;
%put &j &var4 &&var&j;
返回这个:
4 Female &&var4
这段代码以前可以正常解析,不明白为什么现在不行了。
如果你能帮助我,甚至把我引向正确的方向,这已经阻止了我 3 个小时
【问题讨论】:
标签: macros sas global-variables