Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: while vs. forvalues


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: while vs. forvalues
Date   Tue, 10 Aug 2004 10:29:34 +0100

Not quite so. To expand a remark made earlier in the thread, 
Stata indulges trailing spaces within references to macro 
names, in at least some circumstances.  

So, for example, 

. local j = 1 
. di `j ' 

will work as if the space didn't exist. There might 
be a temptation to regard this as a feature. My 
own guess is that it is just a side-effect of 
the way the Stata parsing engine is indifferent 
to spaces in some circumstances. In this case, Stata's 
seen an opening left quote and a legal macro name and it's 
on the look-out for the only legal successor, a closing 
right quote. Although the above works, users should still 
regard `j ' as affected by a typo and try to edit out such 
spaces, not least because this behaviour shouldn't be regarded
as guaranteed in future releases of Stata. 

Note that this presupposes that a macro has been previously 
defined. Like Stas, I don't know a way to define a macro 
with a space as part of its name and that should be 
impossible as well as illegal. 

Nick 
[email protected] 

Stas Kolenikov
> 
> Is there a type in your -while- command? `j ' would give you an empty
> string. I am not even aware of ways to define a local macro that has a
> space in its name. So it is the -while- way that should not 
> work, at least
> exactly the way you wrote it.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index