Wednesday, October 16, 2019

Splitting up gen OK=1 if ... into several expressions

Hi,
I try to run the following command
gen OK=1 if strpos( name, "one") >0 | strpos( name, "two") >0 | strpos( name, "three") >0 | .... | strpos( name, "fourhundred") >0 | strpos( name, "fourhundredone") >0
The problem is that I get the error message "too many literals" and I wonder how I can shorten & split up this command.

The goal is to keep only those with a OK value (I believe one could formulate this somehow as 'keep if strpos( name, "one") >0 ....' too but that's the same problem.

If there's a similar thread, I apologies.

No comments:

Post a Comment