Looping involving calendar dates in a macro is much easier if you work with SAS date values (and not human readable values such as 2010 and 10). Therefore, I convert 2010 and 10 to an actual SAS data value using the MDY function. Then you can use the INTNX and INTCK functions as needed to work in terms of quarters (or months or weeks, if desired).
%macro loop(startyear,startmonth);
%let date=%sysfunc(mdy(&startmonth,1,&startyear));
%do %while(&date<%sysfunc(today()));
/* %put %sysfunc(putn(&date,yymm7.)) %sysfunc(year(&date)) %sysfunc(month(&date));*/
%portfolio_(%sysfunc(year(&date)),%sysfunc(month(&date)))
%let date=%sysfunc(intnx(quarter,&date,1,b));
%end;
%mend;
%loop(2010,10)
You would probably also be wise to re-configure this code so that you are always working with actual valid SAS date values, rather than discrete year and discrete month used as &date_input.&month. A SAS date value can be formatted and used in file names as 201907, rather than having to append discrete year and discrete month onto the end a file name.
... View more