Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Error when -if- block is the last Mata line
Date   Wed, 22 Sep 2010 19:52:14 +0100

Have a look first at Bill Gould's post


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

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
a= 1
r = 1
if (r) a = 2
//snippet 2
a =1
r = 1
if (r){
a = 2

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index