Help using Base SAS procedures

Show weekday function result (1) as weekday (Sunday)?

Reply
Frequent Contributor
Posts: 100

Show weekday function result (1) as weekday (Sunday)?

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!
Occasional Contributor
Posts: 14

Re: Show weekday function result (1) as weekday (Sunday)?

Hi,
I am not yet an expert on SAS. Try look on proc format.
Warm regards,
Vasile
Respected Advisor
Posts: 3,799

Re: Show weekday function result (1) as weekday (Sunday)?

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]
Frequent Contributor
Posts: 100

Re: Show weekday function result (1) as weekday (Sunday)?

Posted in reply to data_null__
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.
Valued Guide
Posts: 2,177

Re: Show weekday function result (1) as weekday (Sunday)?

have you tried PUT as a function?
Weekday = PUT( date_var, weekdate3. );
Frequent Contributor
Posts: 100

Re: Show weekday function result (1) as weekday (Sunday)?

Great idea. This is the shortcut I was looking for. Thank you.
Ask a Question
Discussion stats
  • 5 replies
  • 214 views
  • 0 likes
  • 4 in conversation