BookmarkSubscribeRSS Feed
SASuserxx
Calcite | Level 5

Hi All,

 

im new to programming and only recently been trained in programming in SAS ( a couple of months )

i have a code that i have been working on and im struck on the last part and would like to post for some ideas to test.

 

i want to create a variable called 'extended date' to add 36 months to today() date. this would be rolling. i also needed to created dates in past, that is the reason for the year=2010

 

data 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;

 

my results so far is below to today()

year month sas_date
2010 1 1-Jan-10
2010 2 1-Feb-10
2010 3 1-Mar-10
2010 4 1-Apr-10
2010 5 1-May-10
2010 6 1-Jun-10
2010 7 1-Jul-10
2011 1 1-Jan-11
2011 2 1-Feb-11
2011 3 1-Mar-11
2011 4 1-Apr-11
2011 5 1-May-11
2011 6 1-Jun-11
2011 7 1-Jul-11

 

 

ideal results would look something like this, taking today's date and then creating the next month for the next 36 months into the future

 

today() is always rolling to next month and extended date is taking today() and adding a month for 36 month into the future

year month sas_date extended date
2016 2 1-Feb-16  
2016 3 1-Mar-16  
2016 4 1-Apr-16  
2016 5 1-May-16  
2016 6 1-Jun-16  
2016 6 1-Jul-16  
2016 6   today() 1-Aug-16
2016 6   1-Sep-16
2016 6   1-Oct-16
2016 6   1-Nov-16
2016 6   1-Dec-16

 

thanks

Thiary

9 REPLIES 9
Reeza
Super User

You have the code for incrementing 36 months from your previous question. 

 

Is it the next 6 months your looking for? To the end of the year? I can see your output but don't understand the logic. 

SASuserxx
Calcite | Level 5

Hi,

im trying to create a date from today () to 36 month forward into the future.

 

those dates are from the past as i also need to get a date from a certain date in the past to today. this part i already figured out

 

 

thanks

 

Reeza
Super User

Why are the questions essentially identical?

SASuserxx
Calcite | Level 5

i think maybe a friend is trying to help me and i didnt know they also posted here

Reeza
Super User
Data want;
Do I=1 to 36;

    Date=INTNX ('month', today(), I, 'b');
    OUTPUT;

end;
format date date9.; Run;

This creates a dataset with dates incrementing up to 36 months in the future. 

SASuserxx
Calcite | Level 5

hello Reeza,

 

thanks, this helps. Tested,it created the next 36 months.

i will combine by code to get historical dates and future dates

 

thank you for your help!!!!...

 

 

SASuserxx
Calcite | Level 5

this is not me, i only have one account.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 1630 views
  • 0 likes
  • 3 in conversation