hello all,
in my question data set i have a variable po_time as numbers and i want to create a new variable time in time format.
po_time time
1253 12:53
116 13:16
143 12:43
238 14:38
there are lot of rows. i just want to convert to 24hr time format The variable po_time is in the numeric format.
please suggest. thanks in advance.
thanks..
Try this:
data have;
input po_time;
Cards;
1253
116
143
238
;
run;
data want (keep=po_time time);
set have;
h=int(po_time/100);
m=po_time-(h*100);
if h<12 then h=h+12; /* Are you sure all times are in the afternoon? */
time=hms(h,m,0);
format time time5.;
run;
CTorres
time = input(put(po_time,z4.),hhmmss4.) ;
format time time5. ;
data have ;
input po_time ;
cards;
1253
1160
1430
2380
;
proc print;
run;
data want;
set have;
hms=hms(substr(left(po_time),1,2), substr(left(po_time), 3,2), 00);
format hms time8.;
run;
proc print;
run;
hi all,
thanks for your support. all the answers are very helpful. gained knowledge. thanks for your time.
koushik
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: