我是SAS新手。尝试做简单的if-else逻辑并将其合并到循环中。有问题;无法解决。
%macro iterate ();
%let lastCount = 0;
%let currentCount=0;
%let infiniteLoop= 1;
%do %while(&infiniteLoop=1);
/* ..some sql logic */
proc sql noprint;
select count(*) into :currentCount from table1;
quit;
IF ¤tCount=&lastCount
THEN &infiniteLoop=0
ELSE &lastCount = ¤tCount;
%put 'show values: ' &lastCount;
%end;
%mend iterate;
%iterate();
run;
出现“声明无效等错误。
答案 0 :(得分:3)
您需要使用%if %then %else
代替if then else
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543542.htm
并使用%let覆盖宏变量。
像这样 %IF ¤tCount=&lastCount %THEN %let infiniteLoop=0 ;
%ELSE %let lastCount = ¤tCount;