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 !!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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