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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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