Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Panel Data 5 Year Average
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Panel Data 5 Year Average
Date
Tue, 7 Jan 2014 17:28:38 +0000
. gen years = 1 + 5 * floor((year - 1)/5)
. collapse y5=y l5=l, by(country years)
. l
+---------------------------------+
| country years y5 l5 |
|---------------------------------|
1. | 1 1981 22.6 8.92 |
2. | 1 1986 24.2 9.46 |
3. | 1 1991 26.6 9.98 |
4. | 1 1996 28.4 10.48 |
5. | 1 2001 30.6 10.98 |
|---------------------------------|
6. | 2 1976 .233 .09 |
7. | 2 1981 .2354 .0906 |
8. | 2 1986 .2426 .0962 |
9. | 2 1991 .2466 .1102 |
10. | 2 1996 .2506 .1216 |
|---------------------------------|
11. | 2 2001 .2546 .1308 |
12. | 2 2006 0 0 |
+---------------------------------+
Nick
[email protected]
On 7 January 2014 17:05, Muhammad Ramzan <[email protected]> wrote:
> I am working on a panel data having time series from 1981 to 2005.
> and no of countries are 120.
> I have to take a 5 year average of data for each variable.
> like shown below
>
> the original data is
> country year y l
> 1 1981 22 8.7
> 1 1982 22 8.8
> 1 1983 23 8.9
> 1 1984 23 9
> 1 1985 23 9.2
> 1 1986 23 9.3
> 1 1987 24 9.3
> 1 1988 24 9.5
> 1 1989 25 9.5
> 1 1990 25 9.7
> 1 1991 26 9.8
> 1 1992 26 9.9
> 1 1993 27 10
> 1 1994 27 10.1
> 1 1995 27 10.1
> 1 1996 28 10.3
> 1 1997 28 10.4
> 1 1998 28 10.5
> 1 1999 29 10.5
> 1 2000 29 10.7
> 1 2001 30 10.8
> 1 2002 30 10.8
> 1 2003 31 11
> 1 2004 31 11.1
> 1 2005 31 11.2
> 2 1980 0.233 0.09
> 2 1981 0.234 0.091
> 2 1982 0.235 0.09
> 2 1983 0.236 0.091
> 2 1984 0.236 0.091
> 2 1985 0.236 0.09
> 2 1986 0.24 0.091
> 2 1987 0.241 0.093
> 2 1988 0.243 0.096
> 2 1989 0.244 0.099
> 2 1990 0.245 0.102
> 2 1991 0.245 0.104
> 2 1992 0.246 0.108
> 2 1993 0.246 0.111
> 2 1994 0.249 0.113
> 2 1995 0.247 0.115
> 2 1996 0.248 0.118
> 2 1997 0.251 0.12
> 2 1998 0.251 0.121
> 2 1999 0.251 0.124
> 2 2000 0.252 0.125
> 2 2001 0.252 0.127
> 2 2002 0.253 0.129
> 2 2003 0.256 0.131
> 2 2004 0.255 0.133
> 2 2005 0.257 0.134
> 2 2006 0 0
>
>
> what I want is
>
> years y5 I5
> 1981-85 22.6 8.92
> 1986-90 24.2 9.46
> 1991-95 26.6 9.98
> 1996-2000 28.4 10.48
> 2001-2005 30.6 10.98
> 1981-85 0.2354 0.0906
> 1986-90 0.2426 0.0962
> 1991-95 0.2466 0.1102
> 1996-2000 0.2506 0.1216
> 2001-2005 0.2546 0.1308
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/