This might let you handle surgeries that cross midnight, one way is to use conditional processing.
[pre]
data surgery;
input patient $ start:time. end:time.;
format start end time.;
datalines;
patient1 6:54 8:05
patient2 13:45 17:45
patient3 7:05 7:30
patient4 23:53 1:22
patient5 0:45 3:30
;
run;
data surgery;
set surgery;
array HR HR00-HR23;
do i=0 to 23;
if hour(end) lt hour(start) then do;
if i ge hour(start) or i le hour(end) then HR{i+1} = 1;
end;
else do;
if i ge hour(start) and i le hour(end) then HR{i+1} = 1;
end;
end;
drop i;
run;
... View more