Hello everybody.
I have a problem when I try to reshape my dataset. My has informations about high-school grades, but because some students have taken one or more classes again, across a school-year, I can get my dataset reshaped because my year-variabel is not uniquely identified with the students id-number (pnr). In almost all cases it only concerns one class that the student have taken again in another year. so if I could just delete the class-grade that has been taken in a different year in comparison to the students other grades that would be fine. Perhaps my example below can do some explaining:
ID year Class1 Class2 Class3
1 2000 . A .
1 2000 A . .
1 2003 A
2 2001 A . .
2 2005 . A .
2 2001 . . A
3 2000 A . .
3 2000 . A .
3 2000
4 2003 . A .
4 2003 A . .
4 2008 . . A
As you can see the problem arise for student nr. 1, 2 and 4, but not for studen 3. And problem is that when I try to reshape from long to wide, the year-variabel has to be uniquely identified with the ID. I want a dataset one student observation (ID) in the long form, and then one grade per one class in the wide form. But I still want the year-variabel to be a part of the dataset, so the year obiously need to be consistent within the student-ID.
Can anyone help me out with an idea? Or just show me how I can delete the year observation (per student) that does not equal the other year-observations for that student?
Kind regards
Jonas
I have a problem when I try to reshape my dataset. My has informations about high-school grades, but because some students have taken one or more classes again, across a school-year, I can get my dataset reshaped because my year-variabel is not uniquely identified with the students id-number (pnr). In almost all cases it only concerns one class that the student have taken again in another year. so if I could just delete the class-grade that has been taken in a different year in comparison to the students other grades that would be fine. Perhaps my example below can do some explaining:
ID year Class1 Class2 Class3
1 2000 . A .
1 2000 A . .
1 2003 A
2 2001 A . .
2 2005 . A .
2 2001 . . A
3 2000 A . .
3 2000 . A .
3 2000
4 2003 . A .
4 2003 A . .
4 2008 . . A
As you can see the problem arise for student nr. 1, 2 and 4, but not for studen 3. And problem is that when I try to reshape from long to wide, the year-variabel has to be uniquely identified with the ID. I want a dataset one student observation (ID) in the long form, and then one grade per one class in the wide form. But I still want the year-variabel to be a part of the dataset, so the year obiously need to be consistent within the student-ID.
Can anyone help me out with an idea? Or just show me how I can delete the year observation (per student) that does not equal the other year-observations for that student?
Kind regards
Jonas
Comment