Announcement

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

  • Generating a variable that takes value 1 if other characteristics of other variables are fulfilled

    Hi I have to generate a dummy variable X1 that takes the value of 1 if only ONE of the dummy variables A B and C have value of 1, and a variable X2 if only TWO of the variables A B and C take value of 1. Do you know an easy way to do that? Thank you in advance.

  • #2
    Code:
    egen X= rowtotal(A B C)
    gen X1= X==1
    gen X2= X==2

    Comment

    Working...
    X