Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Looping with merge


From   Adam Guerrero <[email protected]>
To   [email protected]
Subject   st: Looping with merge
Date   Mon, 13 May 2013 10:42:05 -0400

Hello All,

I am trying to write a loop for the following lines of code

merge m:1 zip_num using zip_pov.dta, keepusing(povrate)
drop if _merge==2
drop _merge
merge m:1 zip_num using p15_zip.dta, keepusing(permcf)
drop if _merge==2
drop _merge
merge m:1 zip_num using p37_zip.dta, keepusing(perbachelor)
drop if _merge==2
drop _merge

This is what, but has not been working

foreach file in zip_pov.dta p15_zip.dta p37_zip.dta {
foreach var of varlist "povrate" "permcf" "perbachelor" {
merge m:1 zip_num using `file', keepusing(`var')
drop if _merge==2
drop _merge
    }
}

Any advice would be very much appreciated.   Thanks in advance.

Adam Guerrero
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index