Hi,
I imagine this question has already been answered but I cannot seem to find it. I want to figure out the number of teachers who taught a given course in a school and district. I have tried various different options, but none give me what I am looking for. Here is what I have tried:

egen N_Tpercourse = count(staffid), bysort (leanumber schoolnumber coursecode) /// this option counts the total number of times the staffid appears.
egen N_Tpercourse = gropu (staffid leanumber schoolnumber coursecode)

I have tried other things but none seem to do what I want them to do. Any suggestions? Or can you point me to where this question has already been answered? Thanks in advance.