I have dataset with a variable (refvar) that references, as values, the names of other variables in the dataset. I wish to generate a new variable (newvar) that outputs the value of the variable being referenced. As an example:
Not sure how to go about creating newvar.
obs | aaa | bbb | ccc | ddd | eee | refvar | newvar |
1 | 9 | 5 | 4.3 | 6 | 7 | bbb | 5 |
2 | 1 | 7 | 1 | 1 | 6 | ccc | 1 |
3 | 6.8 | 2 | 7 | 3 | 4 | aaa | 6.8 |
4 | 1 | 1 | 9 | 5 | 2 | bbb | 1 |
Comment