libname in 'C:\Documents and Settings\Laura\My Documents\Cross-State Policy\CPS data\Data\Raw' ; libname out 'C:\Documents and Settings\Laura\My Documents\Cross-State Policy\CPS data\TAXSIM' ; options nofmterr; %macro CPS1; * do the 1992-99 files first; %do i=2 %to 9; data temp9&i; set in.mar9&i; * variables created below are those that need combining to be included as TAXSIM requires; year=199&i; **STATE recode; if state=63 then STATER=1; if state=94 then STATER=2; if state=86 then STATER=3; if state=71 then STATER=4; if state=93 then STATER=5; if state=84 then STATER=6; if state=16 then STATER=7; if state=51 then STATER=8; if state=53 then STATER=9; if state=59 then STATER=10; if state=58 then STATER=11; if state=95 then STATER=12; if state=82 then STATER=13; if state=33 then STATER=14; if state=32 then STATER=15; if state=42 then STATER=16; if state=47 then STATER=17; if state=61 then STATER=18; if state=72 then STATER=19; if state=11 then STATER=20; if state=52 then STATER=21; if state=14 then STATER=22; if state=34 then STATER=23; if state=41 then STATER=24; if state=64 then STATER=25; if state=43 then STATER=26; if state=81 then STATER=27; if state=46 then STATER=28; if state=88 then STATER=29; if state=12 then STATER=30; if state=22 then STATER=31; if state=85 then STATER=32; if state=21 then STATER=33; if state=56 then STATER=34; if state=44 then STATER=35; if state=31 then STATER=36; if state=73 then STATER=37; if state=92 then STATER=38; if state=23 then STATER=39; if state=15 then STATER=40; if state=57 then STATER=41; if state=45 then STATER=42; if state=62 then STATER=43; if state=74 then STATER=44; if state=87 then STATER=45; if state=13 then STATER=46; if state=54 then STATER=47; if state=91 then STATER=48; if state=55 then STATER=49; if state=35 then STATER=50; if state=83 then STATER=51; * create TAXSIM status variable; if FLSTAT ne 6; * drop those who are nonfilers (later give them zeroes for tax vars); if FLSTAT=5 then STATUS=1; * single; else if 1 le FLSTAT le 3 then STATUS=2; * joint; else if FLSTAT=4 then STATUS=3; * head of household; * create TAXSIM age gt 65 variable; if FLSTAT=2 then AGE65=1; * close to #65 year olds because this is # filers of that age; else if FLSTAT=3 then AGE65=2; else AGE65=0; RENT=0; *because we have no rent indicator; ITEMS=sum(FEDRET,FICA); *includes just payroll taxes because we have no other itemized expenses; CCE=0; *because we have no child care expenses; NDEP=_CHILD18; MORT=0; SHORT=0; LONG=0; **** create head and spouse earnings variables and other taxable & nontaxable income variables; ** here is what we decided to do: heads get their wages spouses get their wages + the kids wages other family members who file singly get computed separately (as HEADWS var for TAXSIM) non family members who file get computed separately ; ** this means that the resulting TAXSIM output will get summed up by family ** any nonfilers get zero for all tax variables; if FAMREL=1 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * HH heads; else if FAMREL=4 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * other relatives (filing singly); else if FAMREL=0 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * non relatives (single-person family); else if FAMREL=2 then SPOUSWS=sum(_incwag,INCWG1,_incse,INCSE1); else if FAMREL=3 then KIDERN=sum(_incwag,INCWG1,_incse,INCSE1); OTHERT=sum(FMIRNT,FMIINT,FMIALM,FMIOTH,KIDERN); OTHERNT=sum(FMIPA,FMICH2,FMICP2,FMISEC,FMIDIS,FMIVET,FMISRV); proc sort data=temp9&i; by hhseq fampos; run; data rollup9&i; set temp9&i; by hhseq fampos; retain HEAD SPOUSE fstatus; if first.fampos then do; HEAD=0; SPOUSE=0; fstatus=status; * this keeps the first record filing status; end; HEAD=sum(HEAD,HEADWS); SPOUSE=sum(SPOUSE,SPOUSWS,KIDERN); * this sums up their records to the family; if last.fampos then output; run; data all9&i; merge rollup9&i(keep=hhseq fampos fstatus head spouse) temp9&i; by hhseq fampos; if 2 ne FAMREL ne 3; * drop kid and spouse records because they are accounted for in head record for TAXSIM; if head lt 0 then head=0; * TAXSIM wont take any income <0; if spouse lt 0 then spouse=0; * TAXSIM wont take any income <0; proc sort data=all9&i; by hhseq fampos; * the KEEP statement below lists the variables (and order) needed for TAXSIM; data out.TAXSIM9&i(KEEP=RECNUM YEAR STATER fSTATUS _CHILD18 AGE65 HEAD SPOUSE FMIDV2 OTHERT FMIRET FMISS OTHERNT RENT PRPTAX ITEMS CCE FMIUC NDEP MORT SHORT LONG); retain RECNUM YEAR STATER fSTATUS _CHILD18 AGE65 HEAD SPOUSE FMIDV2 OTHERT FMIRET FMISS OTHERNT RENT PRPTAX ITEMS CCE FMIUC NDEP MORT SHORT LONG; * reorder for TAXSIM; set all9&i; by hhseq fampos; if stater ne 9; * drop DC; RUN; proc means data=out.TAXSIM9&i; * see if it did what was expected; title 'Test means 199'&i ; run; proc print data=out.TAXSIM9&i (obs=40) noobs; * see if it did what was expected; title 'Test print 199'&i ; run; * output data in text format for submission to TAXSIM; * these are the PROC EXPORT details from SAS, which, by default, output variable names in the first row, which we do not want for TAXSIM, so I am modifying the specific code (dont ask me what some of this means); data _null_; set OUT.TAXSIM9&i end=EFIEOD; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ %let _EFIREC_ = 0; /* clear export record count macro variable */ file "C:\Documents and Settings\Laura\My Documents\Cross-State Policy\CPS data\taxsim\Temp9&i..txt" delimiter=' ' DSD DROPOVER lrecl=32767; format RECNUM best12. ; * this best12 format was the default for SAS; format YEAR best12. ; format STATER best12. ; format fSTATUS best12. ; format _CHILD18 best12. ; format AGE65 best12. ; format HEAD best12. ; format SPOUSE best12. ; format FMIDV2 best12. ; format OTHERT best12. ; format FMIRET best12. ; format FMISS best12. ; format OTHERNT best12. ; format RENT best12. ; format PRPTAX best12. ; format ITEMS best12. ; format CCE best12. ; format FMIUC best12. ; format NDEP best12. ; format MORT best12. ; format SHORT best12. ; format LONG best12. ; do; EFIOUT + 1; put RECNUM @; put YEAR @; put STATER @; put fSTATUS @; put _CHILD18 @; put AGE65 @; put HEAD @; put SPOUSE @; put FMIDV2 @; put OTHERT @; put FMIRET @; put FMISS @; put OTHERNT @; put RENT @; put PRPTAX @; put ITEMS @; put CCE @; put FMIUC @; put NDEP @; put MORT @; put SHORT @; put LONG ; end; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ if EFIEOD then call symputx('_EFIREC_',EFIOUT); run; %end; %mend; %CPS1; run; %macro CPS2; * now do the 2000-05 files ; %do i=0 %to 5; data temp0&i; set in.mar0&i; * variables created below are those that need combining to be included as TAXSIM requires; year=200&i; **STATE recode; if state=63 then STATER=1; if state=94 then STATER=2; if state=86 then STATER=3; if state=71 then STATER=4; if state=93 then STATER=5; if state=84 then STATER=6; if state=16 then STATER=7; if state=51 then STATER=8; if state=53 then STATER=9; if state=59 then STATER=10; if state=58 then STATER=11; if state=95 then STATER=12; if state=82 then STATER=13; if state=33 then STATER=14; if state=32 then STATER=15; if state=42 then STATER=16; if state=47 then STATER=17; if state=61 then STATER=18; if state=72 then STATER=19; if state=11 then STATER=20; if state=52 then STATER=21; if state=14 then STATER=22; if state=34 then STATER=23; if state=41 then STATER=24; if state=64 then STATER=25; if state=43 then STATER=26; if state=81 then STATER=27; if state=46 then STATER=28; if state=88 then STATER=29; if state=12 then STATER=30; if state=22 then STATER=31; if state=85 then STATER=32; if state=21 then STATER=33; if state=56 then STATER=34; if state=44 then STATER=35; if state=31 then STATER=36; if state=73 then STATER=37; if state=92 then STATER=38; if state=23 then STATER=39; if state=15 then STATER=40; if state=57 then STATER=41; if state=45 then STATER=42; if state=62 then STATER=43; if state=74 then STATER=44; if state=87 then STATER=45; if state=13 then STATER=46; if state=54 then STATER=47; if state=91 then STATER=48; if state=55 then STATER=49; if state=35 then STATER=50; if state=83 then STATER=51; * create TAXSIM status variable; if FLSTAT ne 6; * drop those who are nonfilers (later give them zeroes for tax vars); if FLSTAT=5 then STATUS=1; * single; else if 1 le FLSTAT le 3 then STATUS=2; * joint; else if FLSTAT=4 then STATUS=3; * head of household; * create TAXSIM age gt 65 variable; if FLSTAT=2 then AGE65=1; * close to #65 year olds because this is # filers of that age; else if FLSTAT=3 then AGE65=2; else AGE65=0; RENT=0; *because we have no rent indicator; ITEMS=sum(FEDRET,FICA); *includes just payroll taxes because we have no other itemized expenses; CCE=0; *because we have no child care expenses; NDEP=_CHILD18; MORT=0; SHORT=0; LONG=0; **** create head and spouse earnings variables and other taxable & nontaxable income variables; ** here is what we decided to do: heads get their wages spouses get their wages + the kids wages other family members who file singly get computed separately (as HEADWS var for TAXSIM) non family members who file get computed separately ; ** this means that the resulting TAXSIM output will get summed up by family ** any nonfilers get zero for all tax variables; if FAMREL=1 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * HH heads; else if FAMREL=4 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * other relatives (filing singly); else if FAMREL=0 then HEADWS=sum(_incwag,INCWG1,_incse,INCSE1); * non relatives (single-person family); else if FAMREL=2 then SPOUSWS=sum(_incwag,INCWG1,_incse,INCSE1); else if FAMREL=3 then KIDERN=sum(_incwag,INCWG1,_incse,INCSE1); OTHERT=sum(FMIRNT,FMIINT,FMIALM,FMIOTH,KIDERN); OTHERNT=sum(FMIPA,FMICH2,FMICP2,FMISEC,FMIDIS,FMIVET,FMISRV); proc sort data=temp0&i; by hhseq fampos; run; data rollup0&i; set temp0&i; by hhseq fampos; retain HEAD SPOUSE fstatus; if first.fampos then do; HEAD=0; SPOUSE=0; fstatus=status; * this keeps the first records filing status; end; HEAD=sum(HEAD,HEADWS); SPOUSE=sum(SPOUSE,SPOUSWS,KIDERN); * this sums up their records to the family; if last.fampos then output; run; data all0&i; merge rollup0&i(keep=hhseq fampos fstatus head spouse) temp0&i; by hhseq fampos; if 2 ne FAMREL ne 3; * drop kid and spouse records because they are accounted for in head record for TAXSIM; if head lt 0 then head=0; * TAXSIM wont take any income <0; if spouse lt 0 then spouse=0; * TAXSIM wont take any income <0; proc sort data=all0&i; by hhseq fampos; * the KEEP statement below lists the variables (and order) needed for TAXSIM; data out.TAXSIM0&i(KEEP=RECNUM YEAR STATER fSTATUS _CHILD18 AGE65 HEAD SPOUSE FMIDV2 OTHERT FMIRET FMISS OTHERNT RENT PRPTAX ITEMS CCE FMIUC NDEP MORT SHORT LONG); retain RECNUM YEAR STATER fSTATUS _CHILD18 AGE65 HEAD SPOUSE FMIDV2 OTHERT FMIRET FMISS OTHERNT RENT PRPTAX ITEMS CCE FMIUC NDEP MORT SHORT LONG; * reorder for TAXSIM; set all0&i; by hhseq fampos; if stater ne 9; * drop DC; RUN; proc means data=out.TAXSIM0&i; * see if it did what was expected; title 'Test means 200'&i ; run; proc print data=out.TAXSIM0&i (obs=40) noobs; * see if it did what was expected; title 'Test print 200'&i ; run; data _null_; set OUT.TAXSIM0&i end=EFIEOD; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ %let _EFIREC_ = 0; /* clear export record count macro variable */ file "C:\Documents and Settings\Laura\My Documents\Cross-State Policy\CPS data\taxsim\Temp0&i..txt" delimiter=' ' DSD DROPOVER lrecl=32767; format RECNUM best12. ; * this best12 format was the default for SAS; format YEAR best12. ; format STATER best12. ; format fSTATUS best12. ; format _CHILD18 best12. ; format AGE65 best12. ; format HEAD best12. ; format SPOUSE best12. ; format FMIDV2 best12. ; format OTHERT best12. ; format FMIRET best12. ; format FMISS best12. ; format OTHERNT best12. ; format RENT best12. ; format PRPTAX best12. ; format ITEMS best12. ; format CCE best12. ; format FMIUC best12. ; format NDEP best12. ; format MORT best12. ; format SHORT best12. ; format LONG best12. ; do; EFIOUT + 1; put RECNUM @; put YEAR @; put STATER @; put fSTATUS @; put _CHILD18 @; put AGE65 @; put HEAD @; put SPOUSE @; put FMIDV2 @; put OTHERT @; put FMIRET @; put FMISS @; put OTHERNT @; put RENT @; put PRPTAX @; put ITEMS @; put CCE @; put FMIUC @; put NDEP @; put MORT @; put SHORT @; put LONG ; end; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ if EFIEOD then call symputx('_EFIREC_',EFIOUT); run; %end; %mend; %CPS2; run;