Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to merge those files


From   "E. Paul Wileyto" <[email protected]>
To   [email protected]
Subject   Re: st: How to merge those files
Date   Thu, 18 Oct 2007 08:29:23 -0400

Your code is written like SAS programming.  Try the "joinby" command.  
It does not require a preliminary sort.

Paul


Yu,Jingbo wrote:
> Hi, I got stuck and cannot find out what's wrong with my commands.
> Anybody can help me check on them? Thanks!
>
>  
>
> Jingbo
>
> ___________________________________
>
>  
>
> Child data file:
>
> DUID (family ID, 5 digits)
>
> PID (person ID within family, 3 digits)
>
> DUPERSID (unique person, 8 digits) *DUPERSID=DUID+PID
>
> MOPID (mom PID)
>
> DAPID (dad PID)
>
>  
>
> Parents data file:
>
> DUID
>
> PID
>
> DUPERSID
>
>  
>
> I am trying to link the two files together with those commands:
>
>  
>
> use parents, clear
>
> generate duidpid=dupersid
>
> sort duidpid
>
> save parents, replace
>
>  
>
> use child, clear
>
> generate duidpid=(duid*1000)+mopid
>
> sort duidpid
>
> merge duidpid using "child"
>
> tab _merge
>
>  
>
> . tab _merge
>
>  
>
>      _merge |      Freq.     Percent        Cum.
>
> ------------+-----------------------------------
>
>           1 |     16,956       33.01       33.01
>
>           2 |     34,403       66.99      100.00
>
> ------------+-----------------------------------
>
>       Total |     51,359      100.00
>
>  
>
>
> *
> *   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/
>
>   


-- 
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Department of Psychiatry
University of Pennsylvania
3535 W. Market Street, Suite 4100
Philadelphia, PA  19104-3309

Voice 215-746-7147
Fax 215-746-7140
[email protected]
http://www.mail.med.upenn.edu/~epw



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