Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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 <richard.c.herron@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <jcoveney@bigplanet.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index