Dear all,

I am new to STATA and tried to calculate a measure that captures the ownership concentration within a given industry. I have also posted the equation of the MHHI below. My file contains data from the respective firms and the investors from 2000 to 2019. I am struggling to implement a code that considers all the other investor's ownership if the investor is invested in its competitors too...
  • sj is the market share of firm j
  • gammaij is the control share of firm j by shareholder i
  • betaij is the ownership share of firm j
  • betaik indexes firm j's competitors
Here is an exemplary sample of my database:
  • mgrno= unique identification number of the shareholder
  • Cusip= unique identification number of the firm
  • consownership=ownership share
  • instvoting=control share
datemerge mgrname mgrno cusip consownership instvoting marketshare
2016q4 Investor 1 47833 0790X10 10% 10% 30%
2016q4 Investor 2 10177 0790X10 15% 12% 30%
2016q4 Investor 3 11800 0790X10 13% 13% 30%
2016q4 Investor 4 54345 0790X10 12% 10% 30%
2016q4 Investor 1 47833 7089W10 10% 10% 40%
2016q4 Investor 2 10177 7089W10 15% 12% 40%
2016q4 Investor 3 11800 7089W10 13% 13% 40%
2016q4 Investor 4 54345 7089W10 12% 12% 40%
2016q4 Investor 1 47833 14744810 10% 10% 30%
2016q4 Investor 2 10177 14744810 15% 15% 30%
2016q4 Investor 3 11800 14744810 13% 10% 30%
2016q4 Investor 4 54345 14744810 12% 10% 30%
I would be grateful for any help on this, and I hope fellow researchers consider this a useful post!

Thank you,
Thomas