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

RE: st: RE: Parsing of multiple -if- lines


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Parsing of multiple -if- lines
Date   Tue, 13 Aug 2002 13:05:24 -0400

> -----Original Message-----
> From: David Kantor [mailto:[email protected]] 
> Sent: Tuesday, August 13, 2002 1:00 PM
> To: [email protected]
> Subject: Re: st: RE: Parsing of multiple -if- lines
> 
> 
> At 12:33 PM 8/13/2002 -0400, Nick Winter wrote:
> 
> >When the -else- clause is removed, then the program crashes only when
> >the second token is set to an asterisk, suggesting that it is the
> >comments in there that are somehow confusing things?
> 
> I'm not totally clear about this, but I think that Stata 
> expects a loaded 
> program to have no commented-out text.  That is, any 
> commented-out text it 
> finds at load time is stripped out; once loaded, a program has no 
> comments.  (Do -program list-; you will see: no more 
> comments.)  But now 
> you are introducing a new twist: parts of the program become 
> commented-out 
> at run time.  Perhaps the comment-skipping feature does not 
> operate (at 
> least, not completely) while running a program, as it is 
> presumed to have 
> already gone through that step at load time.

Interestingly, although Stata drops any commented lines when loading a
program, it is also happy to encounter comments as it interprets the
lines at execution.  The local macros `1' '2', are not substituted until
runtime, so the lines remain.

This simpler version makes it clear:

prog define myprog3
   `1' di "line one"
   `2' di "line two"
   `3' di "line three"
end

. myprog3 " " " " " "
line one
line two
line three

. myprog3 " " " " "*"
line one
line two

--Nick Winter
*
*   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