x cd /pub/data/acs/Tools; %let pgm=moe_agg_demo; filename pgm "&pgm..sas"; *----Verify MOE by looking at Poor for Mo PUMAs. Sum the data by PUMA and look at the calc MOE and REL_MOE. Compare the REL_MOEs of the individual PUMAs to what we get for the totals. ------*; title "from acs/Tools/&pgm : Look at Calculated MOE Value"; title2 "Using Sample Data at PUMA Level for WY"; options nodate; %libname(acs2008); libname basetbls '/pub/data/acs2008/basetbls'; libname user '/SAS_temp/user'; /* =======================Begin comment================ data sample; set acs2008.usmcdcprofiles(keep=sumlev PUMA State Areaname geoid poor poor_moe povuniverse pctpoor); ***where state='29' and (sumlev='795' or geoid='04000US29') ; *---Missouri PUMAs and the state total---; where state='56' and (sumlev='795' or geoid='04000US56') ; *---Wyoming PUMAs and the state total---; run; data out; length areaname $20; format areaname $28.; set sample end=last; ReLMOE=100*poor_MOE/poor; if sumlev='040' then do; output; delete; end; sumsquaresmoe + poor_moe**2; sumpoor+poor; output; if last then do; poor_moe=.; RelMOE=.; poor=.; pctpoor=.; Areaname='Calc Sum of PUMAs'; MOE_calc=sqrt(sumsquaresmoe); RelMOECalc=100*MOE_calc/sumpoor; output; end; else delete; put / _all_; drop sumlev puma state geoid ; format Rel: 6.1; run; ods html file="&pgm.WY.html"; proc print d data=out; format areaname $28.; run; ======================End comment================== */ *----run similar step but with the base tables using Wyoming data for ease of checking----; /* =======================Begin comment================ data sampleb; merge basetbls.ustabs17_20(keep=logrecno sumlev PUMA5 State Areaname geoid c17001i: drop=c17001Ii: in=inests) basetbls.ustabs17_20_moes(keep=logrecno geoid c17001m: state in=inmoes); by logrecno; if not (inests and inmoes) then do; put / _all_; abort abend; end; where state='56' and (geoid=:'79500' or geoid='04000US56') ; *---Wyoming PUMAs and the state total---; run; ======================End comment================== */ data outb; length areaname $28; format areaname $28.; set sampleb end=last; poor=c17001i2; poor_moe=c17001m2; poormale=c17001i3; poormale_moe=c17001m3; poorfemale=c17001i7; poorfemale_moe=c17001m7; poorsumacross_moe=sqrt(poormale_moe**2 + poorfemale_moe**2); ReLMOE=100*poor_MOE/poor; if sumlev='040' then do; output; delete; end; sumsquaresmoe + poor_moe**2; sumpoor+poor; sumsquarespoormalemoe + poormale_moe**2; sumpoormale+poormale; sumsquarespoorfemalemoe + poorfemale_moe**2; sumpoorfemale+poorfemale; output; if last then do; poor_moe=.; RelMOE=.; poor=.; pctpoor=.; Areaname='Calc Sum of PUMAs'; poor_moe_calc=sqrt(sumsquaresmoe); RelMOECalc=100*poor_moe_calc/sumpoor; poormale_moe_calc=sqrt(sumsquarespoormalemoe); poorfemale_moe_calc=sqrt(sumsquarespoorfemalemoe); output; end; else delete; put / _all_; drop sumlev puma: state geoid c17: ; format Rel: 6.1; run; ods html file="&pgm.WY.html"; proc print d data=outb; format areaname $28.; run;