Announcement

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

  • calculating mean based on multiple variables

    Hello, I have a variable year containing years 1996-2014 and a variable firm_size which can take values "Small", "Medium", "large". When I generated the average of another numerical variable markup i used this code: egen average_markup_clean = mean(markup_clean), by(year). But I know want to do this per year based on the firm_size, however by() can only contain one argument. How should I encounter this problem? Thank You in advance!

  • #2
    The premise is not correct. There is no bar to two arguments.

    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . egen mean = mean(mpg), by(foreign rep78)
    
    . tabdisp rep78 foreign, c(mean)
    
    ------------------------------
    Repair    |
    record    |     Car origin    
    1978      | Domestic   Foreign
    ----------+-------------------
            1 |       21          
            2 |   19.125          
            3 |       19  23.33333
            4 | 18.44444  24.88889
            5 |       32  26.33333
            . |    23.25        14
    ------------------------------
    
    .

    Comment

    Working...
    X