BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BonnaryW
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Since you have date value PUT it with the appropriate format:

 

%let pmons= %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(date()),-1)),monname3.));

%put &pmons;

View solution in original post

4 REPLIES 4
ballardw
Super User

Since you have date value PUT it with the appropriate format:

 

%let pmons= %sysfunc(putn(%sysfunc(intnx(month,%sysfunc(date()),-1)),monname3.));

%put &pmons;

BonnaryW
Obsidian | Level 7
Thank you Ballardw. It's work!
Reeza
Super User

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.


 

BonnaryW
Obsidian | Level 7
Thank you Reeza. It's work !!!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3756 views
  • 2 likes
  • 3 in conversation