Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: local and loops
From
Matthew White <[email protected]>
To
[email protected]
Subject
st: local and loops
Date
Tue, 20 Aug 2013 14:52:39 -0400
Hi all,
Using Stata 13 for Windows 7, I'm trying to figure out an interaction
between -local- and loops. Normally when I define a local, multiple,
consecutive internal spaces are preserved. For example:
. local x 1 2
. display strpos("`x'", " ")
2
Yet when I use the same definition in a loop, the internal spaces are trimmed:
. forvalues i = 1/5 {
2. local x 1 2
3. }
. display strpos("`x'", " ")
0
Have others experienced this before? It's probably rare that this
would bite, but I'm running into such a situation now. Enclosing the
contents of the local by double quotes solves the problem:
. forvalues i = 1/5 {
2. local x "1 2"
3. }
. display strpos("`x'", " ")
2
I'm just so used to dropping these quotes when I don't need them!
Thank you,
Matt
--
Matthew White
Senior Project Associate
Innovations for Poverty Action
101 Whitney Avenue, New Haven, CT 06510 USA
www.poverty-action.org
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/