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
Creating a new set with every possible pair within a groupDear all, I would like to create a new dataset that includes all possible pairs of observations, wi…
Export matrix to Word with asdocx after the predict commandProf River Huang asked the following question Dear Attaullah, Is it possible to put the results …
Manipulating local listsIn my code below I expected to get a local macro (myvars2) with a list of all my variables (which ar…
Need help with creating certain variablesHi. EmpCode OfficeCode Year Sept_30 In Out Existing 1 11 2011-12 . . 1 12 2011-12 1 . 1 . …
Can the attenuation bias of a demeaned dependent variable be solved by an control function approach?I recently demeaned my dependent variable by a group interaction. Mainly because simply adding them …
Subscribe to:
Post Comments (Atom)
0 Response to Selecting variables based on the value of another variable
Post a Comment