Announcement

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

  • Sum of several dummy variables

    Hello!
    I want to create a new variable that sums all of this dummy variables
    Code:
     
     Rsuppdoc Rsuppleg Rsuppjob Rsuppaprt Rsupphealth Rsuppeduc Rsuppeduc2 RsuppAT Rsuppfood Rsupppsyc
    They are simple dummy variables that take the value of 1 if "yes" and 0 otherwise.

    The code I wrote to achieve my goal was:
    Code:
    egen sumsupp = rowtotal(Rsuppdoc Rsuppleg Rsuppjob Rsuppaprt Rsupphealth Rsuppeduc Rsuppeduc2 RsuppAT Rsuppfood Rsupppsyc)
    Nevertheless the new variable "sumsupp" is giving me values from 0-8 instead of being a dummy variable (1 or 0) or is it ok the way I´m doing?

    Code:
    tab sumsupp
    
        sumsupp |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              0 |        459       56.04       56.04
              1 |        174       21.25       77.29
              2 |         81        9.89       87.18
              3 |         52        6.35       93.53
              4 |         29        3.54       97.07
              5 |         16        1.95       99.02
              6 |          6        0.73       99.76
              7 |          1        0.12       99.88
              8 |          1        0.12      100.00
    ------------+-----------------------------------
          Total |        819      100.00
    Thank you! Have a great year!

  • #2
    Indeed, in principle the total of 8 dummy (indicator) variables, each (0, 1). can run from 0 to 8.

    Why do you expect a result of 0 or 1? You can get a row minimum for all of the variables being 1 and a row maximum for any of the variables being 1

    Comment

    Working...
    X