BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

Hi,

I performed Cox-PH model to assess the survival of patients deceased at hospital by few categorical variables. Now I'd like to assess the length of stay at hospital among patients by the same categorical variables who are released from hospital and still staying at hospital (isolated). So this switches the gear to a right-censored data and I'm trying to understand how to define the censoring in data step and proc phreg?  I calculated the length of stay as shown below for both status of patients: isolated at hospital and released from hospital.

data length_stay; set have; 
if state='released' then do;
length_stay=released_date-confirmed_date; end;
if state='isolated' then do;  
length_stay=22004-confirmed_date; end; 
miss_length=length_stay=.;  
if length_stay in (. -1 -7) then delete;  
run; 

Table below shows the range of the length of stay of patients in the data. 

length_stay.png

So now, what is the censoring variable for the length of stay in terms of defining in a datastep? which is the equivalent of vital_status that I used in the survival analysis for the deceased patients? And how this changes the components of my proc phreg? 

 

proc phreg data=length_stay;
class sex1(ref='1') agel(ref='2') comorb(ref='0')/
param=ref order=internal;
model length_stay*'WHAT IS HERE?'= sex1 comorb agel/ties=Efron rl;
run;

Thank you for your time indeed.

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

@Cruise wrote:
1. Would you agree if I use today's date as a censoring date for the patients still at hospital?

If you do your analysis "today" and you know "today's" status of the patients, then this should be fine. For a Cox PH model the addition of a constant amount of time to all survival times is irrelevant.

 

2. Should I include patients deceased at hospital in the length of stay analysis.

Yes, I would include them because they contribute relevant information. Also, when you apply the results of your analysis to future patients, you cannot know in advance if they will die during their stay at hospital.

 

If I leave them in the data I will use the date of death as the end of their stay at hospital. I suspect deceased patients are different from the rest in terms of the categorical variables I will have in the model: age, gender and co-morbidity status.

I would rather treat deceased patients as censored at their date of death. Otherwise, factors increasing the hazard of death (such as severe comorbidities) and factors increasing the "hazard" of discharge (like no comorbidities) would be mixed up in the model. (See also Analysis of Competing-Risks Data.)

View solution in original post

6 REPLIES 6
Cruise
Ammonite | Level 13

@Reeza

@FreelanceReinh 

@SteveDenham Please take a look. 

 

https://communities.sas.com/t5/Statistical-Procedures/Continous-outcome-variable-and-Categorical-ind...

 

In this blog, Steve suggested Cox proportional hazards regression, with time to exit from hospital as a left-truncated/right censored variable, and fit it as in Example 73.3 Modeling with Categorical Predictors in the SAS/STAT13.2 documentation for PROC PHREG. But I'm still trying to understand what is and how to create a censoring variable in the context of a length of stay at hospital. 

FreelanceReinh
Jade | Level 19

Hi @Cruise,

 

As a start, I would define

status=(state='released');

and use in the PROC PHREG step

model length_stay*status(0) = ...
Cruise
Ammonite | Level 13
Thanks for the starting point. I greatly appreciate it. Variable state has there levels: isolated(still at hospital), released and deceased at hospital. 1. Would you agree if I use today's date as a censoring date for the patients still at hospital? 2. Should I include patients deceased at hospital in the length of stay analysis. If I leave them in the data I will use the date of death as the end of their stay at hospital. I suspect deceased patients are different from the rest in terms of the categorical variables I will have in the model: age, gender and co-morbidity status.
FreelanceReinh
Jade | Level 19

@Cruise wrote:
1. Would you agree if I use today's date as a censoring date for the patients still at hospital?

If you do your analysis "today" and you know "today's" status of the patients, then this should be fine. For a Cox PH model the addition of a constant amount of time to all survival times is irrelevant.

 

2. Should I include patients deceased at hospital in the length of stay analysis.

Yes, I would include them because they contribute relevant information. Also, when you apply the results of your analysis to future patients, you cannot know in advance if they will die during their stay at hospital.

 

If I leave them in the data I will use the date of death as the end of their stay at hospital. I suspect deceased patients are different from the rest in terms of the categorical variables I will have in the model: age, gender and co-morbidity status.

I would rather treat deceased patients as censored at their date of death. Otherwise, factors increasing the hazard of death (such as severe comorbidities) and factors increasing the "hazard" of discharge (like no comorbidities) would be mixed up in the model. (See also Analysis of Competing-Risks Data.)

Cruise
Ammonite | Level 13
Thanks for the resource. Treating deceased patients as censored at their date of death means that treating the censoring indicator as: status=(state in ('released', 'deceased');
Am I getting it right, you think?
FreelanceReinh
Jade | Level 19

@Cruise wrote:
Treating deceased patients as censored at their date of death means that treating the censoring indicator as: status=(state in ('released', 'deceased');

No, this would treat them as not censored. There's no need to modify the definition of status I suggested earlier. Both 'isolated' and 'deceased' cases will then get status=0, which means 'censored', as desired.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 950 views
  • 3 likes
  • 2 in conversation