Dear list members:
I would like to learn how to generate a new variable that is the cumulative average of an existing variable in a time-series cross-section dataset. In the following example, I would like to create "cum average" of the fourth column, which is the cumulative average of the 3rd-column variable "amount." There was one thread about a cumulative average, but it didn't look like it is what I'm looking for.
I thank you in advance for your kind assistance.
Best wishes,
Taka
I would like to learn how to generate a new variable that is the cumulative average of an existing variable in a time-series cross-section dataset. In the following example, I would like to create "cum average" of the fourth column, which is the cumulative average of the 3rd-column variable "amount." There was one thread about a cumulative average, but it didn't look like it is what I'm looking for.
country id | year | amount | cum average |
1 | 1994 | 1 | 1 |
1 | 1995 | 3 | 2 |
1 | 1996 | 3 | 2.3333 |
1 | 1997 | 4 | 2.75 |
1 | 1998 | 5 | 3.2 |
2 | 1994 | 2 | 2 |
2 | 1995 | 4 | 3 |
2 | 1996 | 2 | 2.6666 |
2 | 1997 | 4 | 3 |
2 | 1998 | 2 | 2.8 |
3 | 1994 | 2 | 2 |
3 | 1995 | 1 | 1.5 |
3 | 1996 | 3 | 2 |
3 | 1997 | 4 | 2.5 |
3 | 1998 | 2 | 2.4 |
I thank you in advance for your kind assistance.
Best wishes,
Taka
Comment