I think this might be quicker. proc sql; create table dist as select test1.id, count(distinct test2.id) as some_number, from (select * from test) test1 cross join (select * from test) test2 where geodist(test1.latitude, test1.longitude, test2.latitude, test2.) <= 10 group by test1.id ; quit; run;
... View more