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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 690 views
  • 2 likes
  • 4 in conversation