BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buddha_d
Pyrite | Level 9
SAS gurus
How to convert date as 06/12/2016 4:30:55 PM (Char 22) From

12JUN16:16:30:55 (numeric 8 information)?

I used informat mdyampm. But it truncates the seconds
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User
proc format library=work;
picture Exceldt (default=22)
low-high = '%0m/%0d/%Y %h:%0M:%0S %p' (datatype=datetime);
run;

data _null_;
   x = '12JUN16:16:30:55';
   d = input(x,anydtdtm.);
   put  d= ExcelDt.;
run;

View solution in original post

7 REPLIES 7
data_null__
Jade | Level 19

The informat creates the correct datetime value.  MDYAMPM format does not appear to show seconds but you can see they are there when displayed with DATETIME format.

 

27         data _null_;
28            x = '06/12/2016 4:30:55 PM';
29            d = input(x,mdyampm22.);
30            put x= d=mdyampm27. d=datetime.;
31            run;

x=06/12/2016 4:30:55 PM d=6/12/2016  4:30 PM d=12JUN16:16:30:55
buddha_d
Pyrite | Level 9
Input should be 12JUN16:16:30:55 and output should look like 06/12/2016 4:30:55 PM
ballardw
Super User
proc format library=work;
picture Exceldt (default=22)
low-high = '%0m/%0d/%Y %h:%0M:%0S %p' (datatype=datetime);
run;

data _null_;
   x = '12JUN16:16:30:55';
   d = input(x,anydtdtm.);
   put  d= ExcelDt.;
run;
buddha_d
Pyrite | Level 9

Thank you So much, Ballardw. 

            I have googled so much to get this, but your experience beats everything. Thanks again. You are great. 

buddha_d
Pyrite | Level 9
Please respond soon
data_null__
Jade | Level 19

You can use the PROC FORMAT and the PICTURE statement to make the format you desire.

buddha_d
Pyrite | Level 9

Thanks data _null_ it works

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 7 replies
  • 1951 views
  • 2 likes
  • 3 in conversation