BookmarkSubscribeRSS Feed
elopomorph88
Calcite | Level 5

I have a column of data in the SAS format of DATE9.   I want to just read the day number from the date from this column of data.  For example, one of the dates is 09Sep21 and I want to read the day of 9 from this data.  So any advice on how to read the day number from a SAS date would be greatly appreciated.  

 

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Use DAY function

 

day(date);

PaigeMiller
Diamond | Level 26

and for anyone else reading along, if you want the month you can use

 

month(date)

and if you want the year, you can use

 

year(date)

The format of the variable is irrelevant when you use the DAY() or the MONTH() or the YEAR() function; however the variable must be numeric, and the variable must be a valid SAS date (number of days since 01JAN1960) and not something like 090921 which is not a valid SAS date.

--
Paige Miller
Reeza
Super User
Day function if you need to convert it, Day format if you want to summarize by day across various months and want to avoid having to create a new variable.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2210 views
  • 2 likes
  • 4 in conversation