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


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 722 views
  • 0 likes
  • 2 in conversation