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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.