Hi there - probably an easy question for most of you, but I'm new to STATA and can't find the answer to this.
I am trying to create a new variable "ethnicity_Hisp" by searching seven other variables (ethnicity1; ethnicity2; etc) for the string "Hispanic or Latino".
I've tried to do this a couple different ways - shortened to just two variables here for simplicity:
gen variable ethnicity_Hisp=1 if ethnicity1 == "Hispanic or Latino" | ethnicity2 == "Hispanic or Latino"
gen variable ethnicity_Hisp=1 if strpos(ethnicity1, "Hispanic or Latino) | strpos(ethnicity2, "Hispanic or Latino"
I keep getting back "too many variables"
Is there a way to do this without a multistep code where I generate the variable and then replace with 1 for each of the ethnicity variables?
Thanks!
Related Posts with Creating variable from searching multiple strings
ttest code multiple variables that define groupHello. I cant seem to work out the coding that replicates the following function, which when copied …
OLS vs logistic regression*Hello, I was hoping someone could clarify this for me. I have used OLS regressions using the PISA d…
Effect of varying number of integration points on model fit for melogitHi everyone, I am using meologit to fit a model to individual binary outcome data from a cluster ra…
How to perform an equivalence test (based on a t-test) for regression coefficients?Hi, How do I perform an equivalence test (based on a t-test) for regression coefficients in STATA? …
The problem with rcallThe package rcall is great! But when I start, I encounter a problem. When I transfor a scalar to R, …
Subscribe to:
Post Comments (Atom)
0 Response to Creating variable from searching multiple strings
Post a Comment