BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Citrine10
Obsidian | Level 7

Hi

 

I need help with converting datetime20. to a character.

The format of the data is as follows:

18AUG2022:13:41:10

 

I need to convert it to character because I am concatenating this field with another character field. 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data test;
   dt  = '18AUG2022:13:41:10'dt;
   cdt = put(dt, datetime20.);
   format dt datetime20.;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20
data test;
   dt  = '18AUG2022:13:41:10'dt;
   cdt = put(dt, datetime20.);
   format dt datetime20.;
run;
Tom
Super User Tom
Super User

@Citrine10 wrote:

Hi

 

I need help with converting datetime20. to a character.

The format of the data is as follows:

18AUG2022:13:41:10

 

I need to convert it to character because I am concatenating this field with another character field. 


In that case you probably do not want to use DATETIME format.  Instead use something like E8601DT19. that will generate a string that will sort in chronological order.

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1500 views
  • 0 likes
  • 4 in conversation