Reputation: 7778
I am new to SAS. Trying to do simple if-else logic and incorporate it into the loop. Having issues; unable to resolve.
%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;
Having errors like "Statement is not valid.
Upvotes: 0
Views: 215
Reputation: 4006
You need to use %if %then %else
instead of if then else
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543542.htm
and use %let to overwrite your macro variables.
like this
%IF ¤tCount=&lastCount %THEN %let infiniteLoop=0 ;
%ELSE %let lastCount = ¤tCount;
Upvotes: 3