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


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 366 views
  • 0 likes
  • 2 in conversation