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
Interpretation of logistic regression of categorical variables with interactionGood morning! I am using a statewide dataset of adult inpatients with COVID-19 (n=18k+) to assess ra…
Replace Values by previous valuesDear all, I am a bit stuck. I have household and personal id date for 8 rounds, however not each pe…
Retrieving data from online archive database and making it ready for STATA (CEDA Archive database) THERE MUST BE SOMEONE HERE WHO IS ABLE TO DO THIS Hi everyone, I'm in a bit of a pickle. I have …
Minimum wage as state level controlHello stata community, For my research, I'm working with IPUMS CPS data and would like to see how w…
Selecting certain observations for a graphHello, I have made a multilevel model for which I want to plot the effects of one of the levels, wh…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a dummy variable with "or" condition
Post a Comment