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 on April 23, and its replacement, is already up and running.

[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" <>
To   <>
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 as
a guinea pig...


-----Ursprüngliche Nachricht-----
[] 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


?  Thanks.


Thomas Jacobs
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index