Derivation
variable: trtplace (table[s]: tb_contact, tb_contactto2007, tbold_contact)
<the exposure contacts are processed separately first:>
reshape wide idcontac famcont contvil contplace trtdate trtdatex trtplace certtbcon wardvisit relship contaccon cough nurseill houseill sleepill contacind contaclong contacdays, i(ident frm_intdate) j(n)
rename * c*
rename (cident cidcontac* cfrm_intdate cnumtbcont) (ident idcontac* intdate numtbcont)
save ${tempfiles}\tbcontacts_wide, replace
<and then merged into the main file:>
merge m:1 ident intdate using ${tempfiles}\tbcontacts_wide, keep(master match) nogen