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: Re: Unable to clear "invalid syntax r(197);" error in user-written .ado file


From   Richard Herron <[email protected]>
To   [email protected]
Subject   Re: st: Re: Unable to clear "invalid syntax r(197);" error in user-written .ado file
Date   Thu, 4 Oct 2012 22:54:41 -0400

You're right, thanks! If I change -syntax- to

    syntax varlist(numeric) [if] [in], ///
        Suffix(string) Byvar(string) [Tail(real 0.5)]

the .ado file runs, save a few other apparent errors. :)

Thanks for the help!

On Thu, Oct 4, 2012 at 10:37 PM, Joseph Coveney <[email protected]> wrote:
> Richard Herron wrote:
>
> I wrote an .ado file to trim data in the left and right tails, but I
> can't get past an "invalid syntax r(197)" error. My -syntax- line is
> as follows.
>
> * begin syntax line
>     syntax varlist(numeric) [if] [in] ///
>         [, Byvar(string fyear) Tail(real 0.5) Suffix(string tr)]
> * end syntax line
>
> I would like to use a -varlist- so that I can loop over the supplied
> variables, but I can't clear the error using -varname- or by dropping
> the -if- and -in- statements. I also tried making the options required
> without defaults, but that didn't work either.
>
> What is my misunderstanding of syntax? Thank you!
>
> [remainder omitted]
>
> --------------------------------------------------------------------------------
>
> It seems as if you're trying to supply default arguments to your string options.  It's my understanding that you cannot do that.  Try omitting them:
>
> syntax varlist(numeric) [if] [in] ///
>         [, Byvar(string) Tail(real 0.5) Suffix(string)]
>
> local byvar = cond("`byvar'" == "", "fyear", "`byvar'")
> local suffix = cond("`suffix'" == "", "tr", "`suffix'")
>
> Joseph Coveney
>
>
>
> *
> *   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