Help using Base SAS procedures

Question on Date Macro

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 117
Accepted Solution

Question on Date Macro

Hi there, I would like some help with the following macro:

%let dt = %SYSFUNC(today(),MONYY.);

This outputs the result: MAY13

How can this code be modified to show the previous month? i.e. APR13?

Secondly, how can I make it look a bit different? Let's say like: April 2013

Thanks!


Accepted Solutions
Solution
‎05-07-2013 12:16 PM
Respected Advisor
Posts: 3,777

Re: Question on Date Macro

17         %let dt = %sysfunc(intnx(MONTH,%SYSFUNC(today()),-1),MONYY.);
18         %put &=dt;
DT=APR13

View solution in original post


All Replies
Solution
‎05-07-2013 12:16 PM
Respected Advisor
Posts: 3,777

Re: Question on Date Macro

17         %let dt = %sysfunc(intnx(MONTH,%SYSFUNC(today()),-1),MONYY.);
18         %put &=dt;
DT=APR13
Frequent Contributor
Posts: 117

Re: Question on Date Macro

Thank you!

Super User
Super User
Posts: 6,500

Re: Question on Date Macro

I do not know of a single format to get "April 2013" output.  I think you will need to use two function calls.

%let dt = %sysfunc(intnx(MONTH,%SYSFUNC(today()),-1));

%let dt = %sysfunc(putn(&dt,monname.)) %sysfunc(putn(&dt,year.));

PROC Star
Posts: 1,561

Re: Question on Date Macro

%let x=%sysfunc(nldate('01dec2013'd,%nrstr(%B %Y)));

%put x=&x;

x=December 2013

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 262 views
  • 4 likes
  • 4 in conversation