问题
I am triggering a mail in SAS which should holds current month and year in the mail
How can I create macro variables &month
&year
such that
&month
should display October&year
should display 2020
Currently using
%let sysmonth= %sysfunc(month("&sysdate"d));
%let sysyear= %sysfunc(year("&sysdate"d));
%put &sysmonth &sysyear;
But I am getting month in number but i want the month in words
回答1:
Use PUTN
with format MONNAME
%put %sysfunc(PUTN("&sysdate"d, monname.));
------ LOG ------
October
回答2:
%SYSFUNC
has an optional second argument that specifies format. In the particular case here you don't really need it - Richard's PUTN works just as well - but in the case that you do want a function to operate, here's that example - the example here being for if you want a different month than the current one, but any function works this way.
%let sysmonth= %sysfunc(intnx(month,"&sysdate"d,-1),monname.);
%put &=sysmonth;
来源:https://stackoverflow.com/questions/64351082/how-to-get-current-month-name-and-year-in-sas-using-macro