quietly: infile ptid mridate age male race weight height packyrs yrsquit alcoh /// physact chf chd stroke diabetes genhlth ldl alb crt plt sbp aai /// fev dsst atrophy whgrd numinf volinf obstime death /// using http://www.emersonstatistics.com/datasets/mri.txt drop in 1 summ obstime if death==0 g deadin5= 0 replace deadin5= 1 if obstime <= 5 * 365.25 recode ldl 160/max=3 130/160=2 min/130=1, gen(ldlCTG) recode ldl 160/max=1 0/160=0, gen(ldlGE160) g logldl= log(ldl) recode chd 0=0 1=1 2=0, gen(angina) recode chd 0=0 1=0 2=1, gen(mi) recode stroke 0=0 1=1 2=0, gen(tia) recode stroke 0=0 1=0 2=1, gen(cva) gen cvd= chd + stroke + chf recode cvd 0=0 1/max=1 tabstat male age weight packyrs angina mi tia cva chf cvd deadin5, /// by(ldlCTG) stat(n mean sd min q max) col(stat) long tabstat male age weight ldl packyrs angina mi tia cva chf cvd, /// by(deadin5) stat(n mean sd min q max) col(stat) long ttest ldl, by(deadin5) unequal ttest ldl, by(deadin5) ttest logldl, by(deadin5) unequal di exp(4.810764), exp(4.718601), exp(.0921629), exp(.0199059), exp( .1644199) ttest logldl, by(deadin5) di exp(4.810764), exp(4.718601), exp(.0921629), exp(.0348868), exp( .149439) cs deadin5 ldlGE160, or cc deadin5 ldlGE160, exact g obsmos= obstime / 30.4 stset obsmos death sts graph, by(ldlGE160) ylabel(0.75(.05)1.00) /// plot1opts(lcolor(red)) plot2opts(lcolor(blue)) sts list, by(ldlGE160) at(12 24 36 48 60) sts test ldlGE160 stcox ldlGE160, robust stcox ldlGE160