x cd /pub/data/sf32000x/Tools; %let pgm=eezdata_boone2k_tomap; filename pgm "&pgm..sas"; *---Extract data for all BGs in Boone county, MO with data items to map for the EEZ board. Uses 090 geos. John Blodgett, OSEDA, U of Missouri Extension. ---*; 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 Esriid $24 County $5 City $18 Township $18 Tract $7 BG $1 ; set sf3x.moh(keep=sumlev logrecno geocode esriid state county cousubfp placefp tract bg &numvars where=(county='29019' and sumLev='090')) sf3x.moi(keep=sumlev logrecno esriid state county areaname &numvars where=(sumlev in ('040','050')) ); if sumlev='050' then if county='29019'; areaname="Tract "||tract||", BG "||bg; if sumlev='090' then do; esriid=compress(geocode,'-.'); 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 table 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 for all of Boone Co"); 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; /* ========================begin comment==================================== 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; ==========================end comment====================================== */ filename dlmout "/pub/data/temp/&pgm..csv"; %cnvtdlm (setin=temp.&pgm,names=1,genlabs=1); run; ods html close;