Hi - I am very much a beginner at SAS, so would like to apologize ahead of time for a (probably) simple question! I am creating a table pulling one line of data per dataset I am using. The datasets all have the format loanreport_YYYYMM. I need years 2010 through 2019 and months 01, 04, 07, and 10 for all years. For example, I need loanreport_201901, loanreport_201904, loanreport_201907, etc. I currently have this basic macro and it works fine, but I am looking for a way I can automate it more by being able to just change the 'end date' at the top of the code with a macro. This program is run once a year and when it is run, only the '07' month is ready for the current year. So for 2020, I would like to be able to change end date to 2020 and have it pull the 201910, 202001, 202004, and 202007 datasets to create those 4 new lines in the proc sql table. I know this is possible and have read other posts similar to this, but I just can't figure out how to make it work for my code. Thank you!! %macro portfolio(date_input, month);
data example_&date_input.&month.;
set loanreport_&date_input.&month. (keep = variables variables);
run;
proc sql;
create table alltheloans_&date_input.&month. as select
&date_input.&month. as dataasof,
other variables,
other variables,
from example_&date_input.&month.
group by dataasof;
quit;
%mend;
%portfolio_(2010, 10);
%portfolio_(2011, 01);
%portfolio_(2011, 04);
%portfolio_(2011, 07);
%portfolio_(2011, 10);
etc. etc. through %portfolio_(2019, 07) ;
data home.portfolio_7a;
set home.portfolio_201010
home.portfolio_201101
home.portfolio_201104
home.portfolio_201107
home.portfolio_201110
etc. etc. etc.
run
... View more