I have a variable in Stata in my dataset that looks like this:
city
Washington city
Boston city
El Paso city
Nashville-Davidson metropolitan government (balance)
Lexington-Fayette urban county
And I want it to look like:
city
Washington
Boston
El Paso
Nashville-Davidson
Lexington-Fayette
"city," "county," and "urban county" are the only three words that follow after a city name. In other words, I want to extract the substring from left to the space before either city, county, or urban.
The only way I can think of approaching this using subinstring:
replace city = subinstr(city, " city", "", .)
I don't think, however, that I can add multiple options here.