I need to code a new variable 0 or 1 depending on the value of a string variable. The following seems to work:
gen notcountry=0
foreach nonc in "AFW" "ARB" "AFE" {
replace notcountry=1 if (cid3==nonc)
}
However, I have several dozen values in addition to AFW, ARB, AFE. I can cut and past them from a Word doc but adding the parens is tedious. Is ther some obvious shortcut I'm missing?
Thanks as always--this has been a great community for years.
gen notcountry=0
foreach nonc in "AFW" "ARB" "AFE" {
replace notcountry=1 if (cid3==nonc)
}
However, I have several dozen values in addition to AFW, ARB, AFE. I can cut and past them from a Word doc but adding the parens is tedious. Is ther some obvious shortcut I'm missing?
Thanks as always--this has been a great community for years.
Comment