Hello everyone,
I have two dummy variables ger1 and ger2.
Essentially what I need to do is to create another binary variable (named here dummy) in which, for every "group" of observations in which ger1=1, if it has at least one observation where ger2=1, then dummy=1 for the entire group.
Sorry if this is confusing, I include a data sample hoping it helps clarify this a bit.
("dummy" in this case, was done by hand, it is what I want it to look like - and what I need your help with to learn how to code it).
I'm using Stata 14.1 on Mac.
If anyone has any insight on how to do this, it would be much appreciated.
Thanks in advance,
Ana
I have two dummy variables ger1 and ger2.
Essentially what I need to do is to create another binary variable (named here dummy) in which, for every "group" of observations in which ger1=1, if it has at least one observation where ger2=1, then dummy=1 for the entire group.
Sorry if this is confusing, I include a data sample hoping it helps clarify this a bit.
("dummy" in this case, was done by hand, it is what I want it to look like - and what I need your help with to learn how to code it).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ger1 ger2 dummy) 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 end
If anyone has any insight on how to do this, it would be much appreciated.
Thanks in advance,
Ana
Comment