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: return null Mata

From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: return null Mata
Date   Tue, 1 Apr 2014 20:46:52 +0000


According to the Mata help, " return [without any arguments] causes the function to stop execution and return to the caller, returning nothing."

Is that what you wanted?

Joe Canner
Johns Hopkins University School of Medicine

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas, Anthony
Sent: Tuesday, April 01, 2014 4:41 PM
To: [email protected]
Subject: st: return null Mata

Hi All,

I'm sure there is an obvious answer to this question, but I can't seem
to figure it out. I have a Mata function that I want to return nothing
when some condition fails to be met (the function is ordinarily
supposed to return a string matrix). I was thinking something like:

if(something) return(NULL);

or if(something) return(0);

would work, but I get errors indicating the return type is not as
expected in either case. I'm guessing this is because NULL is really a
pointer and 0 is just being interpreted in its normal sense. How can I
get Mata to return nothing in one instance and a string matrix in


*   For searches and help try:

*   For searches and help try:

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