Hi and thanks again, I created a libname geog. I tried your suggested method and try the following as well: proc sql; create table geog.bankbank1 as select a.fyear, tic, bank_id,zipcitydistance(zipcode, bankzip)as bankdist from geog.comp a , geog.us_banks_unique b where a.fyear=b.fyear group by a.fyear,tic; having not missing(calculated bankdist); quit; proc sql; create table geog.banknum as select fyear, tic, count(0<=bankdist<=60) as banknum from geog.bankbank1 group by tic, fyear; quit; run; I found the similar answer. I attached the files if you need them. I feel it is a bit strange as the number of banks within 60 miles radius is similar for different firms in the same year. Thanks. mspak
... View more