Hi!
I have a dataset on admissions (50.000+ observations). As patient information was entered for every ward they have visited during their admission, I reshaped data in wide format because I just want to know date of arrival and discharge and not the “in-betweens”.
As some will have had 1 shift during admissions and others 10 I’m running this command to get the correct discharge date:
.gen dateoutend = .
.replace dateoutend= dateout1 if dateout1 !=.
.replace dateoutend= dateout2 if dateout2 !=.
.replace dateoutend= dateout3 if dateout3 !=.
…. And so on .. (I only have 6 this time but sometimes 27)
I thought this would work:
.replace dateoutend = dateout1-6 if dateout1-6 != .
but it returns an incorrect date
Is there any shortcut to these commands so I don’t have to write “dateout1” “dateout2” ect. Obs. Stata has to run the command in the correct order from 1-x.
Regards Lykke (ps - my first entry
- great forum)
I have a dataset on admissions (50.000+ observations). As patient information was entered for every ward they have visited during their admission, I reshaped data in wide format because I just want to know date of arrival and discharge and not the “in-betweens”.
As some will have had 1 shift during admissions and others 10 I’m running this command to get the correct discharge date:
.gen dateoutend = .
.replace dateoutend= dateout1 if dateout1 !=.
.replace dateoutend= dateout2 if dateout2 !=.
.replace dateoutend= dateout3 if dateout3 !=.
…. And so on .. (I only have 6 this time but sometimes 27)
I thought this would work:
.replace dateoutend = dateout1-6 if dateout1-6 != .
but it returns an incorrect date
Is there any shortcut to these commands so I don’t have to write “dateout1” “dateout2” ect. Obs. Stata has to run the command in the correct order from 1-x.
Regards Lykke (ps - my first entry

Comment