Statalist The Stata Listserver


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

Re: st: RE: Merge??


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Merge??
Date   Wed, 14 Feb 2007 12:15:13 -0500

Maarten--
That would have been my first thought, too.  But Raphael Fraser has
either mistyped his desired outcome, or has some hidden structure in
mind that matches d1 and d2 in the first obs in 82 and not the second:
82    1   1
82     .   1
If he meant
82    1   .
82     .   1
82     .   1
then he wants to -append- not -merge- I guess.  If he did not mistype,
he still may want to -append- and then -replace- according to some
rule...

On 2/14/07, Maarten Buis <[email protected]> wrote:
--- Raphael Fraser wrote:
I would like to merge data1 and data2:

data1,
time d1
82    1
90    0

data2,
time d2
82    1
82    1
89    0

The result should look like this
time d1 d2
82    1   1
82     .   1
89     .   0
90    0    .


You need to make sure that both data1 and data2 are sorted
according to time. Then you can use -merge-, see:
-help merge-. The do-file will look something like this:

use data2, clear
sort time
save data2, replace
use data1, clear
sort time
merge time using data2
list time d1 d2 _merge in 1/20
tab _merge

Hope this helps,
Maarten

BTW you have reached the same answer if you searched in Stata
on merge, by typing -findit merge-.
*
*   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