Is there a function in SAS to that converts "Sunday" = 1, "Monday" = 2, etc. or should I just write the codes to do it?
I think you need to write the code 😞
Typically you can browse by category for reference.
Check out the WEEKDAY function which returns a number (1 to 7, I think) based on a SAS date. For example,
day_no = WEEKDAY( SASdate );
I believe this returns weekday based on SAS date value which is numeric.
I was wondering if there's any function that converts actual text i.e. "Sunday" into 1.
The WEEKDAY function does use a SAS date. I assumed that you had the date availabel as a SAS date. If it is just a matter of mapping a string to a value, that's a job for PROC FORMAT.
proc format;
value $day2num
'Sunday' = '1'
'Monday' = '2'
...
;
run;
data x;
daynum = put( daystring, $day2num. );
I think you need to write the code 😞
Typically you can browse by category for reference.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—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.