I have this code in a Stata 13.1 do file:
This displays an r(3000) error:
This code appears to conform to the first case in -help m2_if-. However, I've seen posts elsewhere that say Mata is actually expecting an -else- statement here, because if you type something like
in interactive mode, it displays an > and prompts you to continue entering the command i.e. an else block. But, adding a semicolon to the end of the line doesn't fix this, i.e. this code still throws the same error:
If I make this into a multi-line if statement:
I get the same error. I need to add a semicolon after the closing brace to get this to work, like this:
I don't see anything in -help m2_semicolons- that describes this behaviour either. What am I missing?
Code:
cls mata: s = 1 t = 1 if (s == t) display("equal") end
Code:
unexpected end of line (0 lines skipped)
Code:
if (1 == 1) display("equal")
Code:
cls mata: s = 1 t = 1 if (s == t) display("equal"); end
Code:
cls mata: s = 1 t = 1 if (s == t) { display("equal") } end
Code:
cls mata: s = 1 t = 1 if (s == t) { display("equal") }; end
Comment