BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Using SAS 9.4

 

Is there a method to convert a character variable in $16 format ( ie. '6/10/2017 5:28') into a numeric timestamp with DATETIME16. format (ie. '03FEB17: 19:33:00')? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @GS2 

 

Try the mdyampm informat

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003172027.htm

 


data want;
char_time='6/10/2017 5:28';
want_time=input(char_time,mdyampm15.);
format want_time datetime18.;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi @GS2 

 

Try the mdyampm informat

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003172027.htm

 


data want;
char_time='6/10/2017 5:28';
want_time=input(char_time,mdyampm15.);
format want_time datetime18.;
run;
Kurt_Bremser
Super User

Convert the separate parts (use the scan() function) into a date and time, and use the dhms() function to combine them into a datetime (use the time value as the "seconds" argument).