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
Related Posts with Selecting variables based on the value of another variable
Open password protected ".dta" file (I have the password)Dear All, I have received data files (.dta) which is protected with a password (I have the password…
Possible bug in -bootstrap-Currently, I only have access to Stata 11 to 14. In these releases, there appears to be a bug in boo…
Problem with betamixI am having a problem with betamix. Our dependent variable has a distribution whose characteristics …
Dealing with zero valuesHello, I am working on the effect of social transfers (pensions and other social benefits) on middle…
Collapsing survival dataDear all, I have a very big data set with a survival structure that I want to compress/collapse. Ri…
Subscribe to:
Post Comments (Atom)
0 Response to Selecting variables based on the value of another variable
Post a Comment