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


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<pradipto.banerjee@adainvestments.com> 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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Wednesday, August 08, 2012 4:34 PM
> To: statalist@hsphsun2.harvard.edu
> 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
> <pradipto.banerjee@adainvestments.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index