Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Stata' new merge


From   Fred Wolfe <fwolfe@arthritis-research.org>
To   statalist@hsphsun2.harvard.edu
Subject   st: Stata' new merge
Date   Wed, 17 Dec 2003 07:49:12 -0600

Stata's new merge is intriguing and perhaps worrisome.

Consider this:

merge patkey newenc using ${sql}demo1 ${sql}surv3,keep(hlth* w_hlthins)

to which Stata replies: "variable w_hlthins not found in using dataset"

Done the old way:

merge patkey newenc using ${sql}demo1,keep(hlth*)
merge patkey newenc using ${sql}surv3,keep(w_hlthins)

Stata has no problem. Therefore the -merge- change for multiple merges using a -keep()- option only works if the 'kept' variables are in both data sets.

At the very least Stata might upgrade the help file to make this manifest. Of course, Stata might look ahead and see if the 'kept' variable was present in any of the using data sets.

Also, _merge/k refers to the relation between master and using data sets(k). However, what if the first merge alters the master set such that the new master yields _merge results with respect to using set k+1.

There is case to be made for merging on set at a time. Hard to see that multiple merges add much utility for the potential confusion.

Fred Wolfe


Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel (316) 263-2125 Fax (316) 263-0761
fwolfe@arthritis-research.org


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