Hi,
I am relatively new to Stata and would appreciate some help writing a few lines of code to solve a problem with my data.
I have a database of students' grades from many different schools.
Each observation has the following relevant variables:
Each school has many different exams, subjects and students.
Each observation receives the same grade as all other observations with the same Year, Exam_id and School. In other words, the grade is a class average, and is not unique to each student.
In some years new Exam_ids were introduced and replaced old exam_ids. In these observations, I would like to do the following:
I have tried various approaches and sorting methods but have yet to find a solution for this problem.
Thank you very much.
I am relatively new to Stata and would appreciate some help writing a few lines of code to solve a problem with my data.
I have a database of students' grades from many different schools.
Each observation has the following relevant variables:
- School_id
- Student_id
- Year
- Subject_id
- Exam_id
- Exam_units (1-5)
- New_exam (binary variable, 1 if the Exam_id is new in the given school, and didn't feature in previous years)
- Grade
|
Each observation receives the same grade as all other observations with the same Year, Exam_id and School. In other words, the grade is a class average, and is not unique to each student.
In some years new Exam_ids were introduced and replaced old exam_ids. In these observations, I would like to do the following:
- Create a binary variable sameunits, which equals 1 if the new Exam_id switched a different Exam_id in a given school in the previous year that had the same Subject_id and same Exam_units. For example: if in 1995 school no. 72 taught exam no. 82 which was a 5 unit exam in subject "Math", and in 1996, the following year, the exam_id in the school was changed (indicated by new_exam==1), so that the exam_id now equals 91 but the subject is still "Math", the variable sameunits in relevant observations in 1996 would equal 1.
- In these cases, I would like to switch the grade in exam 91 in year t (for example in school_id 72 in year1996) with the class-wide grade from the old Exam_id (82) in year t-1, again only if the unit number is equal for both (5, in this case).
I have tried various approaches and sorting methods but have yet to find a solution for this problem.
Thank you very much.
Comment