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]
st: Error when -if- block is the last Mata line
From
Steve Samuels <[email protected]>
To
[email protected]
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
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.
Thanks
Steve
Steven J. Samuels
[email protected]
****************
//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/