BookmarkSubscribeRSS Feed
1239
Calcite | Level 5

Hi All,

How to change the date&time fromat from 09SEP21:00:00:00 to 09-SEP-2021 00:00 (DD-MMM-YYYY HH:MM). Please help.

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

I don't know of such a format out-the-box. 

 

However, you can roll out your own format like this

 

proc format; 
  picture dtfmt (default=20)
    other = '%0d-%b-%Y %0H:%0M' (datatype = datetime)
  ;
run;

data _null_;
   dt = '09SEP2021 00:00:0'dt;
   put dt dtfmt.;
run;
Tom
Super User Tom
Super User

You mentioned formatting of dates, but your description of what you want is for DATETIME values (number of seconds) not DATE values (number of days).

 

Do any of the datetime values you need to display contain actual non-zero value for the time of day component?  If not then why not just convert the values from seconds to days by using the DATEPART() function and then use the DATE11 format to display the dates in DD-MON-YYYY style?

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
  • 2 replies
  • 1421 views
  • 3 likes
  • 3 in conversation