x cd /pub/data/sf12000/Tools; %let pgm=aggradius_xxgeos; filename pgm "&pgm..sas"; /*---Aggregate pop counts around the radius of a location using 2000 census pop counts from the stf12000_xxgeos directory. This is a circular area pop aggregation setup. Jan, 2002. John Blodgett, OSEDA, U. of Missouri Outreach & Extension, Under contract with the Missouri Census Data Center ---*/; title "&pgm: 15-mile Radius Population and Over-65 Population"; title2 'Site: 500m Barrett, Malden, MO.'; title3 'Note: Small Portion of Arkansas in Circle Omitted from Report'; options ls=64 ps=40; %let y0=36.58024; %let x0=-89.971833; *<--from Eagle geocoder using address: 500 Barrett, Malden, MO 63863-; %let radius=15; libname user '/tmp/storage/john'; libname sf1geos '/pub/data/sf12000/xxgeos' access=readonly; libname sf12000x '/pub/data/census_2000/sf12000x' access=readonly; data rept; retain xlong1 x0 &x0 ylat1 y0 &y0; retain d2r .0174532925; *=atan(1)/45; *--convert coords from degrees to radians--; *set sf1geos.arblks sf1geos.moblks; *<----------------whatever states are within the radius; set sf12000x.moblks(keep=county intptlon intptlat totpop over65); if _n_=1 then do; xlong1r=xlong1 * d2r; ylat1r=ylat1 * d2r; end; retain; if max( abs(x0 - intptlon) , abs(y0-intptlat) ) le &radius/50; *<========reasonable pre-filter=========; xlong2r=intptlon * d2r; ylat2r=intptlat * d2r; d1=3949.99*arcos(sin(ylat1r) * sin(ylat2r) + cos(ylat1r) * cos(ylat2r) * cos(xlong1r - xlong2r)); if d1 le &radius; keep county totpop over65;; run; proc sort; by county; run; %agg(aggin=rept,aggout=aggout,aggby=county,aggvars=totpop over65,dropvars=_type_ _nag_); proc print u d data=aggout; id county; sum totpop over65; run;