【发布时间】:2016-08-25 14:34:55
【问题描述】:
我正在使用 SAS,我必须在 DO 循环中创建一些宏变量。这是我的代码的一部分:
%if &dsempty888=0 %then %do;
data _null_;
set freq_&&var&i;
if &&var&i=888888888 then do;
call symput("cont8_&&var&i",percent);
end;
run;
%end;
%if &dsempty888=1 %then %do;
%let cont8_&&var&i=0;
%end;
%if &dsempty999=0 %then %do;
data _null_;
set freq_&&var&i;
if &&var&i=999999999 then do;
call symput("cont9_&&var&i",percent);
end;
run;
%end;
%if &dsempty999=1 %then %do;
%let cont9_&&var&i=0;
%end;
%if &dsempty444=0 %then %do;
data _null_;
set freq_&&var&i;
if &&var&i=444444444 then do;
call symput("cont4_&&var&i",percent);
end;
run;
%end;
%if &dsempty444=1 %then %do;
%let cont4_&&var&i=0;
%end;
此代码位于另一个从 i=1 to &end 运行的 DO 循环中。
有了这个,我的宏变量cont4_&&var&icont8_&&var&icont9_&&var&i 被大量覆盖......并且它们在循环之外变得无用。例如,我试图将它们命名为 &&cont4_&&var&i。但显然 SAS 并没有解决宏观问题。
实际上,宏是在循环内部创建的,但我不知道在需要外部时如何调用它们。
我该如何解决?
提前致谢。
【问题讨论】:
-
另请参阅this question 和this question,了解有关多与号分辨率的更多信息。