Hi there!
I have 3 variables: a month column and a year column and a day column. The day column with have the value 15 referring to mid-month and will be constant. Now using the 3 fields, I would like to create a Date column in Date9. Format. How do I do this?
Sample Data
Obs | Month | Year | Day |
1 | 5 | 2008 | 15 |
2 | 8 | 2009 | 15 |
3 | 4 | 2010 | 15 |
4 | 9 | 2005 | 15 |
New Data
Obs | Month | Year | Day | New_Date |
1 | 5 | 2008 | 15 | 15May2008 |
2 | 8 | 2009 | 15 | 15Oct2009 |
3 | 4 | 2010 | 15 | 15Apr2010 |
4 | 9 | 2005 | 15 | 15Sep2005 |
data want;
set have;
new_date=mdy(month,day,year);
format new_date date9.;
run;
data want;
set have;
new_date=mdy(month,day,year);
format new_date date9.;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.