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

st: RE: multiple merge


From   "Li, Wenjun" <[email protected]>
To   "'[email protected]'" <[email protected]>
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:[email protected]]
		Sent:	Monday, August 05, 2002 3:56 PM
		To:	[email protected]
		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
		[email protected]
		==========================

		*
		*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index