Hi All,
I have the following table with name and date. I want to extract year, month, day_of_week (eg: Monday, tuesday) and monthyear (eg: JAN2014),
Name | Start_Date |
A | 2015-06-17 |
B | 2015-06-03 |
C | 2015-06-12 |
D | 2015-07-30 |
E | 2015-07-15 |
I have the following code, can't figure out what would be the code for day_of_week (eg: Monday, tuesday) and monthyear (eg: JAN2014). Can someone help please.
data out;
set have;
year = year(Start_Date);
month = month(Start_Date);
run;
Output will look like this:
Name | Start Date | Year | Month | Day_of_Week | monthyear |
A | 2015-06-17 | 2015 | Jun | Wednesday | Jun2015 |
B | 2015-06-03 | 2015 | Jun | Wednesday | Jun2015 |
C | 2015-06-12 | 2015 | Jun | Friday | Jun2015 |
D | 2015-07-30 | 2015 | Jul | Sunday | Jul2015 |
E | 2015-07-15 | 2015 | Jul | Saturday | Jul2015 |
Thanks,
Day_of_Week=put(weekday(Start_Date)+1,downame7.);
monthyear=put(Start_Date,monyy7.);
Day_of_Week=put(weekday(Start_Date)+1,downame7.);
monthyear=put(Start_Date,monyy7.);
Look at the date formats
downame - day of week
year - year
monname3 - month name, either full or 3 chars
monyear - for Jul2015
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.