Ammonite | Level 13

## Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

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.

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

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

@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.)

6 REPLIES 6
Ammonite | Level 13

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

@Reeza

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.

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

Hi @Cruise,

As a start, I would define

``status=(state='released');``

and use in the PROC PHREG step

``model length_stay*status(0) = ...``
Ammonite | Level 13

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

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.

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

@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.)

Ammonite | Level 13

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

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?

## Re: Fitting length of stay at hospital / right censored data to Cox PH model / proc phreg

@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.

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