Hi everyone!
I want to create a dummy variable such that it gives me 1 when either one or both of the other two dummy variables are 1. So, for example, I know that in order to get this dummy to return 1 in the hypothetical case in which I needed both these conditions to occur, I could have just written gen 18yroldMale = ((male==1) & (age==18)). So this command would generate me a variable called 18yroldMale that returns 1 in the case the individual is BOTH a male AND is 18 years old. But what if I wanted it to return 1 even in the case in which just one or both of the conditions were met (when either it's a male no matter the age, or an 18 yr old individual no matter the sex, or both)? I tried replacing the "&" with an "or", but stata gives me error in that case.
Thank you in advance! Please help
Related Posts with Creating a dummy variable with "or" condition
How to calculate Jaccard SimilarityDear Statlisters, I am trying to calculate a pairwise Jaccard similarity measure and have trouble f…
Top of the observationsHello, I need to create a top 20 of my observations, I try to use: for example tab x y, but there ar…
combine four categorical variables altogether and generate new variableDear Stata forum, I would like to calculate a median and I know that Stata provides the code for MAD…
How to graph hours worked and wage assimilation profiles for immigrants?Dear Stata Forum, I have an unbalanced panel data set with observations at the individual level. I r…
Interpretation of grand mean centered versus original form level-2 variables in multilevel logistic regressionHello, I have a random intercept multilevel logistic regression model with cross-level interactions…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a dummy variable with "or" condition
Post a Comment