To download the datasets, go the Stata Reference Manual data link (this is found in the ‘Links to textbook datasets’, then go to the ‘Survival Analysis and Epi Tables (ST) link. You can download all the files or just a few, if you wish. (selvin.dta and rat.dta)
. use "C:\DATA\Stata\selvin.dta", clear
. browse
. ltable t d [freq=pop]
Beg. Std.
Interval Total Deaths Lost Survival Error [95% Conf. Int.]
------
0 1 126 47 19 0.5966 0.0455 0.5017 0.6792
1 2 60 5 17 0.5386 0.0479 0.4405 0.6269
2 3 38 2 15 0.5033 0.0508 0.4002 0.5977
3 4 21 2 9 0.4423 0.0602 0.3225 0.5554
4 5 10 0 6 0.4423 0.0602 0.3225 0.5554
5 6 4 0 4 0.4423 0.0602 0.3225 0.5554
------
. disp 1 - 47/(126-19/2)
.59656652
. disp (1- 5/(60-17/2))*(1- 47/(126-19/2))
.53864744
. disp (1- 2/(38-15/2))*(1- 5/(60-17/2))*(1- 47/(126-19/2))
.5033263
. clear
. use "C:\DATA\Stata\rat.dta", clear
. stset t, failure(died)
failure event: died != 0 & died < .
obs. time interval: (0, t]
exit on or before: failure
------
40 total obs.
0 exclusions
------
40 obs. remaining, representing
36 failures in single record/single failure data
9118 total analysis time at risk, at risk from t = 0
earliest observed entry t = 0
last observed exit t = 344
. sts graph,by(group)
failure _d: died
analysis time _t: t
. sts list, by(group)
failure _d: died
analysis time _t: t
Beg. Net Survivor Std.
Time Total Fail Lost Function Error [95% Conf. Int.]
------
group=1
143 19 1 0 0.9474 0.0512 0.6812 0.9924
164 18 1 0 0.8947 0.0704 0.6408 0.9726
188 17 2 0 0.7895 0.0935 0.5319 0.9153
190 15 1 0 0.7368 0.1010 0.4789 0.8810
192 14 1 0 0.6842 0.1066 0.4279 0.8439
206 13 1 0 0.6316 0.1107 0.3790 0.8044
209 12 1 0 0.5789 0.1133 0.3321 0.7626
213 11 1 0 0.5263 0.1145 0.2872 0.7188
216 10 1 1 0.4737 0.1145 0.2444 0.6728
220 8 1 0 0.4145 0.1145 0.1962 0.6211
227 7 1 0 0.3553 0.1124 0.1519 0.5665
230 6 1 0 0.2961 0.1082 0.1117 0.5087
234 5 1 0 0.2368 0.1015 0.0758 0.4475
244 4 0 1 0.2368 0.1015 0.0758 0.4475
246 3 1 0 0.1579 0.0934 0.0314 0.3735
265 2 1 0 0.0789 0.0728 0.0057 0.2876
304 1 1 0 0.0000 . . .
group=2
142 21 1 0 0.9524 0.0465 0.7072 0.9932
156 20 1 0 0.9048 0.0641 0.6700 0.9753
163 19 1 0 0.8571 0.0764 0.6197 0.9516
198 18 1 0 0.8095 0.0857 0.5689 0.9239
204 17 0 1 0.8095 0.0857 0.5689 0.9239
205 16 1 0 0.7589 0.0941 0.5139 0.8920
232 15 2 0 0.6577 0.1053 0.4123 0.8203
233 13 4 0 0.4554 0.1114 0.2353 0.6520
239 9 1 0 0.4048 0.1099 0.1961 0.6052
240 8 1 0 0.3542 0.1072 0.1591 0.5564
261 7 1 0 0.3036 0.1031 0.1245 0.5056
280 6 2 0 0.2024 0.0902 0.0633 0.3967
296 4 2 0 0.1012 0.0678 0.0172 0.2749
323 2 1 0 0.0506 0.0493 0.0035 0.2073
344 1 0 1 0.0506 0.0493 0.0035 0.2073
------
. sts test group
failure _d: died
analysis time _t: t
Log-rank test for equality of survivor functions
| Events Events
group | observed expected
------+------
1 | 17 12.24
2 | 19 23.76
------+------
Total | 36 36.00
chi2(1) = 3.12
Pr>chi2 = 0.0772
.