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" <>
To   <>
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
Tel: +33 1 39 67 94 42
Fax: +33 1 39 67 70 86

*   For searches and help try:

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