Bookmark and Share

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]

Re: st: mutually exclusive options within a program


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: mutually exclusive options within a program
Date   Wed, 19 Feb 2014 10:54:03 +0000

This can be answered quickly.

Make your options take string arguments, but don't tell the user that.
So, your first level of checking is whether both options were
specified:

if "`alpha'" != "" & "`beta'" != "" {
       <terminate>
}

Your second level of checking is for appropriate numeric input.

Nick
njcoxstata@gmail.com


On 19 February 2014 10:36, Marco Savegnago <savegnago.marco@gmail.com> wrote:
> Dear statalist,
>
> I'm writing a program which has to accept only one of two possible
> options (say either alpha or beta in the code below, each one with a
> default value):
>
>
>      syntax [, alpha(integer 5) beta(integer 10)]
>
>
>
> I need Stata to return an error code whenever these two options are
> invoked together.
>
> How can I achieve this?
>
> Thanks for your consideration,
>
> Marco Savegnago
> *
> *   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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index