BookmarkSubscribeRSS Feed
aishajennifer1
Calcite | Level 5

I currently have the date/time format in this: "Thurs Dec 19 12:30:31 2019"

 

I would like to create a new variable so that I am just shown date/time: 19DEC19 12:30:31"

 

How do I do this?

 

I am using this as my guide but there is no format that falls in the category above: https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm

1 REPLY 1
Kurt_Bremser
Super User

Use the scan() function to extract the 3rd, 2nd and 5th "word", concatenate and use the date9. informat to convert to a date. Use the time8. informat on the 4th "word", and then you can build the datetime from the date and time.

 


@aishajennifer1 wrote:

I currently have the date/time format in this: "Thurs Dec 19 12:30:31 2019"

 

I would like to create a new variable so that I am just shown date/time: 19DEC19 12:30:31"

 

How do I do this?

 

I am using this as my guide but there is no format that falls in the category above: https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm


 

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
  • 1 reply
  • 701 views
  • 0 likes
  • 2 in conversation