Data have character time
time
10:32
10:14
10:15
10:06
09:42
i want
10:32:00
10:14:00
10:15:00
10:06:00
09:42:00
You would read a raw file (i.e. a text file with character values for time) with an INPUT statement, and a suitable INFORMAT for the variable. Analogously you can read a character variable to a numeric (time) variables with an INPUT function, and a suitable INFORMAT.
data have;
input txt_time $5.;
datalines;
10:32
10:14
10:15
10:06
09:42
run;
data want;
set have;
num_time=input(txt_time,time5.0);
format num_time time8.0;
put num_time=;
run;
whilch display on the log
num_time=10:32:00
num_time=10:14:00
num_time=10:15:00
num_time=10:06:00
num_time=9:42:00
data have;
input time $10.;
cards;
10:32
10:14
10:15
10:06
09:42
;
data want;
set have;
num_time=input(time,time.);
format num_time time8.;
run;
You fix that when you read the data in the first place:
data have;
input time time5.;
format time time8.;
cards;
10:32
10:14
10:15
10:06
09:42
;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.