Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: automatic joining variables after merging datasets


From   Jörg Eulenberger <j.eulenberger@web.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: automatic joining variables after merging datasets
Date   Wed, 01 May 2013 11:17:07 +0200



Dear Statalisters,
i have two datasets, were the most of the variables are equal, but the
varnames are completely different.  I merge the two datasets:
****************
use "1.dta", clear
replace id = id+100

merge m:m id using "2.dta"
gen dataset =.
replace dataset=1 if id >100
replace dataset=2 if id <100

**********************
Now i want to join the Variables like:

replace Q_254509 = Q_254737 if _merge==2

Now my question,
is the a automatic way to find variables with the exact same varlabel
and then copy the value from the second variable to the first variable?

Do you have any ideas for this problem?

Jörg







*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index