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

Hi SAS gurus,

 

May I ask one question how to take today date + 36 months into future? Using the variable below SAS_extension? 

 

data in.indata;

                do year=2010 to year(today());

                                do month=1 to month(today());

                                                SAS_date=mdy(month,1,year);                                                                     

                                                output;

                                end;

                end;

 

                format SAS_date date9.;

run;

 

SAS_extension= SAS_date+36 months *** I would like to take today date + 36 months into future

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

INTNX - note the 4th/last parameter aligns it, in this case, I've chosen the beginning of the month. You can choose, end or same. Look up the values in the documentation.

 

date_future36=intnx('month', today(), 36, 'b')

View solution in original post

2 REPLIES 2
Reeza
Super User

INTNX - note the 4th/last parameter aligns it, in this case, I've chosen the beginning of the month. You can choose, end or same. Look up the values in the documentation.

 

date_future36=intnx('month', today(), 36, 'b')
PGStats
Opal | Level 21

data in.indata;

                do year=2010 to year(today());

                                do month=1 to month(today());

                                                SAS_date=mdy(month,1,year);                                                                     

                                                output;

                                end;

                end;

run;

 


are you sure this is what you want?

 

do month=1 to month(today())

 

will return only the months from January to, say, June for ALL years.

 

To get all months, you would do better with:

 

SAS_date = '01JAN2010'd;
do while ( SAS_date <= intnx("MONTH", Today(), 0) );
	SAS_date = intnx("MONTH", SAS_date, 1);
	output;
	end;

 

 

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 1437 views
  • 7 likes
  • 3 in conversation