x cd /pub/data/irsmig/Tools; %let pgm=ioffe_report; filename pgm "&pgm..sas"; /* *****WE DID NOT RUN THIS (yet). Did some manual searches and sent e-mail to Saul re what we found (7-11-15 circa 10 AM). May note need to run this. */ /*--Per report from Saul Ioffe at Northwetern U we look at input CSV file data for various years to verify (and fix?) problems with duplicate data for states of Texas and Ohio. Here is Saul's report (sent 7-6-15): " The CSVs co9900USi and co9900USo contain two more sets of data for every Texas county (county code 48) at the end of the data set after county code 56 ends. Additionally, the CSVs co0001USi, co0001USo, co0102USi, co0102USo, co0203USi, co0203USo, co0304USo, co0405USi, and co0405USo there is a single repetition of data for all Texas counties (county code 48) at the end of the data set after county code 56 ends. Lastly, in the CSV co0304USi, there is a single repetition of data for every county in both Ohio (county code 39) and Texas (county code 48) at the end of the data set after county code 56 ends. Although the county codes are the same, the data next to them is not (returns, exemptions, aggregate AGI, median AGI). Can you please tell me which set of codes (the originals from within the data or the duplicates afterwards) is appropriate? For co9900USi and co9900USo please let me know which of the two duplicates is appropriate if the duplicates are the correct set of data. " jgb 7-11-15 */ libname irsmig '/pub/data/irsmig'; libname temp '/pub/data/irsmig/temp'; missing d; %macro addlzs(var); &var=translate(right(&var),'0',' '); %mend addlzs; %macro cnvtfls(years,states); *---This macro adapted from the cnvt_irsmig.sas module used to read these data before---; filename csvin "../co&years.USi.csv"; filename csvinout "../co&years.USo.csv"; %if &years lt 1011 %then %do; %let pre1011=1; %let numvars=TotalIncome MedianIncome AvgHHIncome PerCapitaIncome ; %let lennumvars=4; %let lastvarin=PerCapitaIncome; %end; %else %do; %let pre1011=0; %let numvars=Aggr_AGI ; %let lennumvars=5; %let lastvarin=Aggr_AGI ; %end; data temp.usinmig&years(label="Migrations INTO all US counties based on returns for tax years &years"); infile csvin dsd %if &years ge 0708 %then %str( firstobs=2 ); missover %if &years eq 0910 %then %str(termstr=crlf); ; ; retain Years "&years"; label years='Tax years on which moves are based'; length ToAreaName $64 ToCounty FromAreaName $64 FromCounty $5 ToSumlev FromSumLev $3 ToState $2 ToCnty $3 FromState $2 FromCnty $3 FromStab $2 _namein $64 NReturns NExemptions 4 &numvars &lennumvars. ; label NReturns='# Tax Returns' NExemptions='# Exemptions on Tax Returns' ; %if &pre1011 %then %do; label TotalIncome='Aggregate Adjusted Gross Income ($000)' MedianIncome='Median Gross Income per Return' AvgHHIncome='Average Gross Income Per Return' PerCapitaIncome='Averge Gross Income Per Exemption'; *<--maybe a misleading name----; %end; %else %do; label Aggr_AGI='Aggregate Adjusted Gross Income ($000)' AvgAGI='Avg AGI'; %end; %if &pre1011 %then %str( informat Nreturns--&lastvarin comma.; ); %if &years ge %str(0506) %then %do; input ToState -- &lastvarin ; **drop MedianIncome; if ToState ne ' '; %end; %else %do; input ToState -- &lastvarin; %end; if _infile_=:'48,000,97,001,TX' then TXset+1; if _infile_=:'39,000,97,001,OH' then OHset+1; FromAreaName=_namein; drop _: ; if index("&states",ToState); *<=========================================; length ToStab $2; if ToState > '00' then ToStab=put(ToState,$fipstab2.); %addlzs(ToState) %addlzs(ToCnty) %addlzs(FromState) %addlzs(FromCnty) %if &pre1011 %then %do; AvgHHIncome=round(TotalIncome*1000/Nreturns); PerCapitaIncome=round(TotalIncome*1000/NExemptions); format NReturns Nexemptions comma9. TotalIncome comma11. MedianIncome--PerCapitaIncome dollar8.; %end; %else %do; if Nreturns then AvgAGI=Aggr_AGI*1000/Nreturns; format AvgAGI dollar7. Aggr_AGI comma11.; %end; ToCounty=ToState||ToCounty; if tocnty='000' then select(tostate); when('00') do; ToSumLev='010'; ToAreaName='United States'; end; otherwise do; ToAreaName=put(ToState,$state.); ToSumLev='040'; end; end; else do; ToCounty=ToState||ToCnty; ToAreaName=put(ToCounty,$county.); ToSumlev='050'; end; FromCounty=FromState||FromCnty; Select (FromCounty); when('96000') do; FromSumlev='tot'; FromAreaName='Total Mig - US & Foreign'; end; when('97000') do; FromSumlev='tus'; FromAreaName='Total Mig - US'; end; when('97001') do; FromSumlev='tss'; FromAreaName='Total Mig - Same State'; end; when('97003') do; FromSumlev='tds'; FromAreaName='Total Mig - Different State'; end; when('98000') do; FromSumlev='tfo'; FromAreaName='Total Mig - Foreign'; end; when(ToCounty) do; FromSumlev='050'; FromAreaName='Non-Migrants'; end; when('57005') do; FromSumlev='apo'; FromAreaName='Foreign - APO/FPO ZIPS'; end; when('58000') do; FromSumlev='oss'; FromAreaName='Other Flows - Same State'; end; when('59000') do; FromSumLev='ods'; FromAreaName='Other Flows - Different State'; end; when('59001') do; FromSumLev='ore'; FromAreaName='Other Flows - Northeast'; end; when('59003') do; FromSumLev='ore'; FromAreaName='Other Flows - Midwest'; end; when('59005') do; FromSumLev='ore'; FromAreaName='Other Flows - South'; end; when('59007') do; FromSumLev='ore'; FromAreaName='Other Flows - West'; end; when('57009') do; FromSumLev='off'; FromAreaName='Other Flows - Foreign'; end; *--redundant?? - same as 98000---; otherwise do; FromSumLev='050'; if fromstate ne tostate then FromAreaName=trim(FromAreaName)||', '||put(fromstate,$fipstab2.); end; end; if fromsumlev ne '050' then fromstab=' '; ***if _n_ le 10 then do; *** list; ***put / _all_; ***end; run; proc freq data 48,000,97,001,TX,Total Mig - US Same St,365660,735540,14036587,23154