## Question on Date Macro

Solved
Frequent Contributor
Posts: 117

# 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
Posts: 3,852

## Re: Question on Date Macro

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

All Replies
Solution
‎05-07-2013 12:16 PM
Posts: 3,852

## Re: Question on Date Macro

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

Thank you!

Super User
Posts: 8,093

## 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: 2,350

## Re: Question on Date Macro

```%let x=%sysfunc(nldate('01dec2013'd,%nrstr(%B %Y)));
%put x=&x;
x=December 2013

```
🔒 This topic is solved and locked.