Hey there,
I'm a student working with Stata and have a data set that contains a variable associated with countries denoting their GDP from last year. However, I need the data to denote this year's GDP. If I "by country: gen GDP = gdplag[_n+1]" and then "drop if GDP == ." It successfully moves all gdplag observations one year to give me GDP while dropping the observations that don't have a gdplag. So I'm almost there. The problem is some of the years in the data set are nonconsecutive. For example, I have the years 1993, 1994, 1996, and 1997. Years 1993 and 1996 end up with accurate GDPs because I can obtain them from the gdplag of 1994 and 1997 respectively. Further, the GDP observation for 1997 is dropped since I don't have gdplag for 1998. However, the gdplag for 1996 becomes the GDP for 1994 when it is actually the GDP for 1995. Is it possible to make sure that gdplag is moved to correspond with the appropriate year? This is my best guess but I get an invalid syntax (r198) error: "by country: gen GDP = gdplag[_n+1] if year[_n] - year[_n-1] = 1"
Related Posts with Dropping Variables Based on Other Variable, Student Project
Panel Data StandardizationHello, I want to standardize my independent variable before running the regression. I have a panel …
Power, graph delta as vertical axis but as a share of baseline take-up rateI am running power calculations and I'm graphing the output with the delta on the vertical axis. C…
Control number of bins in binscatterI generate a binscatter using Code: sysuse auto, clear binscatter price mpg, nq(100) rd(30) line(no…
invalid numlist has missing values Error in forestplotHi, Recently, when I use metan or admetan on aggregated data, there is always an error with the fore…
Generating time series of (quarter) date variables for the period between two date variables: beginning and end of ownershipHi, I would much appreciate your assistance with the below question. Please, I have data set that …
Subscribe to:
Post Comments (Atom)
0 Response to Dropping Variables Based on Other Variable, Student Project
Post a Comment