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: Irritating if...else question for mata vs. stata
From
Thomas Jacobs <[email protected]>
To
[email protected]
Subject
Re: st: RE: Irritating if...else question for mata vs. stata
Date
Sun, 6 Jun 2010 13:31:40 -0500
Nick,
Thanks very much, you basically carried out the experiment Martin had
directed me to.
I am pretty much grasping at straws at this point on this overly
lengthy and convoluted program for which I lack the time to rewrite
before my delivery deadline.
Thanks again,
Tom
On Sun, Jun 6, 2010 at 1:27 PM, Nick Cox <[email protected]> wrote:
> You need not apologise that (you think) your question is irritating.
>
> No -else- is needed in Mata with multiple blocks.
>
> Here's a dopey demo to run.
>
> mata :
>
> void testif() {
> if (42 > 0) {
> "42 is positive"
> "Scotland is wet"
> "Bears don't behave nicely in the woods"
> }
> }
>
> testif()
>
> end
>
> Nick
> [email protected]
>
> Thomas Jacobs
>
> I am trying to determine whether an if block is acceptable in mata
> without an else block even if else is empty.
>
> In the Stata manual for if it specifically shows the following - I am
> ignoring the single line if statement command:
>
> if exp {
>
> multiple commands
>
> }
>
> which...MAY be followed by else etc.
>
> However in the mata manual only the single line line if(exp) sttmnt 1
> is displayed. All the other examples have a trailing else whether in
> block or single line form. In the description, however, it states "if
> evaluates the expression, and if it is true, if executes the statement
> or statement block that immediately follows it; otherwise, if skips
> the statement or block."
>
> I interpret the latter description to be that one can use the if block
> without a trailing else.
>
> The lack of precision is frustrating, however, and I am struggling to
> interpret odd program behavior. Can anyone definitively state whether
> the following is proper programming form for mata:
>
> if (exp) {
>
> multiple statements
>
> }
>
> with no trailing empty
>
> else{
> }
>
> ? Thanks.
>
>
> *
> * 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/
>
--
Thomas Jacobs
*
* 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/