I would like to put a macro variable that would reference Today plus 6 months.
In my initial statement I use to change the date manually in my macro and it works fine but now I want to upgrade my macro so that it calculate Today plus 6 months without me changing it manually.
My original statement look like this : %let Date6mths=5JAN2018;
Then I tried a couple of variation of this code to have this date automatically calculated from the date of production:
%let Date6mths="%sysfunc(INTNX(Month,Today(),6,s))";
- with double quote around the %sysfunc
- without double quote and with single quote for the parameter within the Intnx function
and I also tried this variation : %let Date6mths=INTNX('Month',Today(),6,'s'))";
I use the macro within a Proc SQL
Thx you all for your help
Probably close enough:
%let result =%sysfunc(INTNX(Month,"&sysdate9"d,6,s),date9);
Technically, &sysdate9 is set when the program begins to execute. It contains the current date (just like the TODAY function), but it won't change if the program continues to execute past midnight. In practice, most of the time nobody cares about that.
And why do you need one? You already have the logic which you can use in the code:
intnx('month',today(),6,'s)
So just populate that through the code where you need to use the date + 6 months. Saves code creating that, storage of a macro variable which is text to hold it, then more code to convert it to numeric when used.
Oh, and to correct your code you don't need the double quotes around the sysfunc.
%let Date6mths=%sysfunc(INTNX(Month,%sysfunc(Today()),6,s));
No quotes here, quotes would be wrong.
Probably close enough:
%let result =%sysfunc(INTNX(Month,"&sysdate9"d,6,s),date9);
Technically, &sysdate9 is set when the program begins to execute. It contains the current date (just like the TODAY function), but it won't change if the program continues to execute past midnight. In practice, most of the time nobody cares about that.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.