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: 21,563

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: 21,563

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: 3,908

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.

Ask a Question
Discussion stats
  • 5 replies
  • 123 views
  • 0 likes
  • 3 in conversation