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

st: RE: multiple merge


From   "Li, Wenjun" <WLi1@Lifespan.org>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: multiple merge
Date   Mon, 5 Aug 2002 16:18:03 -0400

If the files are named as file_1, file_2, .... file_500 or the alike, you
try to use Stata's "for" command, e.g.

foreach fileno in 1/500 {
	use file_`fileno', clear
	cap drop _merge
	sort date
	save, replace
}

use file_1, clear
foreach fileno in 2/500 {
	cap drop _merge
	merge date using file_`fileno', nok
	drop _merge
	sort date
}


Hope this helps.

Wenjun Li


		-----Original Message-----
		From:	Riano, Alejandro [mailto:ALEJANDROR@iadb.org]
		Sent:	Monday, August 05, 2002 3:56 PM
		To:	statalist@hsphsun2.harvard.edu
		Subject:	st: multiple merge

		I have 500 files in STATA format that have two variables:
date and X ; i
		need to merge all these files by date in only one file, do
you know a fast
		way in which i could do this (not doing it manually, open
each file and then
		merge it with the first one) ? 

		thanks in advance


		Alejandro Riano
		==========================
		Research Department
		Inter-American Development Bank
		(202) 623-1932
		alejandror@iadb.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/
*
*   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