Hello,
I need to determine cases where two surgeons worked in the same room on a specific day. For example, in the data below, you'll see that both Dr. Devin and Dr. Monchak worked in Room 6 on date 22831. However, Dr. DeJean worked only in room 2 on that day. I need to create two seperate datasets. One includes only cases like Dr. DeJean where he worked in OR 2 only. The other dataset would include all of Dr. Monchacks (even when he worked in room5) and all of Dr. Devin''s cases - all cases where two surgeons shared a room. I grouped the date of service and room together. I was hoping I could use something like gen tagger=1 if Group==Group[_n-1] & PhysName!=PhysName[_n-1]. I would then use bysort Group: egen tokeep=max(tagger==1). Unfortunately, I seem to be missing cases and I relaize it's not the best way to go about this. Loops have always confused me - even after wathcing youtube videos and reviewing the stata manual. Any help would be amazing.
Thank you!
input float Group int DOS str24 PhysName str16 Room
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Devin, Kate D" "OR 6"
I need to determine cases where two surgeons worked in the same room on a specific day. For example, in the data below, you'll see that both Dr. Devin and Dr. Monchak worked in Room 6 on date 22831. However, Dr. DeJean worked only in room 2 on that day. I need to create two seperate datasets. One includes only cases like Dr. DeJean where he worked in OR 2 only. The other dataset would include all of Dr. Monchacks (even when he worked in room5) and all of Dr. Devin''s cases - all cases where two surgeons shared a room. I grouped the date of service and room together. I was hoping I could use something like gen tagger=1 if Group==Group[_n-1] & PhysName!=PhysName[_n-1]. I would then use bysort Group: egen tokeep=max(tagger==1). Unfortunately, I seem to be missing cases and I relaize it's not the best way to go about this. Loops have always confused me - even after wathcing youtube videos and reviewing the stata manual. Any help would be amazing.
Thank you!
input float Group int DOS str24 PhysName str16 Room
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
5 22831 "DeJean John" "OR 2"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
6 22831 "Monchack, Kevin P" "OR 5"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Monchack, Kevin P" "OR 6"
7 22831 "Devin, Kate D" "OR 6"
Comment