BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JMart
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

 

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

 

PaigeMiller
Diamond | Level 26

%let Date6mths=%sysfunc(INTNX(Month,%sysfunc(Today()),6,s));

 

No quotes here, quotes would be wrong.

--
Paige Miller
Astounding
PROC Star

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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2552 views
  • 2 likes
  • 4 in conversation