#!/bin/csh

echo sas NO
sas nber -sysparm NO -log logs/nber-no.log -print lists/nber-no.lst
cd ../taxsim/csv/
echo taxsim
foreach year ( 19 16 13 10 07 04 01 98 95 92 89 )
  echo ${year}
  taxsim32 <txpydata${year}.csv >! results${year}.csv
  st txpydata${year}.csv ../sas/txpydata${year}.sas7bdat  -y
  st txpydata${year}.csv ../dta/txpydata${year}.dta            -y
  st results${year}.csv  ../sas/results${year}.sas7bdat  -y
  st results${year}.csv  ../dta/results${year}.dta            -y
end

cd ../../code
echo sas YES
sas nber -sysparm YES -log ./logs/nber-yes.log -print ./lists/nber-yes.lst

cd ../byhousehold/sas
echo conversions
foreach year ( 19 16 13 10 07 04 01 98 95 92 89 )
  echo ${year}
  st ftax${year}ph.sas7bdat  ../csv/ftax${year}ph.csv    -y
  st ftax${year}ph.sas7bdat  ../dta/ftax${year}ph.dta    -y      
  st ftax${year}phn.sas7bdat ../csv/ftax${year}phn.csv   -y
  st ftax${year}phn.sas7bdat ../dta/ftax${year}phn.dta   -y
  st ftax${year}ptu.sas7bdat ../csv/ftax${year}ptu.csv   -y
  st ftax${year}ptu.sas7bdat ../dta/ftax${year}ptu.dta   -y
end

cd ../../code
echo merge
foreach year ( 19 16 13 10 07 04 01 98 95 92 89 )
  stata -b "do merge ${year}"
  st ../bytaxunit/dta/scftax${year}.dta ../bytaxunit/sas/scftax${year}.sas7bdat -y
  st ../bytaxunit/dta/scftax${year}.dta ../bytaxunit/csv/scftax${year}.csv -y
end

cd ..

wc orig/csv/*.csv byhousehold/csv/*.csv  bytaxunit/csv/*.csv >! record-counts.txt
