My 2 cents. Should be reasonably fast as well.
data have;
input h f x y t;
datalines;
0 1 -113.219 37.18241 20239
1 0 -113.751 37.73728 20404
1 0 -113.124 37.69568 20428
0 1 -113.862 37.70729 20194
1 0 -113.373 37.14169 20200
1 0 -113.485 37.52134 20724
1 0 -114.051 36.89753 20395
1 0 -113.666 37.45601 20410
1 0 -113.421 36.86348 20511
1 1 -113.59 37.08619 20652
1 1 -113.904 37.40063 20098
0 0 -113.997 37.13753 20050
0 0 -113.458 37.27519 20590
0 0 -113.457 37.45815 20403
0 0 -113.732 37.14784 20252
0 1 -113.673 37.03961 20818
1 1 -113.861 37.75376 20859
0 0 -113.793 36.85021 20730
1 0 -113.488 37.4593 20451
1 0 -113.415 37.26769 20074
;
data want(drop = xx yy tt);
if _N_ = 1 then do;
dcl hash hh(dataset : "have(rename = (x = xx y = yy t = tt) where = (f = 1))");
hh.definekey("h");
hh.definedata("xx", "yy", "tt");
hh.definedone();
dcl hiter i("hh");
end;
set have;
xx = .; yy = .; tt = .; c = 0;
do while (i.next() = 0);
if 0 < geodist(y, x, yy, xx, 'm') < 1 & abs(t - tt) < 30 then c + 1;
end;
run;
... View more