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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: local within global


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: local within global
Date   Fri, 25 Nov 2011 17:36:18 +0000

The backslash \ is probably messing up what you want as it is being interpreted as an escape character. Use a forward slash, even under MS Windows if you want \ meaning separator within filenames.

Nick

On 25 Nov 2011, at 15:59, adrien bouguen <abouguen@povertyactionlab.org> wrote:

Dear,

I still face a problem when I want to call a local within a global. I
have got a global which indicates my input directory and another
global which defines some dta names. Stata refuses to open the file
even when I add the curly brackets as advised in other conversations.

For instance:

I define two macros:
global input "directory"
global X "X1 X2 X3 X4"

then a loop such as:

foreach i in $score {
use "$input\`i'", clear
}
does not work. Writing "${input\`i'}" or "${input}\`i'" or even
"${input\{`i'}}" does not solve the problem.

I make it work with the cumbersome:
foreach i in $score {
local j="`i'"
use "$input\`j'", clear
}
Is there any other
*
*   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