|
|
9#

楼主 |
发表于 2010-7-21 23:00:35
|
只看该作者
Re: 请教高手:多列带有重复的ID合并成一列
to gzgoon
this can be solved using hash list while your obs are index by the four IDs SEPARATELY.
by OP's description, as searching goes on, any subsequent observation that has 2 IDs in the current combination of id pool will be identified as belonging to the same group, then any new ID will be added to the pool. The main hash table contains the record number which is the unqiue ID for each obs, and the other elements in the hash is an 5 auxilary hash lists, 4 for id pool of each ID# while the last auxilary hash list contains all related records
for example, for first record, I search by index on ID1 and find record #2, by examination, it satisfies the criteria, so all the IDs are added to the first auxilary hash list while _n_=2 is also added to the second auxilary hash list. Now our ID pool has a set of ID1={1,2}, ID2={11, 12}, ID3={21, 22}, ID4={31}. Iterate over these four auxilary hash tables to find next record that satisfies the critera.
Now on ID2=11, we find _n_=6, by examination, it contains id2 \in ID3={21,22}, so that this record is added to the the hash table in a way as decribed above.
Keep this iteration until all four ID# lists are exhausted and no new record can be found. |
|