/** \file Add random variables to host dataset. \date Mar 2008 **4/2015 Change host data to 2010 */ include common.do local expand : env EXPAND local bsamp : env BREP * Using parameter estimates from simul2004, but now applying them to the unrestricted all2004_pop_adjusted.dta file to restore our sample size when using the unrestricted data. if missing("`bsamp'") { use "$outdata/all2010_pop_adjusted.dta",replace } else { use "$outdata/input_rep`bsamp'/all2010_pop_adjusted.dta", clear } * Merge on the jointly imputed values merge 1:1 hhidpn wave using $outdata/imputed_ssa_ret_2010.dta drop _merge merge 1:1 hhidpn wave using $outdata/imputed_ssa_notret_2010.dta drop _merge foreach var in raime rq fraime frq { egen `var' = rowmax(`var'_ret `var'_notret) } * Assume alzhe = 0, cogstate is normal, and selfmem are good if missing in earlier wave replace alzhe = 0 if alzhe == . replace l2alzhe = 0 if l2alzhe == . replace cogstate = 3 if cogstate == . replace l2cogstate = 3 if l2cogstate == . replace selfmem = 1 if selfmem == . replace l2selfmem = 1 if l2selfmem == . * This is a kludge to deal with individuals who have missing weight and missing bweight. I think this relates to three nursing home respondents, two of which were dead in 2004. drop if weight == . & bweight == . multiply_persons `expand' gen entry = 2010 /* *** Merge with imputed biomarker data */ drop sysbp diabp l2sysbp l2diabp #d ; merge 1:1 hhidpn wave using "$dua_rand_hrs/bio_hrs_recoded_impfinal.dta", keepusing(hhidpn wave biowgtr ldl_imp ldl_miss l2ldl_miss l2ldl_imp hdl_imp hdl_miss l2hdl_miss l2hdl_imp tchol_imp tchol_miss l2tchol_imp l2tchol_miss a1c_imp a1c_miss l2a1c_imp l2a1c_miss sysbp_imp sysbp_miss l2sysbp_imp l2sysbp_miss logcrp_imp crp_miss l2logcrp_imp l2crp_miss crp_imp l2crp_imp ) keep (master match) nogen ; #d cr ** Rename the imputed biomarkers ** Make sure there is no missing value for all the l2 variables foreach v in ldl hdl tchol a1c sysbp crp logcrp { rename `v'_imp `v' rename l2`v'_imp l2`v' replace l2`v' = `v' if l2`v' == . & wave ==10 } foreach v in rxchol hibperx diaberx { replace `v' = 0 if `v' == . & iwstat == 5 replace l2`v' = `v' if l2`v' == . & iwstat == 5 } if missing("`bsamp'") { if(floor(c(version))>=14) { saveold "$outdata/stock_hrs_2010_bio.dta", replace v(12) } else { saveold "$outdata/stock_hrs_2010_bio.dta", replace } } else { if(floor(c(version))>=14) { saveold "$outdata/input_rep`bsamp'/stock_hrs_2010_bio.dta", replace v(12) } else{ saveold "$outdata/input_rep`bsamp'/stock_hrs_2010_bio.dta", replace } }