x cd /pub/data/irstaxes/Tools; %let pgm=merge_with_acs; filename pgm "&pgm..sas"; *---Merge the irstaxes data set with the latest ACS data to get counts of HHs and AvgHHIncome. We want to see if there are discrepancies where the # returns does not parallel the $# of HHs and/or the AvgHHIncome is out of line with the AvgAGI. jgb, 4/14 . ---*; libname user '/SAS_temp'; %libname(irstaxes); %libname(acs2012); libname temp '/pub/data/temp'; /* <=========================Comment out===================================== proc sort data=irstaxes.uszipsplusnoagi11(keep=zipcode stab TotRtrns Nexempts AvgAGI rename=(zipcode=zcta5) ) out=irstaxes; by zcta5; run; data temp.matched temp.unmatched(keep=zcta5 state stab ZIPname TotHHs HHpop GrpQuarters TotRtrns Nexempts); merge acs2012.uszctas5yr(keep=zcta5 ZIPName state TotPop GrpQuarters TotHHs HHpop PCI in=inacs) irstaxes(in=intaxes); by zcta5; if not (inacs and intaxes) then do; if zcta5='00000' or TotHHs le 20 then delete; output temp.unmatched; delete; end; if HHpop; *---To see where we might have bad data we develop two ACS-based proxy variables that should roughly approximate Exemptions and AvgAGI. *---We want to look at cases where returns vs HHs is off by more than 25 pct and/or AvgAGI and AvgHHInc by more than 35 pct-; if (Nexempts >=1) and (AvgAGI >=1); *--they must not be 0--; Ratio_Exempts=Nexempts/HHpop; EstACSAvgAGI=Nexempts/TotRtrns * PCI; *---just a reasonable guess----; format EstACSAvgAGI dollar9.; Ratio_AGI=AvgAGI/EstACSavgAGI; label EstACSavgAGI='HHPop/TotRtrns * PCI (ACS)'; pctgrpquarters=100*grpQuarters/TotPop; format pctgrpquarters 5.1; if pctgrpquarters le 10 then do; if Ratio_exempts <.6 or Ratio_exempts > 1.4 then FlagExempts=1; else FlagExempts=0; if Ratio_AGI <.6 or Ratio_AGI > 1.4 then FlagAGI=1; else FlagAGI=0; end; label Ratio_exempts='Ratio_exempts: Nexempts/HHpop' Ratio_AGI='Ratio AGI: EstACSAvgAGI/AvgAGI'; label EstACSAvgAGI='EstACSAvgAGI: (nexempts/TotRtrns)*PCI'; format ratio: 6.3; output temp.matched; run; ===========================End commented out================================ */ ods html file ="/pub/data/temp/irstaxes_suspect_cases.html"; title "Comparing ZIP Level 2011 Tax Data (irstaxes) With Data from the ACS (2008-2012) for ZCTAs/ZIP Codes"; footnote h=.1 "Report by the Missouri Census Data Center from setup in irstaxes/Tools/&pgm..sas"; proc print data=temp.unmatched (obs=500); id ZCTA5 State Stab; title2 "Unmatched Geography (ZIPs not present on both Files): First 500 of 4187"; run cancel; proc format; Value flag 1='**Flagged**' 0='ok'; run; proc freq data=temp.matched; table FlagExempts FlagAGI/missing; format Flag: flag.; title2 'Frequency Report: Flags Indicating if Exemptions or AGI Are Off by +/- 40% vs. ACS Proxies'; run; data temp.suspects; set temp.matched(where=(flagExempts or FlagAGI)); run; proc print data=temp.suspects(obs=500) label; title2 "500 (of 2058) ZIP Codes With Suspect Values for Nexempts or AvgAGI Per Comparison with Vintage 2012 ACS"; title3 h=.1 "Cases Flagged When Values of Ratio_Exempts or Ratio_AGI Indicate a 40% or More Difference"; id zcta5 ZIPName; var TotHHs HHpop Nexempts Ratio_Exempts TotRtrns PCI EstACSAvgAGI AvgAGI Ratio_AGI; run; ods html close;