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 at the end of May, and its replacement, statalist.org is already up and running.


[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 <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <n.j.cox@durham.ac.uk> wrote:
> Have a look first at Bill Gould's post
>
> http://www.stata.com/statalist/archive/2010-06/msg00392.html
>
> Nick
> n.j.cox@durham.ac.uk
>
> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index