I am cleaning survey data where I want to code a string variable (x) to a numerical variable (y). For example, I want to replace y == 1 if the x variable contains certain strings like: "fgh", "f g h", "pdr" etc. Instead of using the pipe "|", in the code below, I was wondering if I could code this more efficiently?
Many thanks,
Mihir
Code:
replace y = 1 if strpos(lower(x), "fgh") > 0 | strpos(lower(x), "f g h") >0 | strpos(lower(x), "pdr") > 0
Mihir
Comment