Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: looping over all files in a folder


From   "Dimitriy V. Masterov" <[email protected]>
To   [email protected]
Subject   Re: st: looping over all files in a folder
Date   Tue, 22 Aug 2006 16:26:44 -0400

On 8/22/06, Radu Ban <[email protected]> wrote:
....I'm looking for a way to loop this do-file over all the files in
the folder.

Try this (after changing the folder path to suit your setup):

local files : dir "C:\Documents and Settings\Dimitriy V.
Masterov\Desktop" files "*.txt";

cd "C:\Documents and Settings\Dimitriy V. Masterov\Desktop";

foreach file in `files' {;
	insheet using `file', comma clear;
	/* do your stuff here */
};

HTH,
DVM
*
*   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