*---stored in $6386.public.sascode(circle)---*; *--sample of selecting data within circular distance of point-; *libname stf903x '/mscdc/data/stf903x'; %let radius=50; data; *--read specific obs to get coords of "ground zero" circle center pt-; set stf903x.mocntys(where=(county='29019')keep=xcentrm ycentrm county); *<===change county code 29019 as needed; x0=xcentrm; y0=ycentrm; *--now read all the data and select only if within &radius miles of x0,y0; do while (not eod); set stf903x.mocntys end=eod; dsq=(x0-xcentrm)**2 + (y0-ycentrm)**2; if dsq le (&radius * &radius) then output; file print; distance=sqrt(dsq); put areaname ' is ' distance 5. ' miles ' 'from the center of Boone County'; end; drop dsq xcentrm ycentrm x0 y0 %pcts903x; stop; run; proc print; var county totpop areasqmi; sum totpop areasqmi; title 'Counties within 50 mile radius of Boone'; *<===change title; proc means sum; title "totals of &radius-mile radius"; run;