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]
st: Collapse an unbalanced panel with annual entries into a standard 5-year average dataset
From
Mads Knudsen <[email protected]>
To
[email protected]
Subject
st: Collapse an unbalanced panel with annual entries into a standard 5-year average dataset
Date
Sat, 11 Aug 2012 15:29:28 +0200
Dear stata experts,
Here comes a rookie question which I haven't been able to find an answer
for in the forum so far (please excuse me if I have overlooked the obvious
answer):
What I want to do is the quite standard operation of calculating 5-year and
3-year means by country id. I believe that Jeanty's module "paverage" does
the job if one has a balanced panel dataset. However it does not seem to
work for my unbalanced panel.
To illustrate:
I have a data set of this kind (an unbalanced panel in long format):
Country Year GDP POP
AFG 1950 2 6
AFG 1951 7
AFG 1952 2 4
AFG 1953 2 3
AFG 1954 6 6
AFG 1955 4 7
ALB 1950 9 9
ALB 1951 8 6
ALB 1952 10
ALB 1953 12 3
ALB 1954 13 2
ALB 1955 5
which I would like to (easily) transform into a calculated dataset of
the following kind:
country period GDP3yrav POP3yrav
AFG 1950-52 2 5,666667
AFG 1953-55 4 5,333333
ALB 1950-52 9 7,5
ALB 1953-55 12,5 3,333333
Any help would be highly appreciated. Thank you for your consideration!
Kind regards,
Mads Knudsen
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/