Announcement

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

  • egen anycount

    I have five variables that all take on values 0, 1, or 2. I want to create a new variable that equals 1 if the five variables only take on values 0 or 1, excluding 2. What would that look like?

  • #2
    Code:
    egen wanted = rowmax(v1 v2 v3 v4 v5) 
    replace wanted = wanted <= 1

    Comment


    • #3
      Code:
      gen wanted = max(v1, v2, v3, v4, v5) <= 1
      is another way to do it.

      Comment

      Working...
      X