If I want to see whether a string is in a column at the most simplest, I can do something like:

Example 1:
Code:
sysuse auto, clear
local car = "AMC Pacer"
gen x = cond(make == "`car'", 1, 0)

If I want to scale up from here I can do something like:
Example 2:
Code:
sysuse auto, clear
local car = "AMC Pacer"
gen x = cond(make == "`car'" | make == "Buick Opel", 1, 0)
but this seems obviously limited in that I need to manually specify each condition one by one. Is there any way I could evaluate multiple matches akin to example 1? Here I have in mind something like
local car = "AMC Pacer|Buick Opel" or local car = "AMC Pacer" "Buick Opel"

Is it possible to scale my macro?


I can see a way to do with a loop e.g.,
Code:
gen x = 0
foreach i in "AMC Pacer" "Buick Opel"{
replace x = 1 if make == "`i'"
}
but I am wondering if that really is the best way