Hi,

I have a panel data (firm-year level). Anyone knows how to construct Peer firm average, which is the average of all firms within an industry-year combination, excluding the ith observation (excluding the focal firm and only include all the other firms in the industry)? Industries are defined by 3-digit SIC codes.

I only know how to calculate the average of all the firms in the industry. bys sic3 year: egen PeerAverage=mean(Variable).

Thanks in advance!