The macro code works fine when i put in values for the parameters such as 202202, 202203, 202204. But my question is how to do I append these tables in a loop? there's no way to loop the dates so it goes from 202101 to 202203? I found something on stack overflow that says to do this: %macro loop(start_month=, stop_month=);
%local month;
%do month=&start_month %to &stop_month;
%put Month: &month;
%* SQL CODE HERE....
%* SPECIAL CASE WHEN WE REACH END OF A YEAR;
%if %substr(&month, 5, 2) = 12 %then %let month = %eval(&month + 88);
%end;
%mend loop;
%loop(start_month=200301, stop_month=201502) but when i plug in my macro in the middle %yearmonth(&YM); it doesn't work. Do you know why? %macro loop(start_month=, stop_month=);
%local month;
%do month=&start_month %to &stop_month;
%put Month: &month;
%yearmonth(&YM);
%if %substr(&month, 5, 2) = 12 %then %let month = %eval(&month + 88);
%end;
%mend loop;
%loop(start_month=202101, stop_month=202203)
... View more