x cd /pub/data/irstaxes/Tools; %let pgm=create_irstaxes_plus; filename pgm "&pgm..sas"; *---The basic raw data in the files / data sets distributed by the IRS do not contain any variables that seem to us suitable for really getting a handle on the information they contain. Aggregate dollar values and counts of tax returns are only valuable when combined to look at averages, and then compared to some norm such as the corresponding state value for a sub-state area. So this setup creates a series of custom "plus" data sets that parallel the original data sets but contain mostly means and percentage values derived from the raw return counts and dollar amounts. We also use mnemonic names in this set: for example, N00200 is now Nwages and A00200 is now called AmtWages . The new variable AvgWages is calculated by dividing A00200 by N00200 and multiplying by 1000 (since the aggregate amt is in thousands). PctWages is also new and is calculated as the percentage of all returns that reported wages, i.e. 100*N00200/N1 . The new variable AvgTRWages is the average value of Wages if we use Total Returns as the denominator, i.e. it is the average value of wages on all returns, even if they did not report any wages. ***4-10-14: We are alerted to problem with these data. Cases occurred where the Amt and N values were (apparently) 0 but the corresponding Avg variable was showing $1,000. Turns out the apparent 0 values were actually .0001 values, which is what IRS assigns to values that would see better set to 0. See footnote 2 in the tech doc. In this conversion run we shall convert all the .0001 values to 0s and this should make the corresponding Avg variables have missing values. John Blodgett, OSEDA, U of Missouri Columbia. Under contract with the Missouri Census Data Center. Feb. 26, 2014. ************* Rerun 4/30 8:15 to redo the 2 ZIP sets (only -for now!) after fixing problems with them. ************* Rerunning with countys same day. Our compare run showed no need to since county files had not changed. But we had already deleted all the uscnty* files from the directory so need to put them back. ---*; %let year=2011; *---Income tax year---; %let yr=%substr(&year,3,2); libname irstaxes '/pub/data/irstaxes'; *--This is where we create the data set(s)---; options compress=binary; options mprint; %macro dogeos(geo,allno); %*let allno=no; %local setname; %let setname=us&geo.s&allno.agi&yr; data irstaxes.us&geo.splus&allno.agi&yr (label="Enhanced &year Income Tax data by &geo, &allno AGI Grps" ); set irstaxes.&setname; Rename N1=TotRtrns N2=Nexempts MARS2=MJRtrns PREP=PrepRtrns A00100=AmtAGI; if N1 then do; AvgAGI=round(A00100*1000/N1); PctJoint=100*MARS2/N1; PctPrep=100*PREP/N1; AvgExempts=N2/N1; AvgDepends=NUMDEP/N1; Label AvgAGI='Average AGI ($)' A00100='Total AGI ($000)' PctJoint='% Married Couple Joint Returns' PctPrep='% w Paid Preparer Sig' AvgExempts='Avg # Exemptions' AvgDepends='Avg # Dependents'; end; %macro newvar(sfx,name,what); %let lsfx=%length(&sfx); %if &lsfx=3 %then %let sfx=00&sfx; %else %if &lsfx=4 %then %let sfx=0&sfx; if round(n&sfx,.0001)=.0001 then do; n&sfx=0; A&sfx=0; end; N&name=n&sfx; Amt&name=A&sfx; %local pctname; %if %substr(&name,1,4)=%str(With) %then %let pctname=Pct&name; %else %let pctname=PctWith&name; if N1 then &pctname = 100*N&name/N1; if N&name then Avg&name=Amt&name*1000/N&name; if N1 then AvgTR&name=Amt&name*1000/N1; Label N&name="N with &what" Amt&name="Amt &what ($000)"; Label Avg&name="Avg &what when > 0" avgtr&name="Avg &what all returns" &pctname="% reporting &what"; %mend newvar; drop n00200--a11902; %newvar(200,wages,%str(Salaries & Wages)) %newvar(300,TxblInt,Taxable Interst) %newvar(600,OrdDiv,Ordinary Dividends) %newvar(650,QualDv,Qualified Dividends) %newvar(900,BusProInc,Business of Prof Net Income) NFarm=schf; label NFarm='# Farm Returns'; if N1 then PctFarm=100*Nfarm/N1; label PctFarm='% Farm Returns'; %newvar(1000,CapGain,%str(Capital Gain (less loss))) %newvar(1400,IRAdists,IRA Distributions) %newvar(1700,PensionsAnn,Pensions and Annuities) %newvar(2300,UnempComp,Unemployment Compensation) %newvar(2500,TaxableSS,Taxable Social Security Benefits) %newvar(3300,SelfEmpRet,Self Employment Ret Plans) %newvar(4470,Itemized,Itemized Deductions) %newvar(18425,LocalIncTaxes,%str(St & Local Income Tax)) %newvar(18450,LocalSalesTaxes,%str(St & Local Sales Tax)) %newvar(18500,RealEstTaxes,Real Estate Taxes) %newvar(18300,TaxesPaid,Taxes Paid) %newvar(19300,MortInt,Mortgage Int Paid) %newvar(19700,Contribs,Contributions) %newvar(04800,TaxableIncome,Taxable Income) %newvar(7100,TaxCreds,Total Tax Credits) %newvar(7220,ChildCreds,Child Tax Credits) %newvar(7180,ChDepCareCreds,%str(Child & Dependent Care Credits)) %newvar(7260,AddChildCreds,Additional Child Tax Credits) %newvar(59660,EarnedIncCreds,Earned Income Credits) %newvar(59720,ExcEarnedIncCreds,Excess Earned Income Credits) %newvar(9600,AltMinTax,Alternate Minimum Tax) %newvar(6500,IncomeTax,Income Tax) %newvar(10300,Liability,Tax Liability[10]) %newvar(11901,TaxDue,Tax Due at Filing[11]) %newvar(11902,Refund,Refund Due[12]) format Pct: 5.1 Avg: dollar9. Amt: dollar11. N: comma9. ; format AvgExempts AvgDepends 4.1; run; %mend dogeos; %dogeos(cnty,no) ; %dogeos(cnty,all) ; %dogeos(zip,no) ; %dogeos(zip,all) ;