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
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.