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).
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 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?
If you're looking for the day of the week and the date combined in a single variable, see @PaigeMiller's answer above.
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;
@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
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.
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.
Ready to level-up your skills? Choose your own adventure.