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]

st: AW: Irritating if...else question for mata vs. stata


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Irritating if...else question for mata vs. stata
Date   Sun, 6 Jun 2010 20:18:45 +0200

<> 

You could find out via trial and error, for instance using Kit`s function on
page 51 of
http://www.stata.com/meeting/fnasug08/baum_StataMata.beamer.FNASUG08.pdf as
a guinea pig...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Thomas Jacobs
Gesendet: Sonntag, 6. Juni 2010 19:57
An: StataList
Betreff: st: Irritating if...else question for mata vs. stata

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.

Tom


--
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/


*
*   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