I am not well versed in Stata, and I am struggling to find the right syntax to generate a new variable based on the properties of several other variables.
I have one dummy variable indicating sex (Sex_at_birth
), and 3 dummy variables indicating sexual orientation (isHE
, isBI
, isHO
). I want to create 3 dummy variables indicating sexual preferences (likesMEN
, likesWOMEN
, likesBOTH
).
An example logical statement I'd like to use would be:
likesMEN = 1 if ((Sex_at_birth = 1) & (isHE = 1)) | ((Sex_at_birth = 0) & (isHO = 1)),
else likesMEN =0
It would be analogous for the other variables.
I am at loss on how to code it in Stata, and I believe it will be like 2 seconds for someone who knows the program well.
Note: I know that I need n-1
number of dummy variables to code a variable that has 3 categories, and I will have that in mind when conducting analyses. However for my dataset I want to have all of the categories dummy coded (so I can chose which one to omit for my analyses).