Dear Stata colleaguesColleagues, I am new to Stata, and am using Stata 14. I have this kind of national data for elementary schools. I want to use the egen function to calculate repetition rate where grade4enrol is denominator and grade4repeaters is numerator. Since this data is for elementary schools in the entire country, I want to transform my numerator and denominator based on national level total enrolled and repeated for grade 4 in a particular year for a particular school. I am thinking of doing this because my dataset has big schools and small schools where repetition rate of small schools looks large because of their small enrolments. Is there a command I can use to get around this challenge?

Year school_id grade4enrol grade4repeaters
2010 500772 40 2
2010 500667 28 4
2010 500124 31 3
2011 500772 62 2
2011 500667 26 1
2011 500124 22 0
2012 500772 10 3
2012 500667 19 2
2012 500124 45 2
2013 500772 35 4
2013 500667 33 1
2013 500124 28 2
2014 500772 30 3
2014 500667 26 6
2014 500124 31 2
2015 500772 24 3
2015 500667 21 2
2015 500124 26 1