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

There is a variable ttime in character form in table A, which represents the transaction time. The content is as follows:
09-05-21
10-56-34
15-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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
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

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Please show us the code that you have tried.

--
Paige Miller
PeterClemmensen
Tourmaline | Level 20
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;
singhsahab
Lapis Lazuli | Level 10

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 632 views
  • 2 likes
  • 4 in conversation