Hello,
I am trying to convert the pmons(numeric month)to monname3. month.
%let pmons = %sysfunc(month(%sysfunc(intnx(month,%sysfunc(date()),-1))));
ods tagsets.ExcelXP file="C:\Reports\TEST_ME_&pmons&cyear..xls" style=sasweb
options(absolute_column_width='6,20,4');
PROC REPORT DATA=ME nowd;
column ID NAME CODE;
define ID / style(column)={tagattr='00000'};
My file name should be: TEST_ME_MAY2018.xls
Thank you.
Since you have date value PUT it with the appropriate format:
%let pmons= %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(date()),-1)),monname3.));
%put &pmons;
Since you have date value PUT it with the appropriate format:
%let pmons= %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(date()),-1)),monname3.));
%put &pmons;
The second parameter in the %SYSFUNC() is a format.
%let pmons= %sysfunc(intnx(month,%sysfunc(date()),-1),monname3.);
%put &pmons;
Use SYSFUNC() once for the date() function and once for the INTNX and then apply the format. The format MONNAME3 works off a SAS date, not a month. So if MONTH() is applied, it returns a number from 1 to 12 but there is not a format to convert a value of 1 to 12 to a month name. You could create your own if desired.
Note that you can get the full value, May2018 in a single macro variable as well:
%let pmons= %sysfunc(intnx(month,%sysfunc(date()),-1),monname3.);
%put &pmons;
@BonnaryW wrote:
Hello,
I am trying to convert the pmons(numeric month)to monname3. month.
%let pmons = %sysfunc(month(%sysfunc(intnx(month,%sysfunc(date()),-1))));
ods tagsets.ExcelXP file="C:\Reports\TEST_ME_&pmons&cyear..xls" style=sasweb
options(absolute_column_width='6,20,4');
PROC REPORT DATA=ME nowd;
column ID NAME CODE;
define ID / style(column)={tagattr='00000'};
My file name should be: TEST_ME_MAY2018.xls
Thank you.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.