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 on April 23, and its replacement, 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 <>
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?


*   For searches and help try:

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