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
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!
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.