BookmarkSubscribeRSS Feed
Ddb300
Calcite | Level 5
Is there a code for taking a column from a large data set which shows the date in standard format to show the date and the day of the week it is ?

simplistic preferred
6 REPLIES 6
PaigeMiller
Diamond | Level 26

You can apply the WEEKDATE format to the variable that contains the date (assuming it is truly a SAS date value, which is the number of days since 01JAN1960).

--
Paige Miller
mklangley
Lapis Lazuli | Level 10

Or here is another way, using the DOWNAME format, to get the day of the week (Sunday, Monday, etc.):

data example;
    format date date9.;
    format day_of_the_week downame.;
    date = "17Feb2021"d;
    day_of_the_week = date;
run;

 

Ddb300
Calcite | Level 5
Will this show the date also or just the day of the week?
ballardw
Super User

@Ddb300 wrote:
Will this show the date also or just the day of the week?

SAS Provides a bunch of formats. You can also create your own with Proc Format.

How about showing an example of what you want the result to look like so we do not have to guess what you want?

mklangley
Lapis Lazuli | Level 10

If you're looking for the day of the week and the date combined in a single variable, see @PaigeMiller's answer above.

Reeza
Super User

What do you mean exactly? Do you want to see Wednesday February 17, 2021? Wednesday? Day 4 (sunday = day 1)?

Either way, you're likely looking for a format, depending on exactly what you want.

data demo;
date = "17Feb2021"d;
date1 = date;
date2 = date;
format date weekdate. date1 weekday. date2 date9.;
run;

proc print data=demo;run;



https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=leforinforref&docsetTarge...

 


@Ddb300 wrote:
Is there a code for taking a column from a large data set which shows the date in standard format to show the date and the day of the week it is ?

simplistic preferred

 

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1186 views
  • 1 like
  • 5 in conversation