x cd /pub/data/sf32000x/Tools; %let pgm=eezdata_boone_proposed; filename pgm "&pgm..sas"; *---Extract data for selected BGs in Boone county, MO corresponding to proposed EEZs June, 2012. John Blodgett, OSEDA, U of Missouri Extension. Coding begins 6-25-12. Modeled on the eezdata_clinton_sample setup. ---*; libname sf3x '/pub/data/sf32000x'; libname sf3 '/pub/data/sf32000'; libname temp '/pub/data/temp'; %let numvars=totpop sampcount TotPop100 PctSample HHpop TotHHs Families MedianHHInc MedianFamInc PCI PovUniverse Poor PctPoor MeanPovRatio PoorFamilies PctPoorFamilies PoorNonFamHHs PctPoorNonFamHHs TotHUs SampHUs TotHUs100 Occupied OccHUs100 PctOccHUSample; %let numvars2=&numvars poorhhs pctpoorhhs povState PctPovState; %let numvarsprint=TotHHs PoorHHs PctPoorHHs PovState PctPovState PctPoorFamilies PctPoorNonFamHHs Poor PctPoor MedianHHInc MedianFamInc; data &pgm (label="Sample EEZ data at split-BG Level"); length County $5 City $18 Township $18 Tract $7 BG $1 ; set sf3x.moh(keep=sumlev logrecno state county cousubfp placefp tract bg &numvars where=(county='29019' and sumLev='090')) sf3x.moi(keep=sumlev logrecno state county areaname &numvars where=(sumlev in ('040','050')) ); if sumlev='050' then if county='29019'; if sumlev='090' then do; if (cousubfp in ('12142','15688','48944','62840')) and (placefp in ('15670','99999')); select (tract); when('0010.02') if bg='4'; when('0002.00') if bg in ('1','3'); when('0010.01') if bg ='2'; when('0011.01') if bg='1'; when('0015.01') if bg in ('1','3','6'); when('0015.02') if bg in ('1','3'); when('0009.00') if bg in ('1','2'); when('0014.00') if bg = '2'; when('0016.02') if bg='1'; otherwise delete; end; areaname="Tract "||tract||", BG "||bg; *** if logrecno in (6506,6509,6517,6519,6522,6523) then delete; length _arg $7; _arg=state||cousubfp; Township=put(_arg,$fmcd.); _arg=state||placefp; if placefp='99999' then City='Unincorporated'; else City =put(_arg,$place.); end; *--sumlev 090 processing---; PoorHHs=PoorFamilies + PoorNonFamHHs; if tothhs then PctPoorHHs=100*PoorHHs/TotHHs; NonFamHHs=Tothhs - families; if NonFamHHs then PctPoorNonFamHHs=100*PoorNonFamHHs/NonFamHHs; label PoorHHs='Poor Households (Census)' PctPoorHHs='% Poor Hseholds'; format pctpoorhhs 5.1; label OccHUs100='Occupied Housing Units (100% Count)'; drop _: ; run; proc sort; by logrecno; *by placefp cousubfp tract bg; run; proc print; by City township notsorted; id tract bg ; var totpop100 sampcount; run cancel; *---We reviewed this listing to confirm that we have the right geos---; *---Here we merge with the full tble data to get table P53 with HH income counts by interval. We use that to try to emulate DEDs "PovState" variable: # of HHs with income <= .9*state median (.9* $37,934 = $34,140 )---; *---the MedianHHInc for Boone co was $37,485 so we are using the larger state value here----; data p52; set sf3.moph(where=(sumlev='090' and county='29019') keep=logrecno geocode p52i: sumlev county); PovState=sum(of p52i2-p52i6); *--sum of HHs with up to 29,999--; *---Interpolate and add a fraction of the HHs in the 7th cell of the table (HHs with 30k-35k). Allocation factor based on portion of interval 30000-34999 that is below the median-based threshold, 34140. ---; PovState + p52i7*(4140/5000); if p52i1 then PctPovState=100*PovState / p52i1; label PovState="Poor HHs (DED)"; *** HHs w income below 90% of State Median"; format PovState comma7.; label PctPovState="% Poor HHs (DED)"; format pct: 5.1; drop p52i: sumlev county; run; proc sort data=p52; by logrecno; run; data temp.&pgm (label="Sample EEZ data at split-BG Level"); merge &pgm(in=ineez) p52(in=inp52); by logrecno; if ineez; *---we kept all the split bg data for the county but here we "pick off" just the needed ones--; _nout+1; drop _: ; if _nout =3 then put _all_; run; proc sort; by county placefp cousubfp tract bg; run; ods listing close; ods html file="/pub/data/temp/&pgm..html" style=analysis; proc print data=_last_ (drop=sumlev logrecno cousubfp placefp ) label ; by county ; id City Township areaname ; var &numvarsprint; title "&pgm.: Selected Data for Proposed EEZ Zone Poverty Area 19, Boone County"; title2 "Source: 2000 Decennial Census, Summary File 3"; title3 "As processed by OSEDA, U. of Missouri"; footnote .h=2 "Poverty HHs (DED) is Est # HHs with Income Below 90% of State Median ($37,934)"; footnote2 .h=1 "From setup in sf32000x/Tools/&pgm..sas, run on &sysdate"; run; *------------And now aggregate the data to get the zone totals-----------------------*; proc sort data=temp.&pgm out=aggin; by sumlev; run; %agg(aggout=aggout, aggby=sumlev,aggvars=&numvars2, means= PctSample MedianHHInc MedianFamInc PCI PctPoor MeanPovRatio PctPoorFamilies PctOccHUSample PctPoorHHs PctPovState PctPoorNonFamHHs, meanwts=TotPop100 TotHHs Families totpop PovUniverse PovUniverse Families OccHUs100 TotHHs TotHHs NonFamHHs, debug=1); data temp.&pgm._totals(label='Zone totals + State and County totals'); length Areaname $40; set aggout; if sumlev='040' then areaname='Missouri'; else if sumlev='050' then areaname='Boone County'; else areaname='Proposed EEZ Totals'; run; proc print data=temp.&pgm._totals(drop=sumlev); id areaname; var &&numvarsprint; title2 "Part 2: Totals"; title3 "Medians Have Been Estimated Using Weighted Averages"; run; filename dlmout "/pub/data/temp/&pgm..csv"; title2 "These and other related variables for these geographic areas have been saved in a CSV file in temp data directory"; %cnvtdlm (setin=temp.&pgm,names=1,genlabs=1); run; ods html close;