*--this is sascode(caps93xp): does most of the work in generating a 1990 stf3-based "caps +" report. ; *--editing for new year simply means editing value assigned to popyy parm!!!--*; *--edited 8-7-96 to point to latest bg pop estimates for 1996 (jgb)-; *--edited 8-4-97 to point to latest bg pop estimates for 1997 (jgb)-; *--edited 7-22-98 to point to latest bg pop estimates for 1998 (jgb)-; *--several modes 4-12-00 to reference different bg estimates set-; %let popestyr=98; *<=====edit when later year available==; %let popyy=pop&popestyr; %put ; %put; %put ****Begin executing sascode(caps93xp), rev. 4-12-00 ***; *<=========; %put -------------------------------------------------------; %put ***************popyy= &popyy; %put ***************popyy= &popyy; %put ***************popyy= &popyy; %put ***************popyy= &popyy; %put stf903x= &stf903x (parm to specify SAS data set to access with base data); data circle; retain _xsite &xsite _ysite &ysite; length sitename $32; retain sitename "&sitename"; retain _radius &radius; retain _radiusq; if _radiusq=. then _radiusq=_radius**2; set &stf903x(drop=geocode areaname place cousubce cd); by slvl; where slvl="150"; *--select bg summaries--; &filter ; *--ready to do distance select. for efficiency we first eliminate anything outside the _radius-mile square--; if abs(xcentrm - _xsite) le _radius and abs(ycentrm - _ysite) le _radius; *--apply pythagorean distance formula learned in 11th grade to get distance between 2 points.--*; distance=(xcentrm-_xsite)**2 + (ycentrm-_ysite)**2; if distance le _radiusq; *--comparing squares of distances, which is equivalent to if (true) distance le _radius--; distance=sqrt(distance); **if user codes %let radius=1 2 3 then the dospecs parm will be assigned the value "3, 2, 1" **; do circl=&dospecs; if distance le circl then output; else return; end; drop _radius _radiusq ; drop slvl; format distance 7.2; run; data circlep/view=circlep; *--use view to add &popyy var; merge circle(in=incirc) bgests.mo&popestyr.bgs; by county tract bg; if incirc; run; proc sort data=circlep out=circle2; by circl distance; run; options nosymbolgen; *----aggregate the data by circls--; %agg(setin=circle2,setout=circtots, aggby=circl,idvars=sitename _xsite _ysite, grand=0,dropvars=_lvl_, vars= &popyy xcentrm ycentrm areasqmi totpop pctsmpld landsqmi poppsqmi female pctfemal rural onfarms infamily alone groupqtr popinhhs pctgq white black asianpi amindian hispanic pctwhite pctblack pctasian pctamind pcthisp pct0_4 pct5_9 pct10_13 pct14_17 pct18_24 pct25_34 pct35_44 pct45_54 pct55_59 pct60_64 pct65_74 pct75_84 pct85_up pct0_19 pct20_39 pct40_64 pct65_up pct0_9 pct0_13 pct0_17 pct0_24 pct0_34 pct0_44 pct0_54 pct0_59 pct0_64 pct0_74 pct0_84 age0_4 age5_9 age10_13 age14_17 age18_24 age25_34 age35_44 age45_54 age55_59 age60_64 age65_74 age75_84 age85_up age0_19 age20_39 age40_64 age65_up age0_17 age18_44 age45_64 medage tothhs avghhsz hhs1ov65 hhs1 hhs2 hhs3_4 hhs5_up pcthhs1 pcthhs2 pcthhs3_ pcthhs5_ families mcfams mcwchild femhead femheadc nonfhhs pctfamhh pctmcfam pctmcwch pctfemhe pctfemhc pctnfhhs hhi0_10 hhi10_15 hhi15_25 hhi25_35 hhi35_50 hhi50_75 hhi75_99 hhi100up phi0_10 phi10_15 phi15_25 phi25_35 phi35_50 phi50_75 phi75_99 phi100up phi0_15 phi0_25 phi0_35 phi0_50 phi0_75 phi0_99 medhhinc avghhinc famwork0 famwork1 famwork2 famwork3 avgfami0 avgfami1 avgfami2 avgfami3 medfamin avgfamin pci pcihhs poor verypoor pooruniv pctpoor pctveryp age25_up elemeduc highsch1 highsch2 college1 college2 college3 college4 pctelem pcthsch1 pcthsch2 pctcoll1 pctcoll2 pctcoll3 pctcoll4 pctnhsgr pctnocol pctnodeg pctnobac pctnogrp clf unemplyd empovr16 unempfem emplyfem pctunemp clffem nonclff pctunemf mgrprof techsadm servoccs farmetc otherocc pctmgpr pcttechs pctserv pctfarme pctothoc totunits occunits vacant ownerocc rented units1 units5up mobilhms condos pctunit1 pctunit5 pctvacnt pctowner pctrentr medyrblt builta85 built80_ built70_ built60_ built50_ built40_ builtp40 nbuiltmd pctbltmd pctblt85 pctblt40 spownunt avghval medhval untscrnt medrent avgrent, means= xcentrm ycentrm pctsmpld poppsqmi pctgq pctwhite pctblack pctfemal pctasian pctamind pcthisp pct0_4 pct5_9 pct10_13 pct14_17 pct18_24 pct25_34 pct35_44 pct45_54 pct55_59 pct60_64 pct65_74 pct75_84 pct85_up pct0_19 pct20_39 pct40_64 pct65_up pct0_9 pct0_13 pct0_17 pct0_24 pct0_34 pct0_44 pct0_54 pct0_59 pct0_64 pct0_74 pct0_84 medage avghhsz pcthhs1 pcthhs2 pcthhs3_ pcthhs5_ pctfamhh pctmcfam pctmcwch pctfemhe pctfemhc pctnfhhs phi0_10 phi10_15 phi15_25 phi25_35 phi35_50 phi50_75 phi75_99 phi100up phi0_15 phi0_25 phi0_35 phi0_50 phi0_75 phi0_99 medhhinc avghhinc avgfami0 avgfami1 avgfami2 avgfami3 medfamin avgfamin pci pcihhs pctpoor pctveryp pctelem pcthsch1 pcthsch2 pctcoll1 pctcoll2 pctcoll3 pctcoll4 pctnhsgr pctnocol pctnodeg pctnobac pctnogrp pctunemp pctunemf pctmgpr pcttechs pctserv pctfarme pctothoc pctunit1 pctunit5 pctvacnt pctowner pctrentr medyrblt pctblt85 pctbltmd pctblt40 avghval medhval medrent avgrent, mweights=areasqmi areasqmi totpop landsqmi totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop totpop tothhs tothhs tothhs tothhs tothhs tothhs families families families families tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs tothhs famwork0 famwork1 famwork2 famwork3 families families totpop popinhhs pooruniv pooruniv age25_up age25_up age25_up age25_up age25_up age25_up age25_up age25_up age25_up age25_up age25_up age25_up clf clffem empovr16 empovr16 empovr16 empovr16 empovr16 totunits totunits totunits totunits totunits totunits totunits totunits totunits spownunt spownunt untscrnt untscrnt ) run; *----post-agg step to re-estimate some medians and put back builddec, etc.-----*; data circtots; set circtots; *--define the temporary vars and arrays needed to do median estimating. we need arrays to measure the size (width) of intervals as well as arrays of counts to be associated with those intervals.--*; retain agew1 4 agew2 5 agew3 agew4 4 agew5 7 agew6-agew13 10; retain hhiw1 10000 hhiw2 5000 hhiw3 hhiw4 10000 hhiw5 15000 hhiw6 hhiw7 25000 hhiw8 50000; drop agew1-agew13 hhiw1-hhiw8; array agew agew1-agew13; array agec age0_4--age85_up; array hhiw hhiw1-hhiw8; array hhic hhi0_10--hhi100up; %median(intsize=agew,intvals=agec,mdn=medage) *--for medhhinc check to see if weighted avg value is over 100000 & if so use it. else re-estimate based on distribution--*; if medhhinc lt 100000 then do; %median(intsize=hhiw,intvals=hhic,mdn=medhhinc) end; *--re-define decade where most homes built. code copied from stf903x; _bmax=built80_; builddec='1980-3/90'; if built70_ gt _bmax then do; _bmax=built70_; builddec='1970-1979'; end; if built60_ gt _bmax then do; _bmax=built60_; builddec='1960-1969'; end; if built50_ gt _bmax then do; _bmax=built50_; builddec='1950-1959'; end; if built40_ gt _bmax then do; _bmax=built40_; builddec='1940-1949'; end; if builtp40 gt _bmax then do; _bmax=builtp40; builddec='pre 1940 '; end; nbuiltmd=_bmax; drop _bmax; if totunits then pctbltmd=nbuiltmd*100/totunits; run; *---ready to print report. this is a variation of standard xtabs3 report---*; *<----including from separate module, 12-6-94--; %include '/mscdc/sascode/capsprpt.sas';