Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Looping over files


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Looping over files
Date   Tue, 22 Nov 2011 12:29:41 +0000

Jenniffer had difficulty sending this to the list. 

Nick 
n.j.cox@durham.ac.uk 

From: Jenniffer Solorzano Mosquera [mailto:soje11mo@student.hj.se] 

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:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index