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

I have a column titled "Birth_Date" with long SAS date values.

 

The dates look like this: 01MAR1993:00:00:00

 

All I want is to convert those values to the following format: 01-MAR-1993.

 

So, long story short. I just want to convert the date to a different format. I've seen other solutions that are close, but I can't seem to get to the finish line on this one. Spare me the judgment please 🙂

1 ACCEPTED SOLUTION
4 REPLIES 4
PaigeMiller
Diamond | Level 26

Use the DATE11. format.

--
Paige Miller
eer_seer
Obsidian | Level 7

Perfect!  Thank you so much!

Tom
Super User Tom
Super User

You can use the DTDATE format to print just the date part of a datetime value, but it does not support printing the hyphens.

Or you could convert your datetime value (number of seconds) into a date value (number of days) and then use the DATE11. format.

287  data _null_;
288    dt='01MAR1993:00:00:00'dt;
289    date=datepart(dt);
290    put dt= dt datetime20. +1 dt dtdate9. ;
291    put date=  date date11. ;
292  run;

dt=1046563200   01MAR1993:00:00:00 01MAR1993
date=12113 01-MAR-1993

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

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1041 views
  • 2 likes
  • 4 in conversation