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: Syntax error with Syntax itself


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Syntax error with Syntax itself
Date   Thu, 9 Aug 2012 00:32:41 +0100

Options taking string arguments don't have defaults. Or rather the
default is empty.

You would need to program a default of "or" yourself after -syntax- , by

if "`operation'" == "" local operation "or"

Whatever is not explicitly allowed as a possibility by -syntax- should
be regarded as forbidden.

Nick

On Thu, Aug 9, 2012 at 12:18 AM, Pradipto Banerjee
<[email protected]> wrote:
> Nick,
>
> I have now tried:
>
> syntax varlist(min=2) [, BY(string) BReaks(real 20) GOODliq(integer 50000000) OPeration(string "or")]
>
> But I still get an error. What could be wrong with this version?
>
> Many thanks
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Wednesday, August 08, 2012 4:34 PM
> To: [email protected]
> Subject: Re: st: Syntax error with Syntax itself
>
> -breaks()- requires an integer argument but is not compulsory. It
> therefore requires a default.
>
> -goodliq()- is said to take a numeric argument, but that keyword is
> not allowed by itself.
>
> All documented.
>
> Nick
>
> On Wed, Aug 8, 2012 at 9:21 PM, Pradipto Banerjee
> <[email protected]> wrote:
>> Hi, I am writing an egen function
>>
>> program define _gmakesigwgt
>> version 9.2
>> gettoken type 0 : 0
>> gettoken g      0 : 0
>> gettoken eqs 0 : 0
>> syntax varlist (min=2) [, BY(string) BReaks(integer) GOODliq(numeric)]
>> .
>> .
>> .
>> end
>>
>>
>> I've been debugging it using set trace on (set tracedepth 2). I tried calling it as
>>
>> . egen var2 = makesigwgt (var1 var2 var3), by(var4)
>>
>> The debug shows me that there is an -error 197-, i.e. error with the syntax statement itself. The exact error output is:
>>
>> - syntax varlist (min=2) [, BY(string) BReaks(integer) GOODliq(numeric)]
>> invalid syntax
>> r(197)
>>
>>
>> I can't understand what might be the error. Can someone give any suggestions?
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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