Good morning. Any help would be greatly appreciated. I am using the SAS examples from other questions but can't seem to get either to work. It may not be the best approach so I'm open to any help.
I have a standard start date and a numeric time (in two separate fields) and a standard end date and numeric time (in two separate fields). I need to find the number of hours between the two-it could be a start date with a return date a day or two later-it may not always be the same date.
On attempt one I only get missing results, on attempt two I get a conversion like 1405 = 14:05
I have a feeling there's a simple solution, but I can't seem to work it out.
Thank you very much.
Attempt one:
trip_time_standard = hms(input(substr(trip_time, 1, 2), best.), input(substr(trip_time, 3, 2), best.), 0);
I get all missing results.
Attempt two:
data court_19;
set court_18;
trip_time_test = trip_time;
trip_return_time_test = trip_return_time;
t = input(trip_time, best.);
trip_time_DT = hms(int(t/100), mod(t,100), 0);
t = input(trip_return_time, best.);
trip_return_time_DT = hms(int(t/100), mod(t,100), 0);
format trip_time_DT trip_return_time_DT hhmm5.;
run;
reference_date
idnum
trip_date
TRIP_TIME
trip_return_date
TRIP_RETURN_TIME
trip_time_test
trip_return_time_test
t
trip_time_DT
trip_return_time_DT
1/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
2/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
3/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
4/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
5/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
6/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
7/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
8/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
9/1/2018
636
7/11/2009
1416
7/11/2009
1950
1416
1950
1950
14:16
19:50
... View more