🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-13-2017 12:18 PM
(3402 views)
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Input should be 12JUN16:16:30:55 and output should look like 06/12/2016 4:30:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you So much, Ballardw.
I have googled so much to get this, but your experience beats everything. Thanks again. You are great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please respond soon
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use the PROC FORMAT and the PICTURE statement to make the format you desire.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks data _null_ it works