Do you have any data where either of those conditions exist? Your question requires that people be present at the same time and I see no cases where that happens.
At any rate (and not testing this due to limited data)
proc sql;
create table fast as select a.id, count(*) as fast
from one a, one b where (b.arrive > a.arrive and b.serve < a.serve) group by a.id;
create table slow as select a.id, count(*) as slow
from one a, one b where (b.arrive < a.arrive and b.serve > a.serve) group by a.id;
create table times as select a.id, s.slow, f.fast
from one a left join slow s on a.id = s.id left join fast on a.id = f.id;
quit;
Should work.
... View more