Setting: One primary and one competing risks, with censoring


The following SAS program was written based on the paper by E. Korn, Statistics in Medicine 11: 813-829, 1991


/* program for cumulative incidence with one competing risk; time is in year. */
options ls = 78;

data tryout;

input time type1 type2;

censor = 1 - type1 - type2;

cards;


0.0 1 0

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

;


/* combines the events occuring at the same time. In a second step the events and grouped times (say 6-month intervals) are combined in a single code. The factors 10, 100, 1000 have to be adjusted to cover the max of events at a given time Time axis is partitioned into intervals [a(i), a(i+1), ...]. */
PROC means n sum nway noprint;

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;


/* Computing event-free survival prob, type1, survival prob, cum incidence, variance, st error, and 95% conf interval; f1 is (1-KM). */
PROC transpose out = transp;

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;


Return to Course's main page