x cd /pub/data/pl942010/Tools; %let pgm=compare_pl94_with_estimates; filename pgm "&pgm..sas"; *---We compate some of the basic pl94 counts with the corresponding values from the fscpe post-censal estimates. We do a little extrapolation from the July 2009 figures to April 2010 by assuming a constant delete as in the previous year (2008-2009). jgb, 2/11 ----; *-----We want estimates from July of 08 and 09 for these categories: Total, White alone/non-ispanic, Hispanic, Age0_17 . The first 3 we get from casrh but the age variable we get from the custom nchsbri summaries because they have the required age cohort detail. ----; %let state=29; %let stab=mo; libname popests '/pub/data/popests'; libname nchsbri '/pub/data/popests/nchsbri' access=readonly; libname pl942010 '/pub/data/pl942010'; libname estcomps '/pub/data/pl942010/estcomps'; libname pl94 (pl942010); libname user '/SAS_temp/userb'; %macro doit(state,stab); *---We will do this in open code for Mo but use the state/stab parms to make it easy to modify and run for any state---; data casrh; set popests.&stab.casrh09; where SumType in ('t','h','rh'); ***where also county='29001'; by county; retain; if first.county then do; pop2k=0; totpop08=0; totpop09=0; hisp08=0; hisp09=0; whitenh108=0; whitenh109=0; end; if sumtype='t' then do; pop2k=estbase; totpop08=popest_2008; totpop09=popest_2009; end; if sumtype='h' and hispanic='2' then do; hisp08=popest_2008; hisp09=popest_2009; end; if sumtype='rh' and race='01' and hispanic='1' then do; whitenh108=popest_2008; whitenh109=popest_2009; end; if last.county then do; totpop_est=totpop09 + round( .75*(totpop09-totpop08)); hisppop_est=hisp09 + round( .75*(hisp09-hisp08)); whitenh1_est=whitenh109 + round( .75*(whitenh109-whitenh108)); output; end; keep county pop2k totpop_est--whitenh1_est; run; data nchsbri2; set nchsbri.&stab.nchsbridged20xx_sumry; where sumlev='050' and ('00' <= age <='17') and year in ('2008','2009'); *** where also county='29001'; keep county total year age; run; proc sort; by county year; run; data nchsbri; set nchsbri2; by county year; retain; if first.county then do; Under1808=0; under1809=0; end; if first.year then under18=0; under18+total; if last.year then do; if year='2008' then under1808=under18; else do; under1809=under18; under18_est=under1809 + round ( .75*(under1809-under1808)); output; _nout+1; ***if _nout le 5 then put / _all_; end; end; keep county under18_est; run; data hus; set popests.ushuest2009; where state="&state" and sumlev='050'; tothus_est=huest_2009 + round( .75* (huest_2009 - huest_2008)); keep county tothus_est; run; *---Now merge the latest estimates with the actual census counts in pl94 so that we can examine how good/bad the estimates were. This is important because of the critical role played by the estimates in weighting the ACS data. ----; data estcomps.&stab.estimatescomparison(label="Comparison of 4 Key Items from Estimates vs. PL94 Counts"); merge pl94.&stab.sums(in=insums where=(sumlev='050') keep=sumlev county areaname totpop hisppop over18 whitenh1 tothus) casrh(in=inests1) nchsbri(in=inests2) hus(in=inhus); by county; if not (insums and inests1 and inests2 and inhus) then do; _nmiss+1; if _nmiss gt 10 then abort abend; put "Data missing for " county areaname +2 insums= inests1= inests2= inhus= ' *****'; end; Under18=totpop-over18; drop over18; array pl94(5) totpop under18 hisppop whitenh1 tothus; array est (5) totpop_est under18_est hisppop_est whitenh1_est tothus_est; array diff(5) diff_totpop diff_under18 diff_hisppop diff_whitenh1 diff_tothus; array pctdiff(5) pctdiff_totpop pctdiff_under18 pctdiff_hisppop pctdiff_whitenh1 pctdiff_tothus; do _i=1 to 5; diff(_i)=est(_i)-pl94(_i); if pl94(_i) then pctdiff(_i)=100*diff(_i)/pl94(_i); format pct: 6.1; end; drop _:; label diff_totpop='Est - Counted Total Pop' pctdiff_totpop='% Diff Est vs Counted Total Pop'; format county $5.; label county='County'; run; ods html file="/pub/reports/pl94estcomps/&statenm..html" style=sasweb; ***ods pdf file="../&pgm..pdf" style=sasweb notoc; *<--Not using this because cannot fit it on a page--; options nodate orientation=landscape; title "Comparison Report: 2010 Census vs. Official Post-Censal County Estimates"; title2 "For the State of &statenm"; footnote h=1 "Report Generated by the Missouri Census Data Center from compare_pl94_with_estimates.sas"; footnote2 h=1 "2010 Estimate Derived by Extrapolation Using 2008 and 2009 July Estimate"; footnote3 h=1 "Color Scheme: Dark Red=Estimate Way Too High, Dark Green=Estimate Way Too Low (More than 8%)"; footnote4 h=1 "Color Scheme: Light Red=Somewhat High, Light Green=Somewhat Low (4 to 8%)"; *---define the "traffic lighting" format to control color based on value of percent difference---; proc format; value bgcol low -< -8='#008800' -8 -< -4='#ccffcc' -4 - 4='white' 4 -< 8='#ffcccc' 8-high='#880000'; value fgcol -8 - 8='black' other='white'; run; proc report data= estcomps.&stab.estimatescomparison ; columns ('-Geography-' areaname county ) ('-Total Population-' totpop totpop_est diff_totpop pctdiff_totpop) ('-Children (Under 18)-' under18 under18_est diff_under18 pctdiff_under18) ('-Hispanic Population-' hisppop hisppop_est diff_hisppop pctdiff_hisppop) ('-White/Non-Hispanic Pop)-' whitenh1 whitenh1_est diff_whitenh1 pctdiff_whitenh1) ('-Total Housing Units-' tothus tothus_est diff_tothus pctdiff_tothus) ; define areaname / style={backgroundcolor=royalblue color=white} format=$char32. 'County'; define county / 'FIPS' spacing=0 style={backgroundcolor=royalblue color=white} format=$5. width=5; define totpop/display spacing=1 format=comma10. 'Census/Count'; define totpop_est/display spacing=1 format=comma9. 'Estmt'; define diff_totpop/display spacing=1 format=comma9. 'Diff' ; define pctdiff_totpop/style={background=bgcol. foreground=fgcol.} display spacing=1 format=5.1 '% Diff' ; define under18/display spacing=1 format=comma8. 'Census/Count'; define under18_est/display spacing=1 format=comma8. 'Estmt'; define diff_under18/display spacing=1 format=comma. 'Diff' ; define pctdiff_under18/ style={background=bgcol. foreground=fgcol.} display spacing=1 format=5.1 '% Diff' ; define hisppop/display spacing=1 format=comma10. 'Census/Count'; define hisppop_est/display spacing=1 format=comma9. 'Estmt'; define diff_hisppop/display spacing=1 format=comma. 'Diff' ; define pctdiff_hisppop/style={background=bgcol. foreground=fgcol.} display spacing=1 format=5.1 '% Diff' ; define whitenh1/display spacing=1 format=comma10. 'Census/Count'; define whitenh1_est/display spacing=1 format=comma9. 'Estmt'; define diff_whitenh1/display spacing=1 format=comma. 'Diff' ; define pctdiff_whitenh1/ style={background=bgcol. foreground=fgcol.} display spacing=1 format=5.1 '% Diff' ; define tothus/display spacing=1 format=comma10. 'Census/Count'; define tothus_est/display spacing=1 format=comma9. 'Estmt'; define diff_tothus/display spacing=1 format=comma. 'Diff' ; define pctdiff_tothus/style={background=bgcol. foreground=fgcol.} display spacing=1 format=5.1 '% Diff' ; run; ods html close; %mend doit; /* ========================begin comment==================================== %dostates(17 29,names=1); %dostates(06,names=1); %dostates(04 09 16 39 42 55,names=1); %dostates(01 05 08 10 15 18 19 20 22 24 28 31 34 37 40 41 46 48 49 50 51 53 56,names=1); %dostates(02 10 11 13 21 23 25 26 27 30 33 35 36 38 44 45 47 54 72,names=1) ; *--3-25-11 (final states)--; ==========================end comment====================================== */ %dostates(12,names=1);