Hello, I am using complex survey data from NHANES to develop a risk prediction model. I'm following example code for non-survey data found here: https://ncook.bwh.harvard.edu/sas-macros.html The first step is to output predicted probabilities from my Cox regression. However, the output options from PROC PHREG do not seem to be available for PROC SURVEYPHREG. I'm specifically trying output predicted survival probabilities (SURVIVAL=) and linear predictor (XBETA=). Does anyone have advice on how to output these from PROC SURVEYPHREG? Thanks, Sophie Example using PROC PHREG /****** MACRO DEFINITION *******/
%macro PREDMAC (DSNAME, EVENT, EVNTLABL, PYRS, MODLABL, PROB);
proc phreg data=&DSNAME outest=betas(drop=_ties_ _type_ _name_);
id _id_;
model &PYRS*&EVENT(0)= &MODVARS / rl;
output out=survdat survival=survest xbeta=bx;
title2 "PHREG for Outcome: &EVNTLABL";
title3 "For Model = &MODLABL";
run;
data base; set survdat;
* Keep dummy obs only;
if _id_=0;
* baseline survival estimate for referent person;
basesurv=survest;
* centered linear estimate;
bxave=bx;
keep basesurv bxave;
put _id_= &pyrs= basesurv= bxave= ;
data preddat; merge &DSNAME survdat; by _id_;
* delete dummy obs;
if _id_=0 then delete;
data preddat;
if _n_=1 then set base;
set preddat ;
surv=basesurv**(exp(bx-bxave));
&prob=1-surv;
run;
proc univariate plot data=preddat; id _id_;
var &prob;
title2 "Predicted Event Probabilities from Cox Model";
title3 "For Outcome = &EVNTLABL and Model = &MODLABL ";
run;
%mend PREDMAC;
* EXAMPLE USAGE OF MACROS;
* %predmac(one, cvd, Total CVD, pyrs, Model with X1-X20, prcvd10);
/****** END MACRO DEFINITION *******/ Attempt to convert to PROC SURVEYPHREG: /****** MACRO DEFINITION *******/
%macro PREDMAC (DSNAME, EVENT, EVNTLABL, PYRS, MODLABL, PROB);
proc surveyphreg data=&DSNAME ORDER=INTERNAL varmethod=taylor nomcar;
weight WTSSCB6YR;
cluster sdmvpsu;
strata sdmvstra;
domain pop;
model &PYRS*&EVENT(0)= &MODVARS / rl;
*outest=betas(drop=_ties_ _type_ _name_);
output out=survdat survival=survest xbeta=bx;
title2 "PHREG for Outcome: &EVNTLABL";
title3 "For Model = &MODLABL";
run;
data base; set survdat;
* Keep dummy obs only;
if _id_=0 and pop=1;
* baseline survival estimate for referent person;
basesurv=survest;
* centered linear estimate;
bxave=bx;
keep basesurv bxave;
put _id_= &pyrs= basesurv= bxave= ;
data preddat; merge &DSNAME survdat; by _id_;
* delete dummy obs;
if _id_=0 or pop=0 then delete;
data preddat;
if _n_=1 then set base;
set preddat ;
surv=basesurv**(exp(bx-bxave));
&prob=1-surv;
run;
proc univariate plot data=preddat; id _id_;
var &prob;
title2 "Predicted Event Probabilities from Cox Model";
title3 "For Outcome = &EVNTLABL and Model = &MODLABL ";
run;
%mend PREDMAC;
* EXAMPLE USAGE OF MACROS;
* %predmac(one, cvd, Total CVD, pyrs, Model with X1-X20, prcvd10);
/****** END MACRO DEFINITION *******/
... View more