BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ANKH1
Pyrite | Level 9

Hi, we have this dataset:

data have;
input ID Lastage group1 group2 Age_trt Event_age; 
datalines;
1   12  0   1   2   4
2   13  0   1   4   6
3   11  1   0   3   7
4   12  1   0   2   .
5   14  0   1   2   .
6   12  1   0   7   9
7   11  1   0   1   6nn
8   14  0   1   3   .
9   13  1   0   3   .
10  13  0   1   5   8
;
run;

data sample;
set have;
time2event = coalesce(event_age, lastage) - age_trt;
censor = missing(event_age);
if group1=1 then group=1;
else group=2;
run;

Kindly @Reeza advised with coding to obtain KM failure plots. We are not interested in survival but in time to first event. This is the code:

ods trace on;
ods output failureplot=sp;
proc lifetest data=sample plots=survival(f)
outsurv=survival_data timelist=(0 to 24 by 2) reduceout;
strata group;
time time2event*censor(1);
run;


proc sgplot data=sp;
step x=time y=_1_survival_/group=stratum name="Percentage of patients reporting the first event";
xaxis values=(0 to 24 by 2) valueshint label="Time to event (Months)";
yaxis offsetmin=0.02 min=0 offsetmax=0.1 max=1.0 label="Percentage of patients reporting the First Event";
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) name='censored';
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) GROUP=stratum;
run;

Now, we need Cox models. I've used the following:

proc phreg data=sample plots=(cumhaz);
class group;
model time2event*censor(1)=group;
baseline /rowid=cohort;
run;

I used cumhaz since we are plotting a failure plot. Please correct me if this is wrong.

 

My main problem is that this code only plots group 2. I checked the output data generated from this code and it also only shows data for group 2. How can the groups be showed in the same graph?

 

Thank you.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

Hello,

 

Yes , they follow the same pattern.
All lines (groups) can only go up (or stay flat). Because it's cumulative.

 

The cumulative hazard function and the survival function have a simple monotonic relationship, such that when the Survival function is at its maximum at the beginning of analysis time, the cumulative hazard function is at its minimum. As time progresses, the Survival function proceeds towards it minimum, while the cumulative hazard function proceeds to its maximum. 

 

The cumulative hazard is the negative log of the survival probabilities, i.e. H(t)=−log(S(t)).

 

See here :

INTRODUCTION TO SURVIVAL ANALYSIS IN SAS

https://stats.oarc.ucla.edu/sas/seminars/sas-survival/

 

You can also calculate the cumulative hazard function using PROC LIFETEST. You don't need a Cox regression for it.

 

BR, Koen

View solution in original post

8 REPLIES 8
sbxkoenk
SAS Super FREQ

Dear @ANKH1 ,

 

With respect to your PROC PHREG ...


I think you need to use the BASELINE statement and COVARIATES= option/data set to explicitly identify the two individual CLASS levels for plotting.

Here is a blurb from the PHREG documentation that explains why you are only getting one curve for the reference level of the CLASS variable:

"If the COVARIATES= data set is not specified, a reference set of covariates that consists of the reference levels for the CLASS variables and the average values for the continuous variables is used. For plotting more than one curve, you can use the OVERLAY= global-plot-option to group the curves in separate plots."

This is from the PLOTS= option documentation found here:
SAS/STAT 15.3 User's Guide
The PHREG Procedure
PROC PHREG Statement
Plots= option
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_syntax01.htm#statug.ph...


So, if you create a COVARIATES= data set with the two class levels and the appropriate BASELINE statement I think you should get what you want.

data covars;
 input plt_catg @@;
datalines;
1 2
;
run;

/* And here's the BASELINE statement you then need in PROC PHREG */
         BASELINE COVARIATES=covars / ROWID=plt_catg;


I don't think you absolutely need the ROWID option on the BASELINE statement but it doesn't look like it would hurt from reading the doc. on the BASELINE statement.

 

Koen

ANKH1
Pyrite | Level 9

Hi, thank you for looking into this. I ran the following code:

data cov;
input group @@;
datalines;
1 2
;
run;

proc phreg data=sample plots(overlay)=(cumhaz);
model timee2event*censor(1)=group / rl;
assess ph/resample;
baseline covariates=cov;
run;

This is the graph. But I don't understand why they are exactly the same. Could you please advice?

plot1.jpg

sbxkoenk
SAS Super FREQ

@ANKH1 wrote:

This is the graph. But I don't understand why they are exactly the same. Could you please advice?


To me the 2 lines (one for each group) are NOT the same.
Why do you think so?
They are not on top of each other.

Koen

ANKH1
Pyrite | Level 9

Sorry, I meant to say why do they follow the same pattern? Or could you please interpret these lines? I am new at assessing the results of Cox models.

sbxkoenk
SAS Super FREQ

Hello,

 

Yes , they follow the same pattern.
All lines (groups) can only go up (or stay flat). Because it's cumulative.

 

The cumulative hazard function and the survival function have a simple monotonic relationship, such that when the Survival function is at its maximum at the beginning of analysis time, the cumulative hazard function is at its minimum. As time progresses, the Survival function proceeds towards it minimum, while the cumulative hazard function proceeds to its maximum. 

 

The cumulative hazard is the negative log of the survival probabilities, i.e. H(t)=−log(S(t)).

 

See here :

INTRODUCTION TO SURVIVAL ANALYSIS IN SAS

https://stats.oarc.ucla.edu/sas/seminars/sas-survival/

 

You can also calculate the cumulative hazard function using PROC LIFETEST. You don't need a Cox regression for it.

 

BR, Koen

ANKH1
Pyrite | Level 9

Thank you! This is very helpful.

OsoGris
SAS Employee

Because you don't have a COVARIATES= option/data set you are getting the default behavior in the BASELINE statement of producing only the reference level of group.  You need to define a COVARIATES= option/data set where you specify both groups.   See the example in the documentation titled "Survival Curves" for an example of using the COVARIATES= option.  I think you would also need to use the CUMHAZ= keyword on the BASELINE statement.  

ANKH1
Pyrite | Level 9

Thank you! The example helped. I don't understand why the two lines are the same. Tried adding cumhaz in the baseline statement but it marked error. Could you please provide how should this be added in the statement?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 1054 views
  • 0 likes
  • 3 in conversation