Hi everyone,
Is there a way to drop certain observations if they match one of the elements in a local?
I have a few hospital names that I have defined in my local using
(I've just mentioned two hospitals here; in reality, I have 60 hospitals I want to include in the local. The hospital names are strings with spaces in between words.)
In my dataset, I have a variable HospitalName, which has an exhaustive list of 700 hospitals in the country. The local 'sample' is a subset of that. I want Stata to keep only the observations where HospitalName matches one of the names from the local. Could some please advise how to do this? From searching, it seems as if I may need a combination of levelsof + inlist + keep if, but I haven't been able to figure out the code for this.
Thanks very much in advance!
Harshita
Is there a way to drop certain observations if they match one of the elements in a local?
I have a few hospital names that I have defined in my local using
Code:
#delim local sample `" "St Peters Hospital" "Mission Hospital" "'; #delim cr
In my dataset, I have a variable HospitalName, which has an exhaustive list of 700 hospitals in the country. The local 'sample' is a subset of that. I want Stata to keep only the observations where HospitalName matches one of the names from the local. Could some please advise how to do this? From searching, it seems as if I may need a combination of levelsof + inlist + keep if, but I haven't been able to figure out the code for this.
Thanks very much in advance!
Harshita

Comment