Following program creates both data step variables and macro variables.
data test;
month = month(input("&sysdate9",date9.));
year = year(input("&sysdate9",date9.));
call symput('month',compress(put(month,best.)));
call symput('year',compress(put(year,best.)));
run;
%put &year;
%put &month;
And from @ballardw:
And a way to do it without a data step:
%let sysmonth= %sysfunc(month("&sysdate"d));
%let sysyear= %sysfunc(year("&sysdate"d));
%put &sysmonth &sysyear;
Remember that SYSDATE has the start date of the SAS session, not the calendar date at the time of execution.
... View more