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, statalist.org is already up and running.


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

RE: st: RE: 5 year panels


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: 5 year panels
Date   Thu, 5 May 2011 15:31:20 +0100

Something like 

keep if inrange(year, 1977,2004) 
gen quin = ceil((y - 1976)/5)

foreach v of var <whatever> { 
	egen mean_`v' = mean(`v'), by(country quin)
}

??? 

Or -collapse- ? 

Nick 
n.j.cox@durham.ac.uk 

lreine ycenna

(1) I've tried the method you suggested, however I have panel data
from 1970-2006 covering 50 countries, the 5-year panels are only
needed from 1977-2004. e.g. 1977-2004, 1982-1986, with 2002-2004 being
the only 3-year panel. So anything before 1977 and after 2004 will
need to be deleted.

(2) Then I will also need to average my other variables and place them
into the 5-year panel slots accordingly. How do I do that?

(3) I might have to delete some rows (years) later on. But since I
have to do this for 50 countries, is there any shortcut for this?

On 5 May 2011 10:54, Nick Cox <n.j.cox@durham.ac.uk> wrote:

> You can get five year groups by e.g.
>
> gen quinquennium  = 5 * floor(year/5)
>
> Put extra constants in the expression for other starts.

lreine ycenna

> What's the command I should use to arrange my yearly data into 5 year panels?
> (Stata 11.0)

*
*   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/


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