I am attempting to write a do while loop that will iterate over a list of values within a macro and am getting a strange result. I have based the structure off of other examples but can't find anything related to this error. I start with this below: proc sql noprint;
select distinct Year_Month format=date9. into : month_list separated by ' '
from string_all
where Year_Month >= '01JAN2021'd
;
quit;
%macro historical_calcs();
%local i next_month;
%do %while (%scan(&month_list),&i) ne );
%let next_month=%scan(&month_list, &i);
proc sql;
create table strings as
select distinct string into : string_list separated by ' '
from strings_all
where Year_Month=&next_month
And
string is not missing
;
quit;
%let i = %eval(&i + 1);
%end;
%mend; I get an error saying "Expected semicolon not found after WHILE clause" and "A dummy macro will be compiled". What I am I missing about the structure of my do while part? Edit: So I included the rest of the code and I've also included the log statement below. GOPTIONS ACCESSIBLE;
26
27 %macro historical_calcs();
28 %local i next_month;
29 %do %while (%scan(&month_list),&i) ne );
ERROR: Expected semicolon not found after WHILE clause.
ERROR: A dummy macro will be compiled.
30 %let next_month=%scan(&month_list, &i);
31
32 proc sql;
33 create table strings as
34 select distinct strings into : string_list separated by ' '
35 from strings_all
36 where Year_Month=&next_month
37 And
38 string is not missing
39 ;
40 quit;
41
42 %let i = %eval(&i + 1);
43 %end;
44 %mend;
45
... View more