***************************Step 2: Read the ZIPcode level CSV files downloaded from the IRS site.*****************; %macro dozips(allno); filename csvinall "/pub/data/irstaxes/&yr.zpallagi.csv"; filename csvinno "/pub/data/irstaxes/&yr.zpnoagi.csv"; *--Had to rename this one. It came down as "allnoagi" options compress=binary; %local setname; %let setname=uszips&allno.agi&yr; data irstaxes.&setname (label="Income Tax data by ZIP Code for tax year &year &allno AGI Groups " ); length State Stab $2 ZIPcode $5 AreaName $40 agi_stub $1 agi $15 SumLev $3; retain TaxYear "&year"; Length N1 MARS1 MARS2 MARS4 PREP N2 NUMDEP A00100 N00200 A00200 N00300 A00300 N00600 A00600 N00650 A00650 N00900 A00900 SCHF N01000 A01000 N01400 A01400 N01700 A01700 N02300 A02300 N02500 A02500 N03300 A03300 N04470 A00101 A04470 N18425 A18425 N18450 A18450 N18500 A18500 N18300 A18300 N19300 A19300 N19700 A19700 N04800 A04800 N07100 A07100 N07220 A07220 N07180 A07180 N07260 A07260 N59660 A59660 N59720 A59720 N11070 A11070 N09600 A09600 N06500 A06500 N10300 A10300 N11901 A11901 N11902 A11902 5; Format A0: A1: A5: dollar12. n1 mars2 prep n2 numdep schf N0: N1: N5: comma9.; infile csvin&allno dsd missover firstobs=2 lrecl=2056; input state stab ZIPCode agi_stub n1--a11902; if zipcode ne '00000' then do; SumLev='871'; AreaName=put(ZIPcode,$zipname.); end; else do; SumLev='040'; *--Standard code indicating a state level summary--; Areaname=put(state,$state.); end; agi=put(agi_stub,$agi.); Label ZIPcode="5-digit ZIP Code " agi_stub="Size of Adj Gross Income" agi="Adj Gross Income Catgry" SumLev="Geo Summary Lvl Code" N1="# Returns " MARS1="# Single Returns" MARS2="# Joint Returns " MARS4="# Head of HH Returns" PREP="# Returns w Paid Preparer Signature" N2="# exemptions [3] " NUMDEP="# dependents " A00100="AGI (Adj Gross Income" N00200="Returns w Salaries & Wages " A00200="Salaries & Wages Amt " N00300="Returns w Taxable Interest " A00300="Taxable Interest Amt " N00600="Returns w Ordinary Dividends " A00600="Ordinary Dividends Amt " N00650="Returns w Qualified Dividends " A00650="Qualified Dividends Amt " N00900="Returns w Business or Professional Net Income (less loss)" A00900="Bus or Prof Net Income Amt " SCHF="# Farm Returns " N01000="Returns w Capital Gain (less loss)" A01000="Capital Gain (less loss) Amt " N01400="Returns w IRA Distributions " A01400="IRA Distributions Amt " N01700="Returns w Taxable Pensions & Annuities " A01700="Taxable Pensions & Annuities Amt " N02300="Returns w Unemployment Compensation " A02300="Unemployment Compensation Amt " N02500="Returns w Taxable Social Security benefits " A02500="Taxable Social Security benefits amt " N03300="Returns w Self-employment Retirement Plans " A03300="Self-employment Retirement Plans Amt " N04470="Returns w Itemized Deductions" A00101="AGI for itemized returns Amt" A04470="Itemized Deductions Amt" N18425="Returns w State & Local Income Tax" A18425="State & Local Income Taxes Amt " N18450="Returns w State & Local General Sales Tax" A18450="State & Local General Sales Tax Amt " N18500="Returns w Real Estate Taxes " A18500="Real Estates Taxes Amt " N18300="Returns w Taxes Paid" A18300="Taxes Paid Amt " ; LABEL N19300="Returns w Mortgage Interest Paid" A19300="Mortgage Interest Paid Amt" N19700="Returns w Contributions" A19700="Contributions Amt " N04800="Returns w Taxable Income" A04800="Taxable Income Amt" N07100="Returns w Total Tax Credits" A07100="Total Tax Credits Amt" N07220="Returns w Child tax credit" A07220="Child Tax Credit Amt" N07180="Returns w Child & Dependent Care Credit" A07180="Child & Dependent Care Credit Amt" N07260="Returns w Additional Child Tax Credit" A07260="Additional Child Tax Credit Amt" N59660="Returns w Earned Income Credit" A59660="Earned Income Credit Amt [6]" N59720="Returns w Excess Earned Income Credit" A59720="Excess Earned Income Credit (refundable) Amt [7]" N11070="Returns with additional child tax credit " A11070="Additional child tax credit Amt" N09600="Returns with alternative minimum tax " A09600="Alternative Minimum Tax Amt " N06500="Returns with income tax " A06500="Income Tax Amt [8] " N10300="Returns with tax liability " A10300="Total Tax Liability [9] " N11901="Returns with tax due at time of filing " A11901="Tax Due at Time of Filing Amt [10] " N11902="Returns with overpayments refunded " A11902="Overpayments Refunded Amt [11]" ; /* ==============================Footnotes copied from the tech doc for 2012 release====================================== G. Endnotes: [1] For complete individual income tax tabulations at the State level, see the historic table posted to Tax Stats at http://www.irs.gov/uac/SOI-Tax-Stats---Historic-Table-2. [2] Does not include returns with adjusted gross deficit. [3] “Qualified dividends” are ordinary dividends received in tax years beginning after 2002 that meet certain conditions and receive preferential tax rates. The maximum qualified dividends tax rate is 15%. [4] Includes the Alaskan permanent fund, reported by residents of Alaska on Forms 1040A and 1040EZs. This fund only applies to statistics in the totals, and the state of Alaska. [5] Earned income credit includes both the refundable and non-refundable portions. The non-refundable portion could reduce income tax and certain related taxes to zero. The earned income credit amounts in excess of total tax liability, or amounts when there was no tax liability at all, were refundable. See footnote 6 below for explanation of the refundable portion of the earned income credit. [6] The refundable portion of the earned income credit equals total income tax minus the earned income credit. If the result is negative, this amount is considered the refundable portion. No other refundable credits were taken into account for this calculation. [7] Income tax reflects the amount reported on Form 1040 line 55. It also includes data from Form 1040A and 1040EZ filers. [8] “Total tax liability” differs from “Income tax”, in that “Total tax liability” includes the taxes from recapture of certain prior-year credits, tax applicable to individual retirement arrangements (IRA's), social security taxes on self-employment income and on certain tip income, advanced earned income payments, household employment taxes, and certain other taxes listed in the Form 1040 instructions. [9] Reflects payments to or withholdings made to "Total tax liability". This is the amount the tax filer owes when the income tax return is filed. [10] The amount of overpayments the tax filer requested to have refunded. ===================================End Footnotes========================================================================= */; run; options ps=90 ls=160; title2 "Data Per irstaxes.&setname Data Set"; proc print data=irstaxes.&setname(obs=50); title3 "First 50"; by taxyear state stab; id zipcode areaname agi; run; proc means data =irstaxes.&setname n mean sum max; title3 "proc means"; class sumlev agi; run; proc datasets library=irstaxes; modify &setname ; index create state; quit; *---decided not to create mo subset views of these sets---; %mend dozips; %dozips(all) ; %dozips(no); *---------------------end step 2---------------*;