BookmarkSubscribeRSS Feed
mnew
Calcite | Level 5
Experts:

Another beginner question. Reviewing the weekday function this morning. What is the best way to convert the weekday function result to 'Sunday...' instead of showing 1-7? Every solution I came up with seemed to be too clumsy. One of them was simply a bad idea. I tried to format the weekday result in weekdate3. :-).

Thank you!
5 REPLIES 5
Vasile01
Fluorite | Level 6
Hi,
I am not yet an expert on SAS. Try look on proc format.
Warm regards,
Vasile
data_null__
Jade | Level 19
Did you try weekdate9.?

[pre]
6 data _null_;
7 do date = today() to today()+14;
8 put date weekdate9.;
9 end;
10 run;

Saturday
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
[/pre]
mnew
Calcite | Level 5
Thanks to you both!
My question is not how to format a date value to show the weekday. I was hoping for a shortcut that convert the weekday function results (1-7) to Sun-Sat. Proc Format as Vasile suggested is definitely a solution.
Peter_C
Rhodochrosite | Level 12
have you tried PUT as a function?
Weekday = PUT( date_var, weekdate3. );
mnew
Calcite | Level 5
Great idea. This is the shortcut I was looking for. Thank you.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3079 views
  • 0 likes
  • 4 in conversation