Announcement

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

  • How to create a depression score

    I need to create a variable for major depression using 8 items (D1, D2, D3, D4, D5, D6, D7, D8) coded 0-3. Major depression requires the first two variables (D1 and D2) to have values 2 and/or 3 and at least 5 of the other variables (D3-D8) to have values 2 and 3. Can you please show me a code for this?

  • #2
    The first two conditions are

    Code:
    inlist(D1, 2, 3) & inlist(D2, 2, 3)
    The third condition can be approached via

    Code:
    egen third = anycount(D3-D8), values(2 3)
    so all can then be put together in a logical expression for an indicator variable

    Code:
    gen major = inlist(D1, 2, 3) & inlist(D2, 2, 3)  & third >= 5
    NB typo egen for gen fixed in EDIT.
    Last edited by Nick Cox; 09 Oct 2018, 12:39.

    Comment


    • #3
      Thank you, Nick! My Stata is showing:

      command inlist is unrecognized.

      What does it mean?

      Comment


      • #4
        The first piece of code is just part of a statement. It won't work by itself. You need to use the second and third lines.

        Comment


        • #5
          clarified by Nick and so I deleted my comment

          Comment


          • #6
            OK. For generic advice see 1.4 and 1.5 at https://www.statalist.org/forums/help#adviceextras

            Comment

            Working...
            X