BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mlogan
Lapis Lazuli | Level 10

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),

NameStart_Date
A2015-06-17
B2015-06-03
C2015-06-12
D2015-07-30
E2015-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:

NameStart DateYear MonthDay_of_Weekmonthyear
A2015-06-172015JunWednesdayJun2015
B2015-06-032015JunWednesdayJun2015
C2015-06-122015JunFridayJun2015
D2015-07-302015JulSundayJul2015
E2015-07-152015JulSaturdayJul2015


Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10

Day_of_Week=put(weekday(Start_Date)+1,downame7.);

monthyear=put(Start_Date,monyy7.);

View solution in original post

2 REPLIES 2
slchen
Lapis Lazuli | Level 10

Day_of_Week=put(weekday(Start_Date)+1,downame7.);

monthyear=put(Start_Date,monyy7.);

Reeza
Super User

Look at the date formats

downame - day of week

year  - year

monname3 - month name, either full or 3 chars

monyear - for Jul2015

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

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.

Discussion stats
  • 2 replies
  • 1279 views
  • 0 likes
  • 3 in conversation