Hello,
I have a wide dataset which contains the birth year of various persons as well as the GDP for various years, as in: birthyear, gdp1990, gdp1991, gdp1992...
Suppose I want to create a new variable which is the average of the gdp for the three years when a person was 8, 9 and 10 years old. I would normally use egen / rowmean, but I can't figure out a simple way to indicate to Stata which 3 variable to average (as they would differ depending on the value of birthyear).
If anyone can suggest a simple and/or elegant way to do this, I would highly appreciate it. I can only think of some very inefficient and inelegant ways of doing it.
Thanks,
'Alim
0 Response to Selecting variables based on the value of another variable
Post a Comment