Dear Statalist users,

I would like to ask this data management questions. For example I have individual teacher data on the schools. The schools_id variable is identifier whether it is the same school or not. We need to select/ keep observations based on teacher experience and teacher need. For example, for school_id 1 we need 3 teachers, and it should be picked by sort the highest experience to less experience teacher. So for school_id 1, we will pick up 3 teachers which is have 19, 8, and 5 years of experience.

I have 50,000 observations, and will take time if we need to specify this.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(school_id experience teacher_need)
1  2 3
1  4 3
1  5 3
1  8 3
1 19 3
2  2 2
2  5 2
2  6 2
2  7 2
2  8 2
2  9 2
end
Do you have suggestions on my cases?