Looks like
bysort octy : egen x1 = total(tradeshare * dist)
Nick
n.j.cox@durham.ac.uk
Roy,Suryadipta
> I had posted a similar query sometime back and did not get
> any response- so probably my question was not very clear.
> Here I have modified the query and it would be extremely
> helpful to get some help. The dataset is as follows:
>
> octy dcty dist tradeshare x1
> a b 10 0.13 12.95
> a c 15 0.13 12.95
> a d 25 0.13 12.95
> b a 10 0.44 13.15
> b c 30 0.44 13.15
> b d 25 0.44 13.15
> c a 15 0.22 16.2
> c b 30 0.22 16.2
> c d 5 0.22 16.2
> d a 25 0.21 15.35
> d b 25 0.21 15.35
> d c 5 0.21 15.35
>
> Value of x1 for octy a (=12.95) has been generated by the
> formula:
> tradeshare(b)*dist(a,b)+tradeshare(c)*dist(a,c)+tradeshare(d)*
> dist(a,d).
>
> Similarly, x1 for octy b
> (=13.15)=tradeshare(a)*dist(b,a)+tradeshare(c)*dist(b,c)+trade
> share(d)*dist(b,d),
> and so on for octy c and d.
>
> I can do the above for 4 countries in Excel but with more
> than 150 countries, it gets extremely difficult. Any
> cooperation is highly appreciated.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/