Dear all,

I am using Stata 15 and for my panel data I have director IDs (Director_ID) and the CEO ID (CEO_ID) on a firm level for each firm and year.
I concatenated a dyad between the CEO ID and the director ID for each firm year observation (dyadCEOdirector). Then I concatenated the dyad the other way around with the director ID first and followed by the CEO ID (dyaddirectorCEO).
I would like to identify how often a director ID and CEO ID dyad (dyaddirectorCEO) appears within all values of the variable "dyadCEOdirector".
After identifying all the cases in which a certain dyad appears in both variables, I would like to sum up how often a certain dyad appears over all firms and years.


My data looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex

*dataex year Director_ID CEO_ID dyadCEOdirector dyaddirectorCEO in 1/10

clear
input float year long Director_ID float CEO_ID str14(dyadCEOdirector dyaddirectorCEO)
2011   17041 17041 "1704117041"   "1704117041"  
2011  106615 17041 "17041106615"  "10661517041" 
2011   36237 17041 "1704136237"   "3623717041"  
2011 1047705 17041 "170411047705" "104770517041"
2011   36235 17041 "1704136235"   "3623517041"  
2011  205747 17041 "17041205747"  "20574717041" 
2011  832497 17041 "17041832497"  "83249717041" 
2011  210009 17041 "17041210009"  "21000917041" 
2011   36232 17041 "1704136232"   "3623217041"  
2011   81697 17041 "1704181697"   "8169717041"  
end
I have not been able to figure out how to identify these cases in which a certain dyad appears in both variables and how to sum up its occurrence in the "dyaddirectorCEO". Any thoughts you have are much appreciated.

Thanks in advance.

Best,

Ina