Statalist


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

Re: st: Beware of Stata's Syntax


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Beware of Stata's Syntax
Date   Thu, 22 May 2008 17:33:29 -0400

Sergiy Radyakin <serjradyakin@gmail.com> et al. --

Beware of posts with the word "bug" as they usually describe a
misunderstood feature.

help syntax##description_of_varlist

documents that

The default is to fill [varlist] in with all the variables.  If
default=none is specified, it is left empty.

Since
 Typing varname
    is equivalent to typing varlist(max=1).

using either

syntax [varname (default=none)]

or

syntax varname

is safest.

On Thu, May 22, 2008 at 5:17 PM, Sergiy Radyakin <serjradyakin@gmail.com> wrote:
> Dear All,
>
> I wonder if this is an intended behaviour (quite dangerous from my
> point of view) or just a bug?
>
> // --- Begin of file SyntaxBug.do ---
>
> program drop _all
> drop _all
>
> generate VariableThatShouldNotBeUsed=.
>
> program define SyntaxBug
>    syntax [varname]
>    di `"`varlist'"'
> end
>
> SyntaxBug
>
> generate JustAnotherVariable=.
>
> SyntaxBug
>
> // --- End of file SyntaxBug.do ---
>
> If this is not an intended behaviour then it is actually two bugs in
> one, since under some conditions the program will process the variable
> that the user DID NOT specify (first call in the program above), and
> under other conditions it will refuse to work though it supposedly
> should (second call in the program above).
>
> If this is intended (may be there is an explanation) then it goes
> against the documentation, saying anything in [ ] is optional.
>
> Thank you,
>    Sergiy Radyakin
*
*   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