Hi,
I want to create a macro variable for last year and the month should be July(current month + 3) .
For example : it should be display as 01JUL2015
I have tried the below.
data _null_;
call symput('previous_year',put(intnx('month',today(),),intnx('year',today(), -1, 'S'),0,'B'),date9.));
run;
%put &previous_year ;
01APR2015
Please let me know.
Thanks
It looks like you're making this a little too complicated. How about:
call symput('previous_year', put(intnx('month', today(), -9), date9.));
Last year + 3 months is the same as going back 9 months.
Thanks !
But it should be automated for every month .If it runs for next month then it should be August.
Not a problem. Your code already contains the today() function and the intnx function. You might have to read the documentation to understand what they do.
What is the point in putting a date in a macro variable? You know the formula you want to use, so why not just use that in your code where you need to rather than setting up a text string (which is what a macro variable is), and then messing around with trying to use that as a date.
Well, one reason could be to use it in a where clause on an indexed variable. Function calls may prevent the index from being used.
Renamed the topic to better descibe the issue.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.