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).

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2494 views
  • 0 likes
  • 3 in conversation