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 🙂
Convert the datetime value to a date:
birth_date = datepart(birth_date);
format birth_date date11.;
Use the DATE11. format.
Convert the datetime value to a date:
birth_date = datepart(birth_date);
format birth_date date11.;
Perfect! Thank you so much!
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
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.
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.