clear
input time event str1 group
1 2 B
2 2 A
3 0 A
4 1 B
5 1 A
6 0 A
7 2 B
8 0 A
9 1 B
10 0 A
11 2 A
12 1 A
13 1 A
14 2 A
15 2 B
16 1 A
17 1 B
18 1 A
19 0 A
20 0 B
end
gen group1=0 if group=="A"
replace group1=1 if group=="B"
gen group2=1 if group=="A"
replace group2=2 if group=="B"
stset time, failure(event==1)
stcox group1
predict h1, basehc
stcox group2
predict h2, basehc
input time event str1 group
1 2 B
2 2 A
3 0 A
4 1 B
5 1 A
6 0 A
7 2 B
8 0 A
9 1 B
10 0 A
11 2 A
12 1 A
13 1 A
14 2 A
15 2 B
16 1 A
17 1 B
18 1 A
19 0 A
20 0 B
end
gen group1=0 if group=="A"
replace group1=1 if group=="B"
gen group2=1 if group=="A"
replace group2=2 if group=="B"
stset time, failure(event==1)
stcox group1
predict h1, basehc
stcox group2
predict h2, basehc
Comment