Statalist


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

Re: st: I can't get fs to work from inside a do file


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: I can't get fs to work from inside a do file
Date   Sat, 16 Feb 2008 16:48:51 -0500

...

I hope you realize that your line

local dofiles r(files)

simply places the text string "r(files)" into the local macro dofiles. That is why word count comes up with one word. You need to expand the local macro when assigning it to dofiles, like this:

local dofiles `r(files)'

If you use the equals sign, then the list will be truncated at 244 characters. Without the equals sign it is nearly limitless.

Michael Blasnik


----- Original Message ----- "Gabi Huiber" wrote:

If you do

local dofiles r(files)

you get a string of all their names in a single word. I checked with
word count `dofiles'. That, of course, defeats the foreach loop. It's
bizarre, because this single-word string shows the do-file names
neatly delimited with spaces, whereas if you do

local dofiles=r(files)

like I did, the do-file names in that folder look like they're all
strung together as in file1.dofile2.do[...] yet the local `dofiles'
does have five distinct words, one for each do-file, as it should. Try
it with one of your do-file directories to see what I mean. Of course
running the foreach loop directly off the `r(files)' local fixes the
problem, but it's still a strange one, don't you think?
*
*   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