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;
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
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;
Thank you So much, Ballardw.
I have googled so much to get this, but your experience beats everything. Thanks again. You are great.
You can use the PROC FORMAT and the PICTURE statement to make the format you desire.
Thanks data _null_ it works
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.
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.