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
Who do people rescale a weight variable?Dear all, I have a question on rescaling/transforming a variable, particularly a weight variable. I…
Help with xtdpdsys commandDear Statalist members, I have been trying to implement xtdpdsys in my paper. However, based on my …
Wald test: the whole interaction not significant but one level is signficantDear all, I am computing a multinomial logit on two outcomes (Marriage, Dissolution vs a reference …
Append multiple files in StataHi there! I have multiple .txt files which I would like to append. The "append/insheet" command does…
Peer firm averageHi, I have a panel data (firm-year level). Anyone knows how to construct Peer firm average, which i…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a dummy variable with "or" condition
Post a Comment