# st: Re: Variable generation

 From "Roy,Suryadipta" To statalist@hsphsun2.harvard.edu Subject st: Re: Variable generation Date Thu, 14 Jun 2007 11:43:02 -0500

Hi,

I probably just sorted it out without any programming- would get beck for more help later on!

g dt=(1/dist)*exp
egen x1=sum(dt), by(octy)

Thanks anyways!

On Thu, 14 Jun 2007 11:24:33 -0500

Hi,

I have data on 5 countries (a, b, c, d, e) for octy, dcty, dist, d1, and exp. The data are given below:

octy dcty dist d1 exp x1 x2
a c 5 1 50 35 50
a d 4 0 100 35 50
b c 3 0 50 29.167 0
b d 8 0 100 29.167 0
c d 2 1 50 25 50
d c 2 1 100 50 100
e c 1 0 50 150 0
e d 1 0 100 150 0

I need to generate x1 and x2 for all countries based on the following formula:

x1 (country a)= 1/dist(a,c)*exp(c)+1/dist(a,d)*exp(d)=1/5*50+1/4*100=35.

x2 (country a)= d1(a,c)*exp(c)+d1(a,d)*exp(d)=1*50+0*100=50, and so on for all countries.

With over 200 countries, this obviously needs some programming and it would be great to get some help here.

Thanks as usual for your help!
```*