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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.