Hi Guys ,
I below dataset not read am pm timings for 24 hrs format and i want difference b/w arrival and departure
data trn;
input station code$ station name $ route number arrival time departure time distance ;
datalines;
shm shalimar 1 -- 16:05 0
src santragachi jn 1 16:16 16:18 6
kgp kharagpur jn 1 17:50 17:55 113
bls balasore 1 19:18 19:20 232
ctc cuttack 1 22:03 22:08 409
bbs bhubaneswar 1 22:50 22:55 437
kur khurda road jn 1 23:25 23:35 456
bam brahmapur 1 01:25 01:30 603
che srikakulam road 1 03:28 03:30 750
vzm vizianagram jn 1 04:28 04:30 819
vskp visakhapatnam 1 05:35 05:55 880
slo samalkot jn 1 07:59 08:00 1030
rjy rajahmundry 1 08:52 08:54 1080
bza vijayawada jn 1 11:20 11:40 1229
wl warangal 1 14:39 14:40 1437
sc secunderabad jn 1 18:30 -- 1578
;run;
You need to use appropriate time informats when reading the data so SAS converts the source strings to SAS time values. This allows you to then use these values for calculations.
You also need to apply the appropriate time formats so when printing the values they become human readable.
data demo;
input arrival_time :time. departure_time :time.;
format arrival_time departure_time travel_time hhmm5.;
travel_time=departure_time-arrival_time;
datalines;
16:05 20:55
04:05 20:55
;
proc print data=demo;
run;
If you don't understand yet how SAS Date, DateTime and Time values work then read the following:
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.