Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Average of three variables with data missing


From   David K Evans <[email protected]>
To   [email protected]
Subject   Re: st: Average of three variables with data missing
Date   Tue, 9 Nov 2004 09:24:42 -0500 (EST)

Yes.

Do

egen average=rmean(var1 var2 var3)

It will take the average of all non-missing observations.
Dave

------------------------------------------------------------------------

PhD student, Harvard Economics Department
Phone: (O) 617-495-5634, (H) 617 - 493 - 1536
Address: Currier Mail Center #554, Cambridge, MA 02138

------------------------------------------------------------------------

On Tue, 9 Nov 2004, Herve STOLOWY wrote:

> Dear All:
>
> I would like to compute the average of three variables for several observations. For some of them, data is missing for one or two variables.
>
> I do:
>
> gen average=(var1+var2+var3)/3
>
> When one figure (at least) is missing, Stata returns a missing average.
>
> Is there an easy way to tell Stata to compute the average on the available data (one, two or three depending on the observations), even though some data are missing?
>
> Best regards
>
> Herv� Stolowy
>
> ***********************************************************
> HEC Paris
> D�partement Comptabilit�-Contr�le de gestion / Dept of Accounting and Management Control
> 1, rue de la Liberation
> 78351 - Jouy-en-Josas
> France
> Tel: +33 1 39 67 94 42
> Fax: +33 1 39 67 70 86
> [email protected]
> http://campus.hec.fr/profs/stolowy/perso/home.htm
>
> *
> *   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/
>
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index