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]

Re: st: RE: Error when -if- block is the last Mata line


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   Re: st: RE: Error when -if- block is the last Mata line
Date   Wed, 22 Sep 2010 15:04:48 -0400

-
Bill's post is a complete answer to my question.  Thanks.

Steve

On Wed, Sep 22, 2010 at 2:52 PM, Nick Cox <[email protected]> wrote:
> Have a look first at Bill Gould's post
>
> http://www.stata.com/statalist/archive/2010-06/msg00392.html
>
> Nick
> [email protected]
>
> Steve Samuels
>
> I'm trying to learn Mata-better late than never.  I encountered the
> issue below when I tried to run a suggestion that Ben Jann made in
> http://www.stata.com/statalist/archive/2009-02/msg00439.html.
>
> If I type the following code snippets interactively, I get a prompt
> ">" after the -if- line (first snippet) or after the -if- block
> (second snippet).
>
> If I run the code in a -do file-, I get an "unexpected end of line"
> error. If I add any command after the if line or block (but not if I
> add a comment line), there is no error. Obviously Stata is expecting
> something after the -if- blocks. What and why? It looks like an -if-
> line or block can't be the last line in a Mata session.
>
> ****************
> //snippet 1
> clear
> mata
> a= 1
> r = 1
> if (r) a = 2
> end
> ****************
> *****************
> //snippet 2
> clear
> mata
> a =1
> r = 1
> if (r){
> a = 2
> }
> end
> ***************************
>
> *
> *   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