I have a dataset where the variable ID identifies a patient. Each patient has multiple rows of observations corresponding to the medical service they used.
Example dataset
PT_ID proc
1 medication
1 surgery
1 ward
2 ICU
2 x-ray
2 ward
3 doctor fee
3 facility
3 ICU
I want to list ALL the observations corresponding to a patient who was say admitted in ICU. In the above example, I want to filter the data such that I get all observations for patient 2 and 3 (row 4-9). If I say br if proc=="ICU", I can filter only row 4 and 9. It seems like there should be a simple command to do this yet not able to figure out. Appreciate any help.
Thanks!
Example dataset
PT_ID proc
1 medication
1 surgery
1 ward
2 ICU
2 x-ray
2 ward
3 doctor fee
3 facility
3 ICU
I want to list ALL the observations corresponding to a patient who was say admitted in ICU. In the above example, I want to filter the data such that I get all observations for patient 2 and 3 (row 4-9). If I say br if proc=="ICU", I can filter only row 4 and 9. It seems like there should be a simple command to do this yet not able to figure out. Appreciate any help.
Thanks!
Comment