Announcement

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

  • Creating New Data Column

    Hello,
    I am working in Stata and I have 3 variables, teacherid, yearexp, action. teacherid is a unique number assigned to each teacher, this number is repeated through the data as it is associated to students and there are several students with the same teacher. yearexp refers to the teacher's years teaching and is numeric. action is either "1" for if the teacher assigned a discipline to the student or "2" if the teacher did not assign a discipline to the student. I would like to combine the data so that I can look at all of the teacherid for the same yearexp are combined to see how many "actions" (disciplines) they assigned for that year. Can anyone help me do this?

  • #2
    It is not clear if you want to count actions by yearexp including all actions from all teacherid - so you will get one count for each value of yearexp - or if you want to count actions by yearexp separately for each teacherid.

    Comment


    • #3
      If teacherid and yearexp are the same, then I want to add all of the actions together. this would reduce my observations so that each teacherid only appears once

      Comment


      • #4
        Perhaps this will start you in a useful direction.
        Code:
        generate count = action==1
        collapse (sum) count, by(teacherid yearexp)

        Comment


        • #5
          That kinda worked, it just didn't add them together. But got me thinking....Thanks!

          Comment


          • #6
            Nevermind, that DID work!

            Comment

            Working...
            X