I'm writing a function in Stata where I do some logical checks and possibly throw an error. Could look something like this:
if ! r(N) {
disp as error "There are no observations with a value of 1 in the subgroup."
exit
}
Now, I'm also running some Mata code and I would like to do logical checks in Mata as well and possibly throw an error like the one above. How would I do that?
Read up on the exit()
and error()
functions of Mata.
help mf_exit
help mf_error