Announcement

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

  • Min and Max in Sum

    Dear Stata Users,

    I am generating a table of descriptive statistics by using
    Code:
    sum
    . However, it gives me the min and max as well. How can I ask Stata not to show these two statistics? It is a requirement as I am using confidential data.

    Thank you
    JL

  • #2
    Code:
    . sysuse auto
    (1978 automobile data)
    
    . table () (), stat(mean price) stat(mean mpg) stat(mean weight) ///
    >              stat(sd price) stat(sd mpg) stat(sd weight)
    
    ------------------------------
    Mean               |          
      Price            |  6165.257
      Mileage (mpg)    |   21.2973
      Weight (lbs.)    |  3019.459
    Standard deviation |          
      Price            |  2949.496
      Mileage (mpg)    |  5.785503
      Weight (lbs.)    |  777.1936
    ------------------------------
    
    . collect layout (var) (result)
    
    Collection: Table
          Rows: var
       Columns: result
       Table 1: 3 x 2
    
    ----------------------------------------------
                  |      Mean   Standard deviation
    --------------+-------------------------------
    Price         |  6165.257             2949.496
    Mileage (mpg) |   21.2973             5.785503
    Weight (lbs.) |  3019.459             777.1936
    ----------------------------------------------
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you, Maarten,

      I tried this code
      Code:
      logout, clear excel save(first_results) replace:  stat (mean var1) stat (mean var2) stat (mean var3)   stat (sd var1) stat (sd var2) stat (sd var3)
      Stata gave me this error
      Code:
      . logout, clear excel save(first_results) replace:  stat (mean var1)
      > stat (mean var2) stat (mean var3)   stat (sd var1) stat (sd var2) s
      > tat (sd var3)
      
      command stat is unrecognized
      r(199);
      
      end of do-file
      
      r(199);
      
      .

      Comment


      • #4
        Jade:
        you inadvertertently missed the first part of Maarten's helpful code:
        Code:
         
         table () (),
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Ah right! My bad, sorry. Thank you Carlo.

          Comment

          Working...
          X