Announcement

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

  • About calculating the average value for unbalanced panel dataset with long type

    Hello there,

    Since I am dealing with the unbalanced panel data which has been shown as below with an example:
    year age gvkey
    1996 66 1075
    1996 53 1075
    1996 65 1075
    1996 52 1075
    1996 53 1075
    1996 62 1075
    1996 61 1075
    1996 50 1075
    1996 57 1075
    1996 68 1075
    1997 48 1075
    1997 53 1075
    1997 46 1075
    1997 67 1075
    1997 66 1075
    1997 69 1075
    1997 54 1075
    1997 58 1075
    1997 54 1075
    1997 51 1075
    2001 61 1177
    2001 56 1177
    2001 66 1177
    2001 66 1177
    2001 68 1177
    2001 58 1177
    2001 54 1177
    2001 65 1177
    2001 69 1177
    2001 59 1177
    2001 55 1177
    2001 64 1177
    1996 64 1300
    1996 58 1300
    1996 61 1300
    1996 67 1300
    1996 61 1300
    1996 65 1300
    1996 55 1300
    1996 64 1300
    1996 49 1300
    1996 62 1300
    1996 44 1300
    1996 60 1300
    where "year" is the fiscal year, "age" is for firm directors' age, "gvkey" is the unique firm identifier.

    I would like to calculate the average (mean) value for the directors' age within one firm based on a specific year, for example, the average value for directors' age of firm 1075 in year 1996 is 58.7. That is all I need. However, I have a huge sample, and therefore would be great if any statalist could help me in dealing with such problem.

    Your help will be much appreciated.

    Thanks!

  • #2
    bysort year gvkey: egen avgage=mean(age)

    should do it.

    Comment


    • #3
      Many thanks, that is really helpful.

      Comment

      Working...
      X