I have data that are long. I would like to generate a new variable that takes on the value of a separate variable is.
This is what my data look like:
classroomid |
score |
subject |
13425 |
5.166667 |
3 = science |
13425 |
5.055555 |
1 = language |
13425 |
5.472222 |
2 = math |
13425 |
5.777778 |
6 = other |
This is what I would like my data to look like. Essentially, if the subject is language, I want to “newscore” to take on the value of science’s score. I want all other subjects to have the same score otherwise.
classroomid |
score |
subject |
newscore |
13425 |
5.166667 |
3 = science |
5.166667 |
13425 |
5.055555 |
1 = language |
5.166667 |
13425 |
5.472222 |
2 = math |
5.472222 |
13425 |
5.777778 |
6 = other |
5.777778 |
0 Response to generate a new variable that takes on the value of a separate variable
Post a Comment