Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: replacing with mean
From
Fabio Zona <[email protected]>
To
[email protected]
Subject
Re: st: replacing with mean
Date
Thu, 2 Dec 2010 07:39:04 +0100 (CET)
I apologize: I forgot to mention that I have multiple variables at the same time, that is, for example, Revenues, Income, Assets... and I have to do the same for each variable..!
----- Messaggio originale -----
Da: "Michael N. Mitchell" <[email protected]>
A: [email protected]
Inviato: Giovedì, 2 dicembre 2010 7:36:23 GMT +01:00 Amsterdam/Berlino/Berna/Roma/Stoccolma/Vienna
Oggetto: Re: st: replacing with mean
Dear Fabio
Will this do the trick?
egen missrev = mean(revenues), by(industry)
replace revenues = missrev if missing(revenues)
Best regards,
Michael N. Mitchell
Data Management Using Stata - http://www.stata.com/bookstore/dmus.html
A Visual Guide to Stata Graphics - http://www.stata.com/bookstore/vgsg.html
Stata tidbit of the week - http://www.MichaelNormanMitchell.com
On 2010-12-01 10.31 PM, Fabio Zona wrote:
> Hi,
>
> I have a set of industries, with a different number of firms in each industry; per each firm I have a value, say it be Revenues
>
> Industry Firm Revenues
> A 1 100
> A 2 150
> A 3 missing1
> A 4 120
> B 5 80
> B 6 130
> B 7 missing2
> ..
>
> I need to replace the missing value of Revenues with the mean of the Revenues within the same industries (For example, missing1 for firm 3, needs to be replaced with the mean of the values 100, 150, 120, that is, with the mean of the revenues of other firms 1, 2 and 4 which belong to the same industry to which firm 3 belongs).
> I need to do this hundreds of time.
> How can I do it easily?
> *
> * 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/
*
* 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/