Announcement

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

  • Assign group ID based on variable

    Dear Statalist,

    I have a data set with two variables 'id' and 'group'. I want to assign observations with a same 'group id' if their 'group' variables are overlapping.

    In the example data below, ideally, I want all four observations receive a same 'group id'. I tried splitting out the 'group' variables and then re-arranged the data but could not manage to get what I want.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str16 id str487 group
    "A" "A,B,C"
    "B" "A,C,D"
    "C" "B,C,D"
    "D" "C,D"  
    end
    Any suggestions are appreciated.

    Thanks!

  • #2
    how would you group the following ids,
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte id str3 group
    1 "A"  
    2 "A,B"
    3 "B"  
    end

    Comment


    • #3
      Originally posted by Øyvind Snilsberg View Post
      how would you group the following ids,
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte id str3 group
      1 "A"
      2 "A,B"
      3 "B"
      end
      I would like to assign them the same group id as well.

      Comment

      Working...
      X