log using stsatriskexamples, replace text sysuse cancer, clear set scheme sj /* Stata Journal scheme */ replace drug = (drug==1) /* makes two possible values for drug */ label define drtype 0 placebo 1 active label values drug drtype expand 10 /* 48 obs --> 480 obs */ stset studytime, failure(died) local tmax 20 stcox drug, noshow nolog /* Example graph 1 */ stsatrisk, by(drug) failure tmax(`tmax') /// caption("Relative risk: 7.53 (95% CI 5.73-9.89), p = 0.000") /* Example graph 2 is next 3 commands */ stsatrisk, by(drug) failure tmax(`tmax') clabel("Placebo" "Active") /// title("") name(stsatrisk, replace) /// caption("Relative risk 7.53 (95% CI 5.73-9.89), p = 0.000") sts graph, by(drug, title("")) failure tmax(`tmax') gwood /// name(cigraph, replace) graph combine stsatrisk cigraph, /// title("Kaplan-Meier failure estimates, by drug") graph export ../../eps/stsatrisk5.eps, replace /* Example graph 3 */ stsatrisk, by(drug) catrisk(0(4)20) clabel("Placebo" "Active") /// failure tmax(`tmax') /// caption("Relative risk 7.53 (95% CI 5.73-9.89), p = 0.000") /* Example graph 4 */ stsatrisk, showevents tablegend /// by(drug) clabel("Placebo" "Active") /// failure tmax(`tmax') /// caption("Relative risk 7.53 (95% CI 5.73-9.89), p = 0.000") /* Example graph 5 */ stsatrisk, catrisk(, size(*.75)) /// tablabel("Number at risk (events):") /// showevents tablegend by(drug) clabel("Placebo" "Active") /// failure tmax(`tmax') /// caption("Relative risk 7.53 (95% CI 5.73-9.89), p = 0.000") log close