Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: pair data to individual data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: pair data to individual data
Date   Thu, 10 Jun 2010 13:47:34 +0100

One way to do it:

gen long id = _n
expand 2
bysort id : gen long aid = cond(_n == 1, aid_1, aid_2)

As mentioned before, 

SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q4/08   SJ 8(4):588--591                                 (no commands)
        tip on how to handle dyadic identifiers

covers technique in this territory.

Nick 
n.j.cox@durham.ac.uk 

Averett, Susan L

I have a data set that has a family id (famid) and two individual person identifiers for siblings (aid_1 and aid_2) plus some other variables which are not shown. As you can see below the famid column has a family with id 1001 with two siblings, 93710875   97570477. Some families, such as 1011 have more than two sets of siblings. See below:

     +-----------------------------+
     | famid      aid_1      aid_2 |
     |-----------------------------|
  1. |  1001   93710875   97570477 |
  2. |  1002   93576557   97506154 |
  3. |  1003   96717912   96717917 |
  4. |  1004   91656927   97676522 |
  5. |  1005   91588998   93578896 |
     |-----------------------------|
  6. |  1006   90718946   91588942 |
  7. |  1007   99578364   99578369 |
  8. |  1008   91576326   98576229 |
  9. |  1009   93506890   93506897 |
 10. |  1010   92544209   96884901 |
     |-----------------------------|
 11. |  1011   93504422   99574220 |
 12. |  1011   93504422   99574221 |
 13. |  1011   99574220   99574221 |
 14. |  1012   90571316   91571911 |
 15. |  1013   91576322   91576325 |
     |-----------------------------|
 16. |  1014   90716062   91886961 |
 17. |  1015   91540352   91540358 |
 18. |  1016   94718146   98578449 |
 19. |  1017   97575250   97575258 |
 20. |  1018   91885961   94575866 |
     +-----------------------------+

Somehow I need to make this look like:

famid      aid
1001     93710875  
1001     97570477

etc...

Any ideas? I've been messing with this for awhile but to no avail.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index