************************************************************************ * * * exer6-3.do * * * * DATE: 01/05/18 * * * ************************************************************************ infile stage time age year status using larynx-dat.txt label variable stage "stage at diagnosis" label variable time "time (years)" label variable age "age" label variable year "year of entry" label variable status "status" *** *** Univariate summaries *** summarize age centile age, centile( 10 25 50 75 90 ) table year table stage *** *** Bivariate summaries with stage *** tabulate stage status, row tabulate stage year, col sort stage by stage: summarize age *** *** set the survival response *** stset time, failure(status) *** *** show the overall survival estimate *** sts list *** *** plot the overall KM *** sts graph, saving("larynx-0.plot") *** *** KM and log-rank for stage34 *** gen stage34 = stage recode stage34 1/2=0 3/4=1 sts graph, by(stage34) saving("larynx-1.plot") sts test stage34, logrank *** *** KM and log-rank for stage *** sts graph, by(stage) saving("larynx-2.plot") sts test stage, logrank *** *** optional *** generate pre75 = year recode pre75 min/74=1 75/max=0 *** pre 1975 sts graph if pre75==1, by(stage34) saving("larynx-3.plot") sts test stage34 if pre75==1, logrank *** 1975+ sts graph if pre75==0 , by(stage34) saving("larynx-4.plot") sts test stage34 if pre75==0, logrank