I have an SQL Program like with field names Proc SQL; Select var1, var2, var3, 31JAN2017, 28FEB2017, 31MAR2017, 30APR2017, 31MAY2017 from table1; quit; Lets assume I am currently in the month of June2017 and my reporting month is May2017, if my month changes to Jul 2017, I need to add 30JUN2017 as a variable in the table. Instead of adding mannually I need to automate using macro. I tried this below %macro loop; %do i=0 %to 11; %let date1=%sysfunc(intnx(month, '01JAN2017'd, &i. ,e), date9.); %put &date1.; %end; %mend; %loop; But it just added values in the log. How can I create macro to add the variable automatically from 31JAN2017 to reporting month. Similarly if the month is JAN 2017 I need it from 31JAN2016 to 31DEC2016 as variables to be added in the select table variables 31JAN2017 28FEB2017 31MAR2017 30APR2017 31MAY2017 30JUN2017 31JUL2017 31AUG2017 30SEP2017 31OCT2017 30NOV2017 31DEC2017
... View more