Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why a pogram arguments cannot begin with "no" ?

    This costed me so much time. I eventually figured it out, but it still makes no sense. It is potentially a bug, unless I am missing something here...

    So, why arguments cannot begin with "no" in a Stata program? Here is an example. Run it and see (I'm using Stata 14.1 on MacBook pro 10.10)


    Code:
    cap prog drop argtest
    prog argtest
    syntax [anything], [nothanks] [yesplease] [nothing] [note] [NOproblem]    //NOTICE THE CAPITAL LETTERS IN "NOPROBLEM"
        display "`nothanks' `yesplease' `nothing' `note' `noproblem'
    end
    
    argtest , nothanks yesplease nothing note noproblem
    When I run this, I only get only two arguments printed which are:

    Code:
     yesplease   noproblem
    But why? Why the other arguments do not get interpreted? and why making abbreviation possible (i.e. for "noproblem" argument) will let me apply the argument?

    PS if the argument is all written in capital letters, it works fine, e.g. [NOTE] would work
    Last edited by haghish; 27 Apr 2016, 08:04.

  • #2
    [U] 11.1.7 The prefix "no" switches off an option.

    Most options are toggles—they indicate that something either is or is not to be done. Sometimes
    it is difficult to remember which is the default. The following rule applies to all options: if option
    is an option, then nooption is an option as well, and vice versa. Thus if we could not remember
    whether detail or nodetail were the default for summarize but we knew that we did not want
    the detail, we could type summarize, nodetail. Typing the nodetail option is unnecessary, but
    Stata will not complain.

    Comment


    • #3
      This is documented in the manuals ([P] syntax) under option descriptor optionally on:


      The macro contains nothing if not specified, or else it contains the macro’s name, fully spelled out. Warning: Be careful if the first two letters of the option’s name are no, such as the option called notice. You must capitalize at least the N in such cases
      This is to avoid conflict with the option descriptor optionally off
      Stata/MP 14.1 (64-bit x86-64)
      Revision 19 May 2016
      Win 8.1

      Comment


      • #4
        Makes sense now. Thank you.

        Comment

        Working...
        X