Announcement

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

  • how to calculate the standard deviation for many variables in STATA

    Dear all,
    I am trying to calculate the standard deviation for 14 variables ( Q1, Q2,,Q14) and I use this command:
    egen CFV_STD=sd inrange(Q1:Q14) but it is not working.
    would anyone know the correct code in this case?

    thank you so much for your help in advance.

  • #2
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    
    . tabstat price-foreign, s(sd) c(s)
    
        Variable |        SD
    -------------+----------
           price |  2949.496
             mpg |  5.785503
           rep78 |  .9899323
        headroom |  .8459948
           trunk |  4.277404
          weight |  777.1936
          length |  22.26634
            turn |  4.399354
    displacement |  91.83722
      gear_ratio |  .4562871
         foreign |  .4601885
    ------------------------
    
    . d
    
    Contains data from C:\Program Files\Stata17\ado\base/a/auto.dta
     Observations:            74                  1978 automobile data
        Variables:            12                  13 Apr 2020 17:45
                                                  (_dta has notes)
    ---------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    ---------------------------------------------------------------------------------
    make            str18   %-18s                 Make and model
    price           int     %8.0gc                Price
    mpg             int     %8.0g                 Mileage (mpg)
    rep78           int     %8.0g                 Repair record 1978
    headroom        float   %6.1f                 Headroom (in.)
    trunk           int     %8.0g                 Trunk space (cu. ft.)
    weight          int     %8.0gc                Weight (lbs.)
    length          int     %8.0g                 Length (in.)
    turn            int     %8.0g                 Turn circle (ft.)
    displacement    int     %8.0g                 Displacement (cu. in.)
    gear_ratio      float   %6.2f                 Gear ratio
    foreign         byte    %8.0g      origin     Car origin
    ----------------------------------------------------------

    Comment


    • #3
      Thanks Nick for your response but I need to create a variable that calculates the standard deviation of all variables ( Q1,Q2,Q3,Q4,until q14) because the standard deviation variable will be used to calculate another variable. Thank you

      Comment


      • #4
        This question was also asked and answered here: #7

        Comment

        Working...
        X