Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Finding and tagging overlapping groups


From   Fredrik Wallenberg <[email protected]>
To   [email protected]
Subject   st: Finding and tagging overlapping groups
Date   Fri, 29 Jul 2005 16:09:04 -0700

This is simply a reformulation of a question I sent out yesterday (and
didn't get any responses to :) I have data sets that, when merged
produce a table with many-to-many relationships. The table below
contains the ID's from each table (Z and E)

     +----------+
     | Z     E  |
     |----------|
  1. |   a    x |
  2. |   b    x |
  3. |   b    z |
  4. |   c    y |
  5. |   d    z |
     |----------|
  6. |   e    q |
  7. |   e    z |
     +----------+

In as a base for further calculations I've created variables showing
duplicates and overlap between groups:
     +----------------------------------+
     | Z     E    zdup   edup   overlap |
     |----------------------------------|
  1. |   a    x      0      1         0 |
  2. |   b    x      1      1         1 |
  3. |   b    z      1      2         1 |
  4. |   c    y      0      0         0 |
  5. |   d    z      0      2         0 |
     |----------------------------------|
  6. |   e    q      1      0         0 |
  7. |   e    z      1      2         1 |
     +----------------------------------+



What I need to do is to create a group variable for all records that
are linked to each other through overlapping Z/E. In the example above
I would like to end up with something like:

     +------------------+
     | zip   ex   group |
     |------------------|
  1. |   a    x       1 |
  2. |   b    x       1 |
  3. |   b    z       1 |
  4. |   c    y       2 |
  5. |   d    z       1 |
     |------------------|
  6. |   e    q       1 |
  7. |   e    z       1 |
     +------------------+


I've spent several days now trying to figure out how to do that in
Stata/Filemaker/Excel and haven't solved it yet. Any help would be
most welcome!!!!

Fredrik

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index