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
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.
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
As shown in the other thread that was referenced, use the intnx() function to increment dates.
Why are the questions essentially identical?
i think maybe a friend is trying to help me and i didnt know they also posted here
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.
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!!!!...
So either this is a homework question or you have two accounts?
this is not me, i only have one account.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: