# AW: st: Fixing the value in egen command

 From "Martin Weiss" To Subject AW: st: Fixing the value in egen command Date Wed, 11 Feb 2009 14:36:11 +0100

```<>

Try
http://www.stata.com/support/faqs/data/missing.html
http://www.stata.com/support/faqs/data/dropmiss.html

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Tanveer Shehzad
Gesendet: Mittwoch, 11. Februar 2009 14:22
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: Fixing the value in egen command

Dear Statalisters:

Some time back, I asked in a panel data if I want to generate a
variable which takes the value equal to the mean of GDP I use the command

by country year, sort : egen float abxx = mean(GDP)

I wanted to make another variable that contains initial value of GDP
fixed (for all years) equal to e.g. value of GDP in year 1885
corresponding to each country. The solution for this modification suggested
by Maarten and Blasnik worked well for the problem.

Now I face a a bit different but related problem. If e.g. the value of
1885 (as in the above question) is missing for one country then it will
take the initial value equal to zero for all other years.

Now my problem is:  I have something like 10,000 banks and I need to
take their initial level of assets (the first available value and not
corresponding to a fixed year). Could their be any solution?

I would be really thankful for the solution.

Best regards, Tanveer

Maarten buis wrote:
>
>> Now I want to make another variable that contains initial value of
>> GDP fixed (for all years) equal to e.g. value of GDP in year 1885
>> corresponding to each country.
>>
>
> bys country (year): gen initgdp = gdp[_n==1]
> bys country (year): replace initgdp = sum(initgdp)
>
> Hope this helps,
> Maarten
>
>
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
>
> Buitenveldertselaan 3 (Metropolitan), room N515
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

--
PhD Student
Department of Finance,
University of Groningen,
Nettelbosje 2
9747 AE Groningen
The Netherlands
Mobile: 0031-644801970

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```