Daniel Schneider wrote:
> I am lost, and I do not know anymore what I am doing wrong with this
> very simple problem. I have been trying to get a very simple if-clause
> to run in Mata, but it hasn't worked at all. I have finally
> reduced the
> if-statement to the most simple form:
>
> mata: if (1==1) results[1,1]
>
>
> (results[1,1] should just output a number)
>
> What I get is
>
> unexpected end of line
> <istmt> incomplete
>
I guess the real question is, why you would want to use an
if statement interactively (from Stata's dot-prompt or from
Mata's colon-prompt) (?)
I don't know why this doesn't work in Mata. Maybe it is not
meant to work interactively. It works with Stata's if command:
. if 1==1 display "Hello world"
Hello world
You can, however, trick Mata into getting what you want:
. mata if (1==1) {} "Hello world"
Hello world
. mata: if (1==1) {} "Hello world"
Hello world
. mata:
-----------------------------
: if (1==1) {} "Hello world"
Hello world
but I am not sure that it is recommendable to do this at all,
and I am pretty sure that it is not documented. And again:
I don't know why you would want to do this. Please note that
you will get yet another error, if the matrix or scalar res
is not defined beforehand.
/Jesper
Jesper Kj�r Hansen
mailto:[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/