The following SAS program was written based on the paper by E. Korn, Statistics in Medicine 11: 813-829, 1991
data tryout;
input time type1 type2;
censor = 1 - type1 - type2;
cards;
0.0 1 0
0.4 1 0
0.5 0 1
0.5 0 0
1.0 1 0
1.1 1 0
1.1 0 1
1.1 0 0
1.3 1 0
1.3 1 0
1.6 0 1
1.6 1 0
1.7 0 1
1.2 0 1
1.3 0 0
2 0 0
2.1 0 0
2.1 1 0
2.3 0 0
2.3 0 1
2.3 1 0
2.3 0 0
2.9 0 1
3.0 1 0
3.1 1 0
3.1 0 1
3.5 0 1
3.8 0 1
4.0 0 1
;
class time;
var type1 type2 censor;
output out = condense sum = type1 type2 censor;
PROC print data = condense;
run;
data condense;
set condense;
q =2;
interval = floor(q*time);
code = type1 + 10*type2 + 100*censor + 1000 *interval; keep code;
/*PROC print data = condense;
PROC frq;
table code;
run;
data new;
set transp;
array c(*) _numeric_;
s = 1;
s1 =1;
cum = 0;
v = 0;
interval =0;
n = 30;
ni = 0; j =0; k =0; l =0; m =0;
upper = .; lower = .;
censor = 0;
do i = 1 to dim(c);
interval = floor(c(i)/1000);
censor = floor((c(i)-1000*interval)/100);
type2 = floor((c(i)-1000*interval-100*censor)/10);
type1 = int(c(i)-1000*interval-100*censor-10*type2);
h = cum;
cum = cum + s*type1/n;
h = (h+cum)/2 + s;
ni = ni + h*type1/n**2;
j = j+(h**2)*type1/n**2;
k = k +cum*type2/n**2;
l = l+(cum**2)*type2/n**2;
m = m+(type1+type2)/n**2;
v = (cum**2)*m-2*cum*(ni+k)+j+l;
e = sqrt(v);
upper = min(cum+1.96*e,1);
lower = max(cum-1.96*e,0);
s = s*(1-(type1+type2)/n);
s1 = s1*(1-type1/n);
f1 = 1. - s1;
n = n-type1-type2-censor;
id = i; output;
end;
title 's1 = prob using "1-KM" and cum = cumulative incidence; plus 95% CI';
* summary for each time;
PROC print data = new;
var f1 cum v e lower upper n;
run;
* summary for groupd times;
PROC sort;
by interval id;
data new2;
set new;
by interval;
if last.interval;
PROC print data = new2;
var interval s s1 f1 cum v e lower upper n;
title '6-month intervals: s= Overall survival, s1= Survival by type1, V =Variance, E = St Error';
run;