BookmarkSubscribeRSS Feed
arpitagarwal512
Calcite | Level 5

Hi Team,

 

i am unable to convert below date format:

 

"02/05/1992" to "1992-05-05 : 00:00:00"

 

source is in string format and output should be in numeric format.

 

 

1 REPLY 1
jklaverstijn
Rhodochrosite | Level 12

You're looking at a simnple two-step process:

 

1) Convert the string to a date

2) Convert the date to a datetime

 

This can be done in a single line of code:

new_dt = dhms(input(date_str, ddmmyy10.), 0,0,0);

Now you have a datetime. But I do not know a predefined format for that so you may have to roll your own. Have a look at this how to do that.

 

EDIT: This would be how to do the custom format:

 

proc format;
  picture mydt other='%0Y-%0m-%0d : %0H:%0M:%0S' (datatype=datetime);
run;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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