Announcement

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

  • Changing data from persons to teams

    Hi all,

    I have to do something that I have never done before and I didn't find any info online, so I am trying luck here. Basically, I have a dataset composed of individuals. I will paste an example, as I believe it is easier to explain:
    Person Team Year Score
    1 A 2000 3
    2 B 2001 2
    1 B 2000 3
    3 A 2000 4
    1 A 2001 2
    In essence, I have a (very disorganized, sorry) list of people who belong to different teams (they can belong to more than 1 team simultaneously, as person 1 in 2000), and in each year these persons have a score.
    Each team is composed of a number of individuals that is not fixed (for instance, some teams will have 3 people, others 5, others 10...).

    My goal is to end up with team-level data, so that each team will have 1 observation per year, and the variable "score" will measure the average score of all team members (tricky, because as I said before, the number of individuals in each team is random, and I do not have a variable that indicates the number of individuals in each team).

    The end result should be something like this (1 observation per team and year, and I do not care about the individuals anymore):
    Team Year Average_score
    A 2000 3.5
    A 2001 3
    A 2002 5
    B 2000 2
    B 2001 3
    B 2002 4
    How should I proceed to do this?

    Thank you very much, any help is greatly appreciated.

    Best,

    Carla

  • #2
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte person str1 team int year byte score
    1 "A" 2000 3
    2 "B" 2001 2
    1 "B" 2000 3
    3 "A" 2000 4
    1 "A" 2001 2
    end
    collapse (mean) score, by(team year)
    list, clean
    Code:
    . list, clean
    
           team   year   score  
      1.      A   2000     3.5  
      2.      A   2001       2  
      3.      B   2000       3  
      4.      B   2001       2

    Comment


    • #3
      Thank you so much!

      Comment

      Working...
      X