Hello,

I am trying to calculate
sumi(xi*zj) where
xi = a dummy
zj = a dummy xi is connected to in firm j

I have panel data with company IDs and individual IDs (mulitlevel) and years as identifiers. I basically want to calculate the sum of individuals in company i who are connected to other companies j with certain characteristics. However, this characteristic is also present in the focal company i - and I struggle to correct for it.

Here is what I tried so far:

Code:
gen Dummy1=1 if var1>0 & var1=.  // firm characteristic I am interested in
gen xi = 1 if var2==5 // individuals I am looking at
gen product=xi*Dummy1 //individuals connected to firm chatacteristic
egen sum_xizj=sum(product), by(compid year)  // sum of inidivudals connected to firm characteristic, but this includes also the focal firm characteristic

I would be grateful for any comments on this!

Thank you