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: Error when -if- block is the last Mata line

From   Steve Samuels <>
Subject   st: Error when -if- block is the last Mata line
Date   Wed, 22 Sep 2010 14:16:47 -0400

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.



Steven J. Samuels

//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–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index