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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1475 views
  • 2 likes
  • 4 in conversation