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: Maximum value for a variable
From
Oliver Jones <[email protected]>
To
[email protected]
Subject
Re: st: Maximum value for a variable
Date
Tue, 22 Mar 2011 18:33:10 +0100
Oh, sorry with `ayear' I meant either `to_year' or `from_year'.
Am 22.03.2011 18:29, schrieb Nick Cox:
Note that even in principle the code here will probably not work.
Unless a local macro `ayear' has been defined, the second time around the loop the
-egen- call will fail as the variable to be created already exists.
I agree with Oliver that -rolling- (or as said -mvsumm- from SSC) is a better idea.
Nick
[email protected]
Oliver Jones
maybe you could also try something manual like:
sort country year
forvalues to_year = 1999/2010{
local from_year = `to_year' - 14
by country year: egen max_growth`ayear' = max(gdp_growth) ///
if year> `from_year'& year< `to_year'
}
But I guess rolling is more convenient...
Am 22.03.2011 18:13, schrieb ajjee:
I have a panel dataset over the period 1960-2010 for 30 countries. I want to
compute the maximum value for a variable over the last 15 years for each
country. For example, for Austria, I want to compute the max of gdp growth
from 1984-1999 for the year 1999 and 1985-2000 for the year 2000 and so on.
*
* 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/
--
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
- - -
Bielefeld University
Faculty of Business Administration and Economics
Chair of Econometrics and Statistics
- - -
Raum / room: V9-110
Tel / phone: +49 (0)521 106 4871
--
*
* 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/