Sorry if this is really basic, but I want to flag every observation where both values 3 and 4 are contained anywhere within the variables var1-var8.
There must be a more efficient way than this:
Code:
gen flag1 = 0 foreach var of varlist var1-var8 { replace flag1 = 1 if `var' == 3 } gen flag2 = 0 foreach var of varlist var1-var8 { replace flag2 = 1 if `var' == 4 } gen flagwant = 0 replace flagwant = 1 if flag1 == 1 & flag2 == 1
Any advice much appreciated!
0 Response to multiple criteria across several variables
Post a Comment