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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3211 views
  • 0 likes
  • 3 in conversation