There is a variable ttime in character form in table A, which represents the transaction time. The content is as follows:09-05-2110-56-3415-23-47
The digits separated are respectively hours, minutes, and seconds.
(1) Write the data stepthat converts ttime to a time variable.(2)To see the value of the ttime in time format, write the format statement.
data have; input ttime $8.; datalines; 09-05-21 10-56-34 15-23-47 ; data want; set have; ttime_num=input(ttime, time8.); format ttime_num time8.; run;
View solution in original post
Please show us the code that you have tried.
Hello,
data want (keep=time_var); input ttime $; time_var=input(ttime,time9.); format time_var time9.; datalines; 09-05-21 10-56-34 15-23-47 ; run; or data want (keep=time_var); input ttime $; new_var_time=tranwrd(ttime,'-',":"); time_var=input(new_var_time,time9.); format time_var time9.; datalines; 09-05-21 10-56-34 15-23-47 ; run;
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!
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.