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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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