Announcement

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

  • How to select observations from a data set sharing certain characteristics

    Hello everybody!
    I am using STATA 14.2 for Mac. I have about 3,000 observations and I would like to select only those that have at least 3 characteristics in common. My study has to do with older people and problems they face with activities of daily living. I have inserted below a simplified table of my data. The various problems are coded as '0' (no problem) and '1' (with problem). What is the code for selecting only those people that are facing three and more problems (in my example, it should be observations 2,4, and 5)? Thank you very much! My problem might seem easy but I have been looking everywhere and wasn't able to find the answer!

    ID Problem eating Problem bathing Problem shopping Problem dressing Problem going out
    1 0 0 1 1 0
    2 1 1 0 1 1
    3 1 0 0 1 0
    4 1 1 1 0 1
    5 0 1 1 1 0
    3000 0 1 0 0 0


  • #2
    Possibly this is what you are looking for:
    Code:
    egen pr_total = rowtotal(pr_eat pr_bath pr_shop pr_dress pr_goout)
    next you can select them, like
    Code:
    whatever if pr_total>=3
    http://publicationslist.org/eric.melse

    Comment


    • #3
      Hello Eric!

      Thank you very much for your reply.
      I tried the first command and I got an error message "variable pr_eat not found", so then I took the "pr_" out and it worked. Then, however, with the second command, I got the message "command whatever is unrecognized"....

      Comment


      • #4
        Eric really didn't mean that you should type whatever as such; he meant <whatever command you have in mind goes here>.

        Comment


        • #5
          Hahaha! Thanks, Nick! I feel particularly bright today!

          OK, I think I got it to work!!!


          Comment

          Working...
          X