Statalist


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

Re: st: artifacts after merge


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: artifacts after merge
Date   Mon, 29 Oct 2007 12:49:11 +0100

Michael McCulloch wrote:

I am merging two datasets, KP.dta and PS.dta, which were sorted by 
the variable <id>. They contain the subjects who from two different 
exposure groups.

Values for <id> are unique to each dataset, so that <id> occurs only 
once in each dataset, and are not duplicated across datasets.

Before the merge,
	In dataset KP, one variable <smoker> has values yes or no: 1/0.
	In dataset PS,  <smoker> is missing.
However, after the merge, PS now has values for <smoker>.

I merged using this command:
	use "A.dta", clear
	merge using "B.dta"

Then, checked my data:

        id   group   smoker
         1      PS        1
         2      PS        1
         3      PS        1
         4      PS        0
         5      PS        0
         6      PS        1
         7      PS        1
         8      PS        1

What have I done wrong?

------------------------------------------------------

Are you sure you don't want to -append- rather than -merge-.

If you want to merge on id, write:
    merge id using "B.dta"

Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index