Hello,
I am working with a dataset of healthcare system and need to determine the days until death for each patient. The variables Start and End are Stata's date variables, Id identify the patient and Death say if the patient was death or not.
I'm trying to create variable named "Gap" like the following example. If it's possible, when the patient will still alive until the end of dataset (like Id 3 in the example) calculate the gap as the subtraction of last day for dataset and "start".
Thanks to you all!
I am working with a dataset of healthcare system and need to determine the days until death for each patient. The variables Start and End are Stata's date variables, Id identify the patient and Death say if the patient was death or not.
I'm trying to create variable named "Gap" like the following example. If it's possible, when the patient will still alive until the end of dataset (like Id 3 in the example) calculate the gap as the subtraction of last day for dataset and "start".
Id | Death | Start | End | Gap |
1 | 0 | 21236 | 21239 | 34 |
1 | 0 | 21250 | 21255 | 20 |
1 | 1 | 21260 | 21270 | 10 |
2 | 0 | 21240 | 21241 | 35 |
2 | 1 | 21270 | 21275 | 5 |
3 | 0 | 21250 | 21270 | . |
3 | 0 | 21310 | 21311 | . |
Comment