Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Counting unique ID who taught a course in a given district and school

    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.

  • #2
    Maybe this, presuming you want to create a variable to track this count, for each combination of the variables leanumber schoolnumber coursecode
    Code:
    egen byte tag = tag(leanumber schoolnumber coursecode staffid)
    egen N_Tpercourse = total(tag), by(leanumber schoolnumber coursecode)
    If not, you may need to specify more carefully what you'd like, as well as supply a data example using dataex.

    Comment


    • #3
      Thank you Hemanshu, that did what I wanted it to do. I appreciate the help.

      Comment

      Working...
      X