Dear,

I have a question regarding creating dummy variables. With the data below as an example, I want to create a dummy that is 1 if within a group of the same CUSIP, there is at least one gender dummy = 1. That is, the newly created dummy is 1 if a company has at least one female (gender=1). How would I go about this?


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long gender str12 CUSIP
0 "000000000"
0 "000000000"
0 "000000000"
0 "000000000"
0 "000000000"
0 "000000000"
0 "000000000"
1 "000000000"
0 "000000000"
0 "000000000"
0 "000000000"
1 "000000000"
0 "000000000"
0 "000000000"
1 "000000000"
1 "000000000"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
1 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
1 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
0 "000360206"
1 "000360206"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
0 "000361105"
end
label values gender gender
label def gender 1 "Yes", modify