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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 1238 views
  • 0 likes
  • 4 in conversation