x cd /pub/data/sf32000x/Tools; %let pgm=eezdata_clinton_sample; filename pgm "&pgm..sas"; *---Extract data for selected BGs in Clinton county, MO as used in the "MEEZ DB" document as a sample of an area being evaluated as a potential EEZ zone. We include all the data from their report, plus several others that we thought relevant. The point is to see if this area can be consider in any way a "poor" area. John Blodgett, OSEDA, U of Missouri Extension. Coding begins 6-13-12. Adding code to emnulte DED PovCounty variable. 6-23-12. (Hard-coded to work for Clinton county only). ---*; 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 TotHUs SampHUs TotHUs100 Occupied OccHUs100 PctOccHUSample; %let numvars2=&numvars poorhhs pctpoorhhs povCounty PctPovCounty; %let numvarsprint=TotHHs PoorHHs PctPoorHHs PovCounty PctPovcounty TotPop100 Poor PctPoor MedianHHInc MedianFamInc PCI MeanpovRatio; 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='29049' and sumLev='090')) sf3x.moi(keep=sumlev logrecno state county areaname &numvars where=(sumlev in ('040','050')) ); if sumlev='050' then if county='29049'; if sumlev='090' then do; if (cousubfp in ('02332','15976','39674','40844','58160')) and (placefp in ('58250','99999')); select (tract); when('9602.00') if bg in ('1','2','3'); when('9603.00') if bg in ('1','2','4'); when('9604.00') if bg in ('1','3'); 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='Unicorporated'; else City =put(_arg,$place.); end; *--sumlev 090 processing---; PoorHHs=PoorFamilies + PoorNonFamHHs; if tothhs then PctPoorHHs=100*PoorHHs/TotHHs; label PoorHHs='Poor Households (Census)' PctPoorHHs='% Poor Hseholds'; format pctpoorhhs 5.1; label OccHUs100='Occupied Housing Units (100% Count)'; drop _: ; run; proc sort data=&pgm ; by logrecno; run; *---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 "PovCounty" variable: # of HHs with income <= .9*county median (.9* $41,629 = $37,466 for Clinton)---; data p52; set sf3.moph(where=(sumlev='090' and county='29049') keep=logrecno geocode p52i: sumlev county); PovCounty=sum(of p52i2-p52i7); *--sum of HHs with up to 39,999--; *---Interpolate and add a fraction of the HHs in the 9th cell of the table (HHs with 40k-45k). Allocation factor based on portion of interval 35000-39999 that is below the median-based threshold, 37466. ---; PovCounty + p52i8*(2466/5000); if p52i1 then PctPovCounty=100*PovCounty / p52i1; label PovCounty="Poor HHs (DED)"; *** HHs w income below 90% of County Median"; format PovCounty comma7.; label PctPovCounty="% 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 EEZ Zone Poverty Area Designation"; 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 County Median ($37,466)"; footnote2 .h=1 "From setup in sf32000x/Tools/&pgm..sas"; 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 PctPovCounty, meanwts=TotPop100 TotHHs Families totpop PovUniverse PovUniverse Families OccHUs100 TotHHs TotHHs, 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='Clinton 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;