D Harwood <[email protected]>:
Take the double quotes off =="`var'" is the short answer--you can't
compare a number to a quoted string.
But are you sure you want the avg change computed over all years (i.e.
the trend, not the annual GDP growth rates)?
And there is no need to generate yearcounter that I can see...
On Mon, Jul 21, 2008 at 10:41 AM, D Harwood <[email protected]> wrote:
Dear All,
I was wondering if anyone knew how to compute GDP growth rates by country. I
have panel data arranged as follows:
Country Year GDP ($ 2000)
Benin 1997 1947193088
Benin 1998 2035610240
Benin 1999 2131227520
Benin 2000 2254838784
Benin 2001 2367580672
Benin 2002 2474121728
Benin 2003 2570612480
Benin 2004 2650301440
Benin 2005 2727160320
.
.
.
And so on for a number of countries. Arranged by country code and by year.
I found an example in the archives of how to calculate the growth rates
(http://www.stata.com/statalist/archive/2006-05/msg00529.html) and yet when
I try to do the same I get an error message 'Type mismatch', no matter which
variable type I enter. I typed the following into the command box and came
out with the output shown.
. egen minyearbycountry = min(year), by(code)
r; t=0.00 15:30:23
. gen yearcounter = year-minyearbycountry
r; t=0.01 15:30:31
. gen g = .
(288 missing values generated)
r; t=0.00 15:30:39
. levelsof code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32
r; t=0.01 15:30:48
. foreach var in `r(levels)' {
2. reg lnGDP yearcounter if code =="`var'"
3. replace g = _b[yearcounter] if code =="`var'"
4. }
type mismatch
r(109); t=26.93 15:31:23
I would be grateful if anyone could point out where I have gone wrong?
Regards,
Dave
*
* 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/