Announcement

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

  • Create table with certain characteristics

    Hi all,
    I'm working with a dataset that resembles the following:
    ID Year HP_Measure Industry
    01 2001 0.021 151
    02 2003 0.034 153
    03 2002 0.045 155
    04 2004 0.161 151
    ... ... ... ...
    ... ... ... ...

    Where I have industries spanning from 151 to 159, and years spanning from 2001 to 2004 (there can be different observations in the same year for every industry).

    I was wondering if there is a way to obtain a table similar to the following:
    Industry 2001 2002 2003 2004
    151 0.095 0.064 0.248 0.0454
    152 ... ... ... ...
    ... ... ... ... ....

    Where the entries for each industry/year couplet are the average of the corresponding HP measures (for each industry and year).

    I tried to use collapse (mean) by Industry, but unfortunately it gives me the average for each industry only, without separating between different years.
    Do you have any suggestions?

    Thanks in advance for your help.


  • #2
    In version 17, this could be

    Code:
    table Industry Year, stat(mean HP_measure)
    In version 16 and back some way stat() should be c()

    You shouldn't be surprised at what happened with collapse, but by(Industry Year) would get you nearer.

    Comment

    Working...
    X