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