Announcement

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

  • Using "table" to produce summary statistics over non-mutually exclusive sets

    I'm trying to produce a publication-ready table of summary statistics over non-mutually exclusive sets of observations using the "table" command, where the set identifiers would be spread across the columns of the table, and the variables/summary statistics spread across the rows.

    For example, I might want to take the following results:

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . table (var) (foreign[1]) , stat(mean price mpg trunk) stat(sd price mpg trunk)
    
    -----------------------------------
                          |  Car origin
                          |     Foreign
    ----------------------+------------
    Price                 |            
      Mean                |    6384.682
      Standard deviation  |    2621.915
    Mileage (mpg)         |            
      Mean                |    24.77273
      Standard deviation  |    6.611187
    Trunk space (cu. ft.) |            
      Mean                |    11.40909
      Standard deviation  |    3.216906
    -----------------------------------
    
    . table (var) (rep78[5]) , stat(mean price mpg trunk) stat(sd price mpg trunk)
    
    -------------------------------------------
                          |  Repair record 1978
                          |                   5
    ----------------------+--------------------
    Price                 |                    
      Mean                |                5913
      Standard deviation  |            2615.763
    Mileage (mpg)         |                    
      Mean                |            27.36364
      Standard deviation  |            8.732385
    Trunk space (cu. ft.) |                    
      Mean                |            11.45455
      Standard deviation  |             2.65946
    -------------------------------------------
    And combine them into a single table like so:

    Code:
    ------------------------------------------------------------
                          |Repair record 1978         Car origin
                          |                 5            Foreign
    ----------------------+-------------------------------------            
    Price                 |                  
      Mean                |              5913           6384.682
      Standard deviation  |          2615.763           2621.915
    Mileage (mpg)         |                         
      Mean                |           27.3636           24.77273
      Standard deviation  |          8.732385           6.611187
    Trunk space (cu. ft.) |                                 
      Mean                |          11.45455           11.40909
      Standard deviation  |           2.65946           3.216906
    ------------------------------------------------------------
    Thoughts or suggestions?
Working...
X