I am trying to convert the time from a column called Start_Time to a number.
An example is (In Military Time) 6:24:43 to the number 6.
Once I get the number I want to put that number into a new Column called New_Time.
Are you trying to pull the just the hour? There is an hour function.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Yes.
data want;
start_time = '6:24:43';
new_time = input(start_time,time8.);
format new_time time8.;
run;
Thanks for the info.
How do use that column "start_time" instead of quantifying each one such as the 6:24:43 ?
To use an existing dataset, use the set statement:
/* make up some sample data */
data have;
input start_time :$8.;
cards;
6:24:43
;
run;
data want;
set have;
new_time = input(start_time,time8.);
format new_time time8.;
run;
If you only want the hour and want to read from the existing data set, use KurtBremser's SET statement with the HOUR function:
/* make up some sample data */
data have;
input start_time :$8.;
cards;
6:24:43
23:11:11
01:40:30
;
run;
data want;
set have;
new_time = hour(input(start_time,time8.));
run;
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.