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
looping regressions with different interaction terms each timeDear all, I am still a Stata novice and first post on statalist, I have tried to follow all rules, …
Creating new variable with countsI'm using a dataset with 6 variables measuring different complications a participant could have had.…
String variable with nonnumeric and numeric categoriesI have a string variable with 3 categories (0,1,NA). I would like to desiring the variable, and chan…
Latent Class Analysis - Is it possible to run ANOVA or Chi-test in STATA after LCA?Hi everyone, I have been trying to conduct an ANOVA or Chi-test to examine whether certain variable…
looping regressions with different interaction terms each timeDear all, I am still a Stata novice and first post on statalist, I have tried to follow all rules, …
Subscribe to:
Post Comments (Atom)
0 Response to Selecting variables based on the value of another variable
Post a Comment