Statalist The Stata Listserver


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

st: RE: Merge??


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: Merge??
Date   Wed, 14 Feb 2007 18:00:47 +0100

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

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


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