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

Re: st: St: re merging two datasets


From   Ernest Berkhout <[email protected]>
To   [email protected]
Subject   Re: st: St: re merging two datasets
Date   Mon, 01 Sep 2003 13:40:36 +0200

At 13:13 1-9-2003, you wrote:
Michael
If you only want the income variable from the B
dataset, you need to create a temporary C dataset
which is a subset of the B dataset

use B
keep city income
save as C


You then sort this new C dataset on city, sort the A
datset on city and follow Michael Blasnik's
suggestion. You then save this new merged dataset as
some variant of A. You can then delete the C datset if
you wish.(I only mention this because I tend not to do
this and have messy little data sub-sets littering my
data folders.)
I did not elaborate on this, but it is only a simple commandline option with mmerge.ado. In the example I posted earlier today the command was:

use A
mmerge city using B, ukeep(income) replace update

On the second line note the option "ukeep(income)". This tells Stata that of the using data set B only the variable 'income' should be used (and the merge variable 'city' of course) and that the rest of the using data set B should be ignored. IMHO this is a much more elegant option than creating a new datafile that has to be deleted manually afterwards...



Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam

Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
http://www.seo.nl
===========================
A statistician: someone who insists
on being certain about uncertainty
===========================

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