Hi all,
I am working with panel data, students nested in classes. I want to cluster on class.
Since I am interesting in certain effects measured on the class level, I want to take into account the students who stayed together in the same class in both year 1 and 2.
There are two ID variables, classyear_1 and classyear_2. But the problem is that values in year 1 and year 2 have completely different ranges. See an example of how it looks below. As you can see there have been quite some students who switched class between year 1 and 2. That's okay, but I want to at least have the students that were in the same class for both years have the same values in a new variable.
I think I'll have to do something with foreach, and then get the mimumum/maximum for each classyear_1, but I don't exactly know what I should do.
I hope maybe someone could help me. Thanks in advance!
I am working with panel data, students nested in classes. I want to cluster on class.
Since I am interesting in certain effects measured on the class level, I want to take into account the students who stayed together in the same class in both year 1 and 2.
There are two ID variables, classyear_1 and classyear_2. But the problem is that values in year 1 and year 2 have completely different ranges. See an example of how it looks below. As you can see there have been quite some students who switched class between year 1 and 2. That's okay, but I want to at least have the students that were in the same class for both years have the same values in a new variable.
I think I'll have to do something with foreach, and then get the mimumum/maximum for each classyear_1, but I don't exactly know what I should do.
I hope maybe someone could help me. Thanks in advance!
| id | classyear_1 | classyear_2 |
| 1 | 1 | 434 |
| 2 | 1 | 436 |
| 3 | 1 | 436 |
| 4 | 1 | 437 |
| 5 | 1 | 437 |
| 6 | 2 | 436 |
| 7 | 2 | 437 |
| 8 | 2 | 437 |
| 9 | 6 | 332 |
| 10 | 6 | 332 |
| 11 | 7 | 332 |
| 12 | 8 | 331 |
| 13 | 8 | 331 |
| 14 | 8 | 334 |

Comment