cap log close log using "hrs2006_mi.log", replace *** * product: hrs2006_mi_full_stock.dta; hrs2006_mi_short_stock.dta * generate descriptive statistics on HRS2006 TICS with MI * indata: HRS stock 2006 * outdata: HRS 2006; whole sample * exhibits: Table3 HRS; Graph1 HRS * dependent files: none *** /* /* analytic */ use ../../../input_data/hrs_analytic_recoded.dta, clear merge 1:1 hhidpn wave using "../../../input_data/tics.dta", keepusing(totcog cogstate) nogen keep(master match) keep if wave==8 codebook iwstat keep if iwstat==1 keep if age >= 53 gen totcog_06 =totcog gen male_hsless = male*hsless gen male_black = male*black gen male_hispan = male*hispan /* Create age spline indicator variables */ gen l2age = age - 2 gen l2age65l = 63 if 63 < l2age replace l2age65l = l2age if l2age <= 63 gen temp_max = 0 if l2age-63<0 replace temp_max = l2age-63 if l2age-63>0 gen l2age6574 = 10 if 10 < temp_max replace l2age6574 = temp_max if temp_max <= 10 gen l2age75p = 0 if 0 > l2age-73 replace l2age75p = l2age-73 if l2age-73 >= 0 mdesc totcog_06 black hispan hsless college male male_hsless male_black male_hispan l2age65l l2age6574 l2age75p hearte stroke cancre hibpe diabe lunge hearta work widowed smokev global totcog_var black hispan hsless college male male_hsless male_black male_hispan l2age65l l2age6574 l2age75p hearte stroke cancre hibpe diabe lunge hearta work widowed smokev foreach x of varlist $totcog_var { drop if missing(`x') } mi set wide mi misstable summarize totcog_06 mi register imputed totcog_06 mi impute ologit totcog_06 = black hispan hsless college male male_hsless male_black male_hispan l2age65l l2age6574 l2age75p hearte stroke cancre hibpe diabe lunge hearta work widowed smokev, add(500) rseed(2020) mi convert mlong, clear drop if _mi_miss==1 replace wtcrnh=wtcrnh/500 if _mi_m != 0 gen mi_flag_06 = 0 replace mi_flag_06 = 1 if _mi_m != 0 sum totcog_06 [aweight=wtcrnh], de tab totcog_06 [aweight=wtcrnh] save hrs2006_mi_full_analytic.dta, replace keep hhidpn totcog_06 wtcrnh mi_flag_06 cogstate rename wtcrnh weight_06 rename cogstate cogstate_06 gen cogcat_06 = . replace cogcat_06 = 1 if totcog_06 <= 6 replace cogcat_06 = 2 if totcog_06 >= 7 & totcog_06 <= 11 replace cogcat_06 = 3 if totcog_06 >= 12 & totcog_06 <= 27 save hrs2006_mi_short_analytic.dta, replace tab cogcat_06 [aweight=weight_06] tab cogstate_06 [aweight=weight_06] */ /* stock_hrs_2006 */ use ../../../input_data/stock_hrs_2006.dta, clear keep if wave==8 keep if iwstat==1 keep if age >= 53 gen totcog_06 = totcog - 1 gen male_hsless = male*hsless gen male_black = male*black gen male_hispan = male*hispan /* Create age spline indicator variables */ gen l2age65l = 63 if 63 < l2age replace l2age65l = l2age if l2age <= 63 gen temp_max = 0 if l2age-63<0 replace temp_max = l2age-63 if l2age-63>0 gen l2age6574 = 10 if 10 < temp_max replace l2age6574 = temp_max if temp_max <= 10 gen l2age75p = 0 if 0 > l2age-73 replace l2age75p = l2age-73 if l2age-73 >= 0 mdesc totcog_06 mi set wide mi misstable summarize totcog_06 mi register imputed totcog_06 mi impute ologit totcog_06 = black hispan hsless college male male_hsless male_black male_hispan l2age65l l2age6574 l2age75p hearte stroke cancre hibpe diabe lunge hearta work widowed smokev, add(500) rseed(2020) mi convert mlong, clear drop if _mi_miss==1 replace weight=weight/500 if _mi_m != 0 gen mi_flag_06 = 0 replace mi_flag_06 = 1 if _mi_m != 0 sum totcog_06 [aweight=weight], de tab totcog_06 [aweight=weight] save hrs2006_mi_full_stock.dta, replace keep hhidpn totcog_06 weight mi_flag_06 cogstate rename weight weight_06 rename cogstate cogstate_06 gen cogcat_06 = . replace cogcat_06 = 1 if totcog_06 <= 6 replace cogcat_06 = 2 if totcog_06 >= 7 & totcog_06 <= 11 replace cogcat_06 = 3 if totcog_06 >= 12 & totcog_06 <= 27 save hrs2006_mi_short_stock.dta, replace log close