Data visualization with SAS programming

Restricted cubic splines in proportional hazard regression

Reply
New Contributor
Posts: 4

Restricted cubic splines in proportional hazard regression

Hello everyone,

 

I am new to SAS. The hazard analysis shows that the association between Bicarb (LBXSC3SI) and survival is no linear. Thus, I want to plot restricted cubic splines in proportional hazard regression. 

 

I used the following syntax for basic cox proportional hazard model.

 

proc phreg data = survey;

model years*dead(0) = LBXSC3SI/rl;

run;

 

and to plot restricted cubic splines I used the following syntax

 

PROC PHREG DATA = survey;
effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details knotmethod=rangefractions(0.05 0.50 0.95) );
model years*dead (0) = LBXSC3SI/rl;
run;
ods graphics on;

 

However, I did not see any graph in my SAS output. I was wondering if anyone can help me with the syntax.

 

Thank you in advance!

Super User
Posts: 23,747

Re: Restricted cubic splines in proportional hazard regression

What did your log show for the last set of code in your post?

And what version of SAS do you have, specifically, SAS/STAT? If you're not sure, the code below will post the relevant information to the log.

 

proc product_status;run;

asarode wrote:

Hello everyone,

 

I am new to SAS. The hazard analysis shows that the association between Bicarb (LBXSC3SI) and survival is no linear. Thus, I want to plot restricted cubic splines in proportional hazard regression. 

 

I used the following syntax for basic cox proportional hazard model.

 

proc phreg data = survey;

model years*dead(0) = LBXSC3SI/rl;

run;

 

and to plot restricted cubic splines I used the following syntax

 

PROC PHREG DATA = survey;
effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details knotmethod=rangefractions(0.05 0.50 0.95) );
model years*dead (0) = LBXSC3SI/rl;
run;
ods graphics on;

 

However, I did not see any graph in my SAS output. I was wondering if anyone can help me with the syntax.

 

Thank you in advance!


 

New Contributor
Posts: 4

Re: Restricted cubic splines in proportional hazard regression

Hello Reza,

I am using SAS 9.3

 

I did not see any error in my log window. Here is what the log window shows from my code

 


51 PROC PHREG DATA = survey;
52 effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details
52 ! knotmethod=rangefractions(0.05 0.50 0.95) );
53 model years*dead (0) = LBXSC3SI/rl;
54 run;

NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: PROCEDURE PHREG used (Total process time):
real time 0.82 seconds
cpu time 0.57 seconds


55 ods graphics on;

 

I used the solution you provided still I do not see the graph. 

 

This is what SAS log window says after I used your solution

 

PROC PHREG DATA = survey;
57 effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details
57 ! knotmethod=rangefractions(0.05 0.50 0.95) );
58 model years*dead (0) = LBXSC3SI/rl;

NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: PROCEDURE PHREG used (Total process time):
real time 5.45 seconds
cpu time 0.53 seconds


59 proc product_status;run;

For Base SAS Software ...
Custom version information: 9.3_M2
Image version information: 9.03.01M2P081512
For SAS/STAT ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/GRAPH ...
Custom version information: 9.3_M2
For SAS/ETS ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/FSP ...
Custom version information: 9.3_M1
For SAS/OR ...
Custom version information: 12.2
Image version information: 9.03.01M0P120512
For SAS/AF ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/IML ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/QC ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/SHARE ...
Custom version information: 9.3_M1
For SAS/LAB ...
Custom version information: 9.3
Image version information: 9.03.01M0P081512
For SAS/ASSIST ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/CONNECT ...
Custom version information: 9.3_M2
For SAS/EIS ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to Netezza ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS Integration Technologies ...
Custom version information: 9.3_M2
For SAS/Secure Windows ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to DB2 ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to Oracle ...
Custom version information: 9.3_M1
For SAS/ACCESS Interface to Sybase ...
Custom version information: 9.3_M1
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to OLE DB ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to Teradata ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to MySQL ...
Custom version information: 9.3_M2
NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):
real time 4.20 seconds
cpu time 0.25 seconds


60 ods graphics on;

Super User
Posts: 23,747

Re: Restricted cubic splines in proportional hazard regression

I didn't provide a solution....

Anyways, you're working with a relatively old version, SAS STAT is now at 14.3 (yours is 12.1).

 

There's nothing within your code that shows as wrong, and it looks like you have the ODS GRAPHICS ON, try adding PLOTS to the PROC PHREG statement is the only other thought I had. 

 

I'm also assuming you're seeing the other output from PROC PHREG, just not the graphs?

 


asarode wrote:

Hello Reza,

I am using SAS 9.3

 

I did not see any error in my log window. Here is what the log window shows from my code

 


51 PROC PHREG DATA = survey;
52 effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details
52 ! knotmethod=rangefractions(0.05 0.50 0.95) );
53 model years*dead (0) = LBXSC3SI/rl;
54 run;

NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: PROCEDURE PHREG used (Total process time):
real time 0.82 seconds
cpu time 0.57 seconds


55 ods graphics on;

 

I used the solution you provided still I do not see the graph. 

 

This is what SAS log window says after I used your solution

 

PROC PHREG DATA = survey;
57 effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details
57 ! knotmethod=rangefractions(0.05 0.50 0.95) );
58 model years*dead (0) = LBXSC3SI/rl;

NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: PROCEDURE PHREG used (Total process time):
real time 5.45 seconds
cpu time 0.53 seconds


59 proc product_status;run;

For Base SAS Software ...
Custom version information: 9.3_M2
Image version information: 9.03.01M2P081512
For SAS/STAT ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/GRAPH ...
Custom version information: 9.3_M2
For SAS/ETS ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/FSP ...
Custom version information: 9.3_M1
For SAS/OR ...
Custom version information: 12.2
Image version information: 9.03.01M0P120512
For SAS/AF ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/IML ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/QC ...
Custom version information: 12.1
Image version information: 9.03.01M0P081512
For SAS/SHARE ...
Custom version information: 9.3_M1
For SAS/LAB ...
Custom version information: 9.3
Image version information: 9.03.01M0P081512
For SAS/ASSIST ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/CONNECT ...
Custom version information: 9.3_M2
For SAS/EIS ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to Netezza ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS Integration Technologies ...
Custom version information: 9.3_M2
For SAS/Secure Windows ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to DB2 ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to Oracle ...
Custom version information: 9.3_M1
For SAS/ACCESS Interface to Sybase ...
Custom version information: 9.3_M1
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to OLE DB ...
Custom version information: 9.3
Image version information: 9.03.01M0P052511
For SAS/ACCESS Interface to Teradata ...
Custom version information: 9.3_M2
For SAS/ACCESS Interface to MySQL ...
Custom version information: 9.3_M2
NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):
real time 4.20 seconds
cpu time 0.25 seconds


60 ods graphics on;


 

New Contributor
Posts: 4

Re: Restricted cubic splines in proportional hazard regression

Yes, it's just the graph that I do not see in the SAS output. I have one more question for you what do I use for PLOTS = ? 

 

PROC PHREG DATA = survey plots= (?);
effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details knotmethod=rangefractions(0.05 0.50 0.95) );
model years*dead (0) = LBXSC3SI/rl;
run;
ods graphics on;

 

Thanks!

Highlighted
SAS Super FREQ
Posts: 4,242

Re: Restricted cubic splines in proportional hazard regression

[ Edited ]

You misspelled the name of the spline variable. Use

ods graphics on;
PROC PHREG DATA = heart plots=(cumhaz surv); /* or other plots */
   effect LBXSC3SIs = spline(LBXSC3SI / basis=tpf(noint) NATURALCUBIC details knotmethod=rangefractions(0.05 0.50 0.95) );
   model years*dead (0) = LBXSC3SIs  / rl;
run;

 The MODEL statement takes the name of the effect, not the original variable.

Occasional Contributor
Posts: 7

Re: Restricted cubic splines in proportional hazard regression

Hi Dr. Rick, 

I'm assessing the association between lactation and maternal risk of diabetes and I am using the code below to run the unadjusted model, also I want to graph splines and I followed your code too, but I don't get the splines graph (please the attached document). 

 

time variable=follow_timedx_yrs

case= definicion11_1

exposure= lactationbyparcat (continous and dummies)

 

/*Unadjusted model*/
proc phreg data=diabetes2;
model follow_timedx_yrs*definicion11_1(0) = lactationbyparcat_1 lactationbyparcat_2 lactationbyparcat_3 lactationbyparcat_4/rl;
run;

 

ods graphics on;
proc phreg data = diabetes2 plots= (cumhaz);
effect lactationbypars = spline(lactationbypar / basis=tpf(noint) NATURALCUBIC details knotmethod=rangefractions(0.05 0.50 0.95) );
model follow_timedx_yrs*definicion11_1(0) = lactationbypars/rl;
run;

 

When I run this code I don't get the HR. How can I get it? and how can specify the knots? for example at 0,6,12 and 24 months of lactation.

 

Thanks in advance,

Monica

SAS Super FREQ
Posts: 4,242

Re: Restricted cubic splines in proportional hazard regression

Posted in reply to mmazariegos

Your code includes the option PLOTS=(CUMHAZ), which means that you are only requesting the plot for the cumulative hazard function. See the documentation for the other plots that you can request.You can also browse the Examples section of the documentation to see if your plot appears in any of the examples. If not, see the doc for the OUTPUT statement and create an output data set that contains the statistic that you want.

 

To specify the placement of the knots, see the article "Regression with restricted cubic splines in SAS". It sounds like you might want the LIST option: such as 

KNOTMETHOD=LIST(0, 6, 12, 24)

 

 

Ask a Question
Discussion stats
  • 7 replies
  • 470 views
  • 2 likes
  • 4 in conversation