BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MagD
Quartz | Level 8

Hi All,

 

Please assist me with converting a date variable from 05AUG2014:00:00:00.000 to 201408 in a one line in proc sql query. I've been using this but its not working:

 

f.period as period format=yymmn6.,

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Your variable is probably a datetime type. The format yymmn6. relates to a date format. Use nextcode

datepart(f.period) as period format=yymmn6.,

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

Your variable is probably a datetime type. The format yymmn6. relates to a date format. Use nextcode

datepart(f.period) as period format=yymmn6.,
Kurt_Bremser
Super User

In SAS, date values are (integer) counts of days from 1960-01-01 (this day is day zero). Time and date values are counts of seconds, from 00:00:00 (time) or 1960-01-01T00:00:00 (datetime).

To make a count of seconds into a count of days, you use the DATEPART function, as already explained.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 2 replies
  • 531 views
  • 0 likes
  • 3 in conversation