by i s3,sort:egen cv=total(v)
by i,sort:egen tcv=total(v)
by s3,sort: egen iv=total(v)
egen tv=total(v)
gen rca=(cv/tcv)/(iv/tv)
gen w=cv/tcv
duplicates drop i s3 ,force
gen csi=rca*ppp
by s3,sort:egen tsi=total(csi)
gen e=w*tsi
by i sj,sort:egen te=total(e)
duplicates drop i sj,force
仅供参考(s3为sitc三位码,sj为sitc1位码,i为出口国)