Bookmark and Share

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

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

st: Looping over files

From   Nick Cox <>
To   "''" <>
Subject   st: Looping over files
Date   Tue, 22 Nov 2011 12:29:41 +0000

Jenniffer had difficulty sending this to the list. 


From: Jenniffer Solorzano Mosquera [] 

I'm trying to use the following to loop over every do-file commands (the
things I have to do with each file before the append):

local sefirms: dir . files "*.txt", nofail respectcase

But I don't want to use the part "nofail respectcase" because I need to
do this for all the file, not only for the ones that can be put on a
macroname. I have like 35.000 files. And from those, I know some files
are not runing with the do-file I already have ( the number of years is
not the same in each file, etc) so, I just want the command select the
files I want to loop over. In other words, i know 28.000 files work in
that do-file, I know their file name (which by the way is in numeric
form, lets say 1.txt 2.txt 3.txt ....), but I don't see as efficient
make a list of all this file names and then put it in on a macro name
because (in a vertical way) first, because they are too many and second,
I don't know how to convert that list into a horizontal form, with those
specific name files, and put them in the do-file.

Is there a way that I can select the files I want without doing this?
And I cannot put the right files in a directory because I would have to
do it manually in the folder window, the one in which I have saved the
all txt files (the 38000).

Thanks for your suggestions,

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index