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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: pair data to individual data


From   Duha Altindag <daltin2@tigers.lsu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: pair data to individual data
Date   Thu, 10 Jun 2010 12:51:39 +0000

If the data set you have right now is called master.dta, then the
following should give what you want.

use master,clear
keep famid aid_1
ren aid_1 aid
save data1,replace
use master,clear
keep famid aid_2
ren aid_2 aid
append using data1
duplicates drop famid aid,force


On Thu, Jun 10, 2010 at 12:25 PM, Averett, Susan L
<averetts@lafayette.edu> wrote:
>
> 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.
> Thanks!
>
> Susan Averett
> *
> *   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/

*
*   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