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

st: Average of three variables with data missing


From   "Herve STOLOWY" <[email protected]>
To   <[email protected]>
Subject   st: Average of three variables with data missing
Date   Tue, 09 Nov 2004 15:20:08 +0100

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/



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