Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: calculating average in Stata

From   James Bernard <>
Subject   st: calculating average in Stata
Date   Wed, 6 Mar 2013 14:17:05 +0800

Hi all,

I am trying to calculate average of observations for a variable. This
is a panel data... grouped by firms observed over 20 years.

Now, I want to calculate average of past three years of a variable to
construct a new variable.

Firm                  Year                sales
--------           ------------              --------------
A                 1990                    100
A                  1991                    missing
A                  1992                    200
A                  1993
A                   1994
A                   1995

So i would like to create a new average_3_sales variable that take in
year 1993 the average of sales observation from year 1990 to 1992....
What Stata does is that it simply returns missing as 1991 observation
is missing. Is there any solution to this?

In my research it would be more reasonable to ignore the missing value
and calculate average of 100 and 200 which is 150. so the value of the
new variable would be 150 for year 1993.

I appreciate your help in advance

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index