Hi All,
Suppose I have a set of variables {x1, x2, x3, x4, x5, x6, x7, x8...}. I would like to generate a new variable that takes a value of 1 if x1=1 or if x2 =1 or if x3=1 etc...
I have been doing this crudely by:
gen newvar = 0
replace newvar = 1 if x1==1 | x2==1 | x2==1 etc...
I presume there is a tidier way of doing this? Any help is much appreciated.
Suppose I have a set of variables {x1, x2, x3, x4, x5, x6, x7, x8...}. I would like to generate a new variable that takes a value of 1 if x1=1 or if x2 =1 or if x3=1 etc...
I have been doing this crudely by:
gen newvar = 0
replace newvar = 1 if x1==1 | x2==1 | x2==1 etc...
I presume there is a tidier way of doing this? Any help is much appreciated.