Hello everybody,
I think this is a quite easy question but nontheless I haven't found a solution yet.
I want to generate a variable x including several conditions. The first condition refers to a dummy variable (a) --> x=1 if a==1. the other variables contain open string answers and I want to generate x=1 if any answer for the variable is given. This means only missing values do not apply to this condition.
So far I haven't found a solution how I can "count" cells that do contain an answer.
I tried this:
gen x = 1 if a==1 | b==" " | c==" " | d==" " | e==" "
Stata gives me an error "type mismatch".
Any suggestions?
Thank you!
I think this is a quite easy question but nontheless I haven't found a solution yet.
I want to generate a variable x including several conditions. The first condition refers to a dummy variable (a) --> x=1 if a==1. the other variables contain open string answers and I want to generate x=1 if any answer for the variable is given. This means only missing values do not apply to this condition.
So far I haven't found a solution how I can "count" cells that do contain an answer.
I tried this:
gen x = 1 if a==1 | b==" " | c==" " | d==" " | e==" "
Stata gives me an error "type mismatch".
Any suggestions?
Thank you!
Comment