Announcement

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

  • Calculate standard deviation of multiple variables at once

    Hello,
    I would like to calculate the mean and the standard deviation of multiple variables at once

    I know I can use this using the sum command, but I would like to store estimated mean and SD separately to export them in a compacted way into a descriptive statistic table (I do not want to report the number of OBS and the Min and Max values I would get from using the sum command


    For instance, take the following example: I am calculating mean values for both the whole sample and foreign cars.

    Code:
    sysuse auto
    mean price mpg rep78 headroom
    eststo avgall
    mean price mpg rep78 headroom if foreign==1
    eststo avgfor
    esttab avgall avgfor ,  nostar not label b(2)
    I would like to add to this table the associated standard deviations. I tried using sd, but it is an invalid command

    Thanks a lot
    Code:
    sd price mpg rep78 headroom
    eststo sdall
    sd price mpg rep78 headroom if foreign==1
    eststo sdfor
    
    esttab avgall sdall avgfor sdfor,  nostar not label b(2)

  • #2
    Code:
    h statsby
    the last example in the help file seems directly relevant to you (just eliminate the parts you don't want); there is also the user-written command -runby-; use -search- to find and download

    Comment


    • #3
      #2 plus


      Code:
      help collapse

      Comment


      • #4
        I think this post was accidentally duplicated; other solutions are discussed at

        https://www.statalist.org/forums/for...riable-at-once

        Comment

        Working...
        X