Announcement

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

  • Create new dummy variable

    Hi everyone,

    I am trying to create a new dummy variable named DIS2 which defines a participant as having 1 or more definitions of disability. In my data set there are 5 dummy variables for each definition of disability, namely:
    hearing: equal to 1 if the participant has difficulty in hearing, other equal to 0.
    visual: which is equal to 1 if the participant has difficulty seeing, the other is equal to 0.
    speaking: equal to 1 if the participant has difficulty in speaking, others equal to 0.
    physical: equal to 1 if the participant has physical limitations, others equal to 0.
    mental: which is equal to 1 if the participant has mental limitations, others equal to 0.

    For example, if a participant has difficulty in speaking and listening, then in DIS2 it will be equal to 1. On the other hand, it will be equal to 0 when the participant only has 1 type of disability.
    Any ideas? Thanks in advance!

  • #2
    you did not provide a data example (please use -dataex-; read the FAQ to find out more) but you probably want the -egen- command with the "anyvalue" function; see
    Code:
    help egen

    Comment


    • #3
      Consider

      Code:
      gen dis = hearing + visual + speaking + physical + mental
      It sounds as if you want

      Code:
      gen multdis = dis > 1 if dis < .
      which will be 1 if dis is 2 or more and 0 if dis is 0 or 1 and missing if dis is missing.

      If you want missing values to be treated differently, you may want to work with

      Code:
      egen dis2 = rowtotal(hearing  visual speaking  physical  mental)
      which will ignore missings.

      Comment

      Working...
      X