* Program survcmacs.v3.sas; * Created by Nancy Cook (BWH, HMS, HSPH) ; * Macros for Overall C for SURVIVAL data; * With Standard errors from Pencina et al, Stat Med, 2004; * PREDC uses predicted probabilities at time T; * with corrected Noether CI; * can subset the data into 10 (default) partitions for efficiency; * PREDCWT includes weights; * SIMP versions do not do Noether CIs - use for bootstrapping; * Use BIG versions to bootstrap large datasets - subsets for efficiency; * Note: these can take some time to run; * Edited 12/22/16 (version 2) to fix ties; * Edited 10/29/28 (version 3) to fix CIs in predc and predcwt (especially wide); * Usage: * %predc(data,2,id,event,pyrs,prob); * NOTE: default nsubs=10 if omitted; * %predcwt(data,2,id,wt,event,pyrs,prob); * %predc_simp(data,2,id,event,pyrs,prob); * %predcwt_simp(data,2,id,wt,event,pyrs,prob); * %predc_big(data,2,id,event,pyrs,prob,100); * %predcwt_big(data,2,id,wt,event,pyrs,prob,100); *************************************************************************************************; %macro PREDC(DSNAME,DETAIL,ID,EVENT,PYRS,PROB,NSUBS); * To compute c-index for survival data; * Using the predicted probability of survival at TIME T; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); * NSUBS = number of subsets of the data to use in computations; * Should be large (eg 100) for large datasets); * Default is 10; %if &NSUBS= %then %let NSUBS=10; %put NSUBS= &nsubs ; data obsdata; set &DSNAME; id=&ID; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; * compute subsamples to avoid large files in sql; groupvar=ranuni(0); keep id event surv folltime groupvar; run; %if &detail=2 %then %do; proc means data=obsdata; title2 "Data = obsdata"; run; %end; data _calc_; set obsdata end=eof; if eof=1 then do; totobs=_n_; output; keep totobs; end; run; data setj; set obsdata; * keep ALL; rename id=id_j surv=y_j folltime=x_j event=z_j; keep id event surv folltime groupvar; run; proc rank data=setj out=setj groups=&NSUBS ; var groupvar; proc sort data=setj; by groupvar; run; %do igrp = 1 %to &NSUBS; data subset; set setj; if groupvar=&igrp-1; run; * Construct ALL usable pairs; proc sql; * create file with all combinations of observations; * Include subset j crossed with all obs; * Just keep usable pairs; create table allset as select id_j, y_j, x_j, z_j, id as id_i, surv as y_i, folltime as x_i, event as z_i from subset, obsdata where id_j < id_i and ((z_j=0 and z_i=1 and x_j > x_i) or (z_j=1 and z_i=0 and x_j < x_i) or (z_j=1 and z_i=1 and id_j ne id_i)) ; /* Not usable if died at same time */ quit; proc sort data=allset; by id_j id_i; * Compute c-index and 95% CI using Pencina and DAgostino; data calc&igrp ; set allset end=eof; by id_j; * x = follow-up time; * y = predicted probability of survival; * j = index person; * i = all others; retain nch ndh nchj ndhj sumcc sumdd sumcd 0; if first.id_j then do; nchj=0; ndhj=0; end; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if ((x_i>x_j and y_i>y_j) or (x_i0 then do; nch+concord; nchj+concord; end; if concord=0 then do; ndh+1; ndhj+1; end; if last.id_j then do; sumcc=sumcc + nchj*(nchj-1); sumdd=sumdd + ndhj*(ndhj-1); sumcd=sumcd + nchj*ndhj; end; if eof=1 then do; uspairs=_n_; nch&igrp=nch; ndh&igrp=ndh; uspairs&igrp=uspairs; sumcc&igrp=sumcc; sumdd&igrp=sumdd; sumcd&igrp=sumcd; output; keep nch&igrp ndh&igrp uspairs&igrp sumcc&igrp sumdd&igrp sumcd&igrp; end; run; data _calc_; merge _calc_ calc&igrp; %end; proc datasets nolist; delete allset; quit; data _calc_; set _calc_; * Sum over subsets; nch=sum(of nch1-nch&NSUBS); ndh=sum(of ndh1-ndh&NSUBS); uspairs=sum(of uspairs1-uspairs&NSUBS); sumcc=sum(of sumcc1-sumcc&NSUBS); sumdd=sum(of sumdd1-sumdd&NSUBS); sumcd=sum(of sumcd1-sumcd&NSUBS); * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); * Noether Var and CI; pcc=sumcc/(totobs*(totobs-1)*(totobs-2)); pdd=sumdd/(totobs*(totobs-1)*(totobs-2)); pcd=sumcd/(totobs*(totobs-1)*(totobs-2)); num=pcc*pd**2 - 2*pc*pd*pcd + pdd*pc**2; denom=(pc+pd)**4; varp=4*num/denom; se_c=sqrt(varp/totobs); zstat_c=c_index/se_c; pvalue_c=2*(1-probnorm(abs(zstat_c))); low_ci_n=c_index-1.96*se_c; upper_ci_n=c_index+1.96*se_c; drop nch1-nch&NSUBS ndh1-ndh&NSUBS uspairs1-uspairs&NSUBS sumcc1-sumcc&NSUBS sumdd1-sumdd&NSUBS sumcd1-sumcd&NSUBS ; run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Overall C with Wide and Noether CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDC; ***********************************************************************************************; %macro PREDCWT(DSNAME,DETAIL,ID,WT,EVENT,PYRS,PROB,NSUBS); * Alternative Sas code to compute c-index for survival data; * Using the predicted probability of survival at TIME T; * Includes WEIGHTS; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * WT = sample weight for case-cohort analysis (indiv, not risk set); * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); %if &NSUBS= %then %let NSUBS=10; %put NSUBS= &nsubs ; data obsdata; set &DSNAME; id=&ID; wt=&WT; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; groupvar=ranuni(0); keep id wt event surv folltime groupvar; run; %if &detail=2 %then %do; proc means data=obsdata; weight wt; title2 "Data = Weighted obsdata"; run; %end; data _calc_; set obsdata end=eof; retain obswt 0; obswt=obswt+wt; if eof=1 then do; totobs=obswt; output; keep totobs; end; run; data setj; set obsdata; * keep ALL; rename id=id_j surv=y_j folltime=x_j event=z_j wt=wt_j; keep id wt event surv folltime groupvar; run; proc rank data=setj out=setj groups=&NSUBS ; var groupvar; proc sort data=setj; by groupvar; run; %do igrp = 1 %to &NSUBS; data subset; set setj; if groupvar=&igrp-1; run; * Construct only usable pairs; proc sql; * create file with all combinations of observations; * Include subset j crossed with all obs; * Just keep usable pairs; create table allset as select id_j, wt_j, y_j, x_j, z_j, id as id_i, wt as wt_i, surv as y_i, folltime as x_i, event as z_i from subset, obsdata where id_j < id_i and ((z_j=0 and z_i=1 and x_j > x_i) or (z_j=1 and z_i=0 and x_j < x_i) or (z_j=1 and z_i=1 and id_j ne id_i)) ; /* Not usable if died at same time */ quit; proc sort data=allset; by id_j id_i; * Compute c-index and 95% CI using Pencina and DAgostino; data calc&igrp ; set allset end=eof; by id_j; * x = follow-up time; * y = predicted probability of survival; * j = case; * i = all (cases and censored); retain nch ndh nchj ndhj sumcc sumdd sumcd sumwt 0; if first.id_j then do; nchj=0; ndhj=0; end; wt_ij=wt_i*wt_j; sumwt=sumwt+wt_ij; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if ((x_i>x_j and y_i>y_j) or (x_i0 then do; nch+concord*wt_ij; nchj+concord*wt_ij; end; if concord=0 then do; ndh+wt_ij; ndhj+wt_ij; end; if last.id_j then do; sumcc=sumcc + nchj*(nchj-1); sumdd=sumdd + ndhj*(ndhj-1); sumcd=sumcd + nchj*ndhj; end; if eof=1 then do; uspairs=sumwt; nch&igrp=nch; ndh&igrp=ndh; uspairs&igrp=uspairs; sumcc&igrp=sumcc; sumdd&igrp=sumdd; sumcd&igrp=sumcd; output; keep nch&igrp ndh&igrp uspairs&igrp sumcc&igrp sumdd&igrp sumcd&igrp; end; run; data _calc_; merge _calc_ calc&igrp; %end; proc datasets nolist; delete allset; quit; data _calc_; set _calc_; * Sum over subsets; nch=sum(of nch1-nch&NSUBS); ndh=sum(of ndh1-ndh&NSUBS); uspairs=sum(of uspairs1-uspairs&NSUBS); sumcc=sum(of sumcc1-sumcc&NSUBS); sumdd=sum(of sumdd1-sumdd&NSUBS); sumcd=sum(of sumcd1-sumcd&NSUBS); * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); * Noether Var and CI; pcc=sumcc/(totobs*(totobs-1)*(totobs-2)); pdd=sumdd/(totobs*(totobs-1)*(totobs-2)); pcd=sumcd/(totobs*(totobs-1)*(totobs-2)); num=pcc*pd**2 - 2*pc*pd*pcd + pdd*pc**2; denom=(pc+pd)**4; varp=4*num/denom; se_c=sqrt(varp/totobs); zstat_c=c_index/se_c; pvalue_c=2*(1-probnorm(abs(zstat_c))); low_ci_n=c_index-1.96*se_c; upper_ci_n=c_index+1.96*se_c; drop nch1-nch&NSUBS ndh1-ndh&NSUBS uspairs1-uspairs&NSUBS sumcc1-sumcc&NSUBS sumdd1-sumdd&NSUBS sumcd1-sumcd&NSUBS ; run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Weighted Overall C with Wide and Noether CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDCWT; **********************************************************************************************; %macro PREDC_SIMP(DSNAME,DETAIL,ID,EVENT,PYRS,PROB); * Alternative Sas code to compute c-index for survival data; * This version does not compute Noether CIs; * Use for bootstrapping to save time; * Using the predicted probability of survival at TIME T; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); data obsdata; set &DSNAME; id=&ID; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; keep id event surv folltime ; run; %if &detail=2 %then %do; proc means data=obsdata; title2 "Data = obsdata"; run; %end; data evtset; set obsdata; if event=1; rename id=id_j surv=y_j folltime=x_j; keep id surv folltime; run; proc sql; * Construct only usable pairs; * From cross of events only with all obs; create table allset as select id_j, y_j, x_j, id as id_i, surv as y_i, folltime as x_i, event as z_i from evtset, obsdata where x_i > x_j; quit; * Compute c-index and 95% CI using Pencina and DAgostino; data _calc_; set allset end=eof; * x = follow-up time; * y = predicted probability of survival; * j = case; * i = all (cases and censored); retain nch ndh 0; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if (x_i>x_j and y_i>y_j) then concord=1; else concord=0; if concord>0 then nch+concord; if concord=0 then ndh+1; if eof=1 then do; uspairs=_n_; output; keep nch ndh uspairs ; end; run; proc datasets nolist; delete allset; quit; data totn; set obsdata end=eof; if eof=1 then do; totobs=_n_; output; keep totobs; end; run; data _calc_; merge _calc_ totn; * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Overall C with Wide CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDC_SIMP; ***********************************************************************************************; %macro PREDCWT_SIMP(DSNAME,DETAIL,ID,WT,EVENT,PYRS,PROB); * Alternative Sas code to compute c-index for survival data; * This version does not compute Noether CIs; * Use for bootstrapping to save time; * Using the predicted probability of survival at TIME T; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * WT = sample weight for case-cohort analysis (indiv, not risk set); * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); data obsdata; set &DSNAME; id=&ID; wt=&WT; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; keep id wt event surv folltime ; run; %if &detail=2 %then %do; proc means data=obsdata; weight wt; title2 "Data = Weighted obsdata"; run; %end; data evtset; set obsdata; if event=1; rename id=id_j surv=y_j folltime=x_j wt=wt_j; keep id wt surv folltime; run; proc sql; * Construct only usable pairs; * From cross of events only with all obs; create table allset as select id_j, wt_j, y_j, x_j, id as id_i, wt as wt_i, surv as y_i, folltime as x_i, event as z_i from evtset, obsdata where x_i > x_j; quit; * Compute c-index and 95% CI using Pencina and DAgostino; data _calc_; set allset end=eof; * x = follow-up time; * y = predicted probability of survival; * j = case; * i = all (cases and censored); retain nch ndh sumwt 0; wt_ij=wt_i*wt_j; sumwt=sumwt+wt_ij; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if (x_i>x_j and y_i>y_j) then concord=1; else concord=0; if concord>0 then do; nch+concord*wt_ij; nchj+concord*wt_ij; end; if concord=0 then do; ndh+wt_ij; ndhj+wt_ij; end; if eof=1 then do; uspairs=sumwt; output; keep nch ndh uspairs ; end; run; proc datasets nolist; delete allset; quit; data totn; set obsdata end=eof; retain obswt 0; obswt=obswt+wt; if eof=1 then do; totobs=obswt; output; keep totobs; end; run; data _calc_; merge _calc_ totn; * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Weighted Overall C with Wide CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDCWT_SIMP; **********************************************************************************************; %macro PREDC_BIG(DSNAME,DETAIL,ID,EVENT,PYRS,PROB,NSUBS); * Alternative Sas code to compute c-index for survival data; * This version does not compute Noether CIs; * Use for bootstrapping with big datasets - breaks into subsets; * Using the predicted probability of survival at TIME T; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); * NSUBS = number of subsets of the data to use in computations; * Should be large (eg 100) for large datasets); data obsdata; set &DSNAME; id=&ID; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; * compute subsamples to avoid large files in sql; groupvar=ranuni(0); keep id event surv folltime groupvar; run; %if &detail=2 %then %do; proc means data=obsdata; title2 "Data = obsdata"; run; %end; data evtset; set obsdata; if event=1; rename id=id_j surv=y_j folltime=x_j; keep id surv folltime; run; proc rank data=obsdata out=obsdata groups=&NSUBS ; var groupvar; proc sort data=obsdata; by groupvar; run; data _calc_; set obsdata end=eof; if eof=1 then do; totobs=_n_; output; keep totobs; end; run; %do igrp = 1 %to &NSUBS; data subset; set obsdata; if groupvar=&igrp-1; run; proc sql; * Construct only usable pairs; * From cross of events only with all obs; create table allset as select id_j, y_j, x_j, id as id_i, surv as y_i, folltime as x_i, event as z_i from evtset, subset where x_i > x_j; quit; * Compute c-index and 95% CI using Pencina and DAgostino; data calc&igrp (keep=nch&igrp ndh&igrp uspairs&igrp) ; set allset end=eof; * x = follow-up time; * y = predicted probability of survival; * j = case; * i = all (cases and censored); retain nch ndh 0; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if (x_i>x_j and y_i>y_j) then concord=1; else concord=0; if concord>0 then nch+concord; if concord=0 then ndh+1; if eof=1 then do; uspairs=_n_; nch&igrp=nch; ndh&igrp=ndh; uspairs&igrp=uspairs; output ; end; run; data _calc_; merge _calc_ calc&igrp; %end; proc datasets nolist; delete allset; quit; data _calc_; set _calc_; * Sum over subsets; nch=sum(of nch1-nch&NSUBS); ndh=sum(of ndh1-ndh&NSUBS); uspairs=sum(of uspairs1-uspairs&NSUBS); * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); drop nch1-nch&NSUBS ndh1-ndh&NSUBS uspairs1-uspairs&NSUBS; run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Overall C with Wide CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDC_BIG; ***********************************************************************************************; %macro PREDCWT_BIG(DSNAME,DETAIL,ID,WT,EVENT,PYRS,PROB,NSUBS); * Alternative Sas code to compute c-index for survival data; * This version does not compute Noether CIs; * Use for bootstrapping with big datasets - breaks into subsets; * Using the predicted probability of survival at TIME T; * (rather than at event or cens time as from proc phreg); * Eliminates those censored after case and dup case pairs; * Variables: * DSNAME = dataset name; * DETAIL = 2 for detailed printout, 1 for limited, 0 for none; * ID = ID varable; * EVENT = outcome variable (coded 0,1); * PYRS = person-time of follow-up; * PROB = predicted probability of event (1-survival prob); * NSUBS = number of subsets of the data to use in computations; * Should be large (eg 100) for large datasets); data obsdata; set &DSNAME; id=&ID; wt=&WT; event=&EVENT; folltime=&PYRS; surv=1-&PROB; * keep only those not missing key variables; if event ne . and folltime ne . and surv ne .; * compute subsamples to avoid large files in sql; groupvar=ranuni(0); keep id wt event surv folltime groupvar; run; %if &detail=2 %then %do; proc means data=obsdata; weight wt; title2 "Data = Weighted obsdata"; run; %end; data evtset; set obsdata; if event=1; rename id=id_j surv=y_j folltime=x_j wt=wt_j; keep id wt surv folltime; run; proc rank data=obsdata out=obsdata groups=&NSUBS ; var groupvar; proc sort data=obsdata; by groupvar; run; data _calc_; set obsdata end=eof; retain obswt 0; obswt=obswt+wt; if eof=1 then do; totobs=obswt; output; keep totobs; end; run; %do igrp = 1 %to &NSUBS; data subset; set obsdata; if groupvar=&igrp-1; run; proc sql; * Construct only usable pairs; * From cross of events only with all obs; create table allset as select id_j, wt_j, y_j, x_j, id as id_i, wt as wt_i, surv as y_i, folltime as x_i, event as z_i from evtset, subset where x_i > x_j; quit; * Compute c-index and 95% CI using Pencina and DAgostino; data calc&igrp (keep=nch&igrp ndh&igrp uspairs&igrp) ; set allset end=eof; * x = follow-up time; * y = predicted probability of survival; * j = case; * i = all (cases and censored); retain nch ndh sumwt 0; wt_ij=wt_i*wt_j; sumwt=sumwt+wt_ij; * use Harrell 1/2 weighting for tied observations; if y_i=y_j then concord=0.5; /* any tied prediction */ else if (x_i>x_j and y_i>y_j) then concord=1; else concord=0; if concord>0 then do; nch+concord*wt_ij; nchj+concord*wt_ij; end; if concord=0 then do; ndh+wt_ij; ndhj+wt_ij; end; if eof=1 then do; uspairs=sumwt; nch&igrp=nch; ndh&igrp=ndh; uspairs&igrp=uspairs; output; end; run; run; data _calc_; merge _calc_ calc&igrp; %end; proc datasets nolist; delete allset; quit; data _calc_; set _calc_; * Sum over subsets; nch=sum(of nch1-nch&NSUBS); ndh=sum(of ndh1-ndh&NSUBS); uspairs=sum(of uspairs1-uspairs&NSUBS); * Wide CI; pc=nch/(totobs*(totobs-1)); pd=ndh/(totobs*(totobs-1)); c_index=pc/(pc+pd); w=(2*1.96**2)/(totobs*(pc+pd)); low_ci_w=((w+2*c_index)/(2*(1+w)))-(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); upper_ci_w=((w+2*c_index)/(2*(1+w)))+(sqrt((w**2+4*w*c_index*(1- c_index))/(2*(1+w)))); drop nch1-nch&NSUBS ndh1-ndh&NSUBS uspairs1-uspairs&NSUBS; run; %if &detail>0 %then %do; proc print data=_calc_; title2 "Weighted Overall C with Wide CIs"; title3 "Using Predicted Probabilities = &PROB "; run; %end; %mend PREDCWT_BIG; *******************************************************************************;