stata排除自身计算的行业均值

by time industry : egen total_x=total(x)
by time industry : egen number=count(x)
gen xx=total_x-x
gen mean_x=xx/(number-1)

x可替换为目标变量名