Hi All,
I have data that resembles the following (it is at the individual level):
In the above, I have current year, GDP growth rate in the current year, the year an individual turns 22 as well as an individual indentifier. I wish to create another variable, GDPrate22 , which is basically the GDP rate in the year when the individual turned 22. Currently, I have done the following:
Simply, I keep only the year and GDPrate variables, and then rename year to age22. This then allows me to merge back GDPgrowth rate for when individuals are 22, as this does not vary at the individual level.
Is there a cleaner way of doing this? I feel that I am missing something doing this in this manner- in particular, when I do this for the state level (GDP growth at the state level), I get a lot of missing values in the merge.
Kind Regards,
CS
I have data that resembles the following (it is at the individual level):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(year GDPrate age22 individual) 1990 3 1982 1 1991 4 1983 2 1992 5 1990 3 1993 1 1992 4 1994 2 1993 5 1995 3 1994 6 1996 3 1995 7 1997 1 1996 8 1998 2 1997 9 1999 1 1998 10 2000 2 1999 11 end
Code:
set more off tempfile master save `master' keep year GDPrate duplicates drop rename (year GDPrate) (age22 GDPrate22) merge 1:m age22 using `master' drop _merge
Is there a cleaner way of doing this? I feel that I am missing something doing this in this manner- in particular, when I do this for the state level (GDP growth at the state level), I get a lot of missing values in the merge.
Kind Regards,
CS
Comment