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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.