Hi everyone,
I am studying hospital readmissions and would like to know the number of days that pass between hospitalizations. For each row, I have the patients ID, a unique ID for the hospitalization (admission ID), date of admission, and date of discharge. For each admission ID, I would like to know the date of their last discharge. From there, I can create a new variable to calculate number of days between last discharge and current admission date.
Is there a way to create a variable that would pull in discharge dates from other rows in the data set?
Here is an example with the new variable I would like to create in blue.
Appreciate your help!
I am studying hospital readmissions and would like to know the number of days that pass between hospitalizations. For each row, I have the patients ID, a unique ID for the hospitalization (admission ID), date of admission, and date of discharge. For each admission ID, I would like to know the date of their last discharge. From there, I can create a new variable to calculate number of days between last discharge and current admission date.
Is there a way to create a variable that would pull in discharge dates from other rows in the data set?
Here is an example with the new variable I would like to create in blue.
| Patient ID | Admission ID | Admit Date | Discharge Date | New var: last discharge date |
| 12345 | 135 | 1/1/2010 | 1/30/2010 | . |
| 12345 | 234 | 2/5/2010 | 2/12/2010 | 1/30/2010 |
| 12345 | 333 | 5/2/2010 | 5/28/2010 | 2/12/2010 |
| 999 | 196 | 11/6/2007 | 11/7/2007 | . |
| 999 | 247 | 12/1/2007 | 12/4/2007 | 11/7/2007 |
Appreciate your help!

Comment