Bookmark and Share

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]

Re: st: RE: return null Mata


From   "Thomas, Anthony" <anthony_h_thomas@brown.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: return null Mata
Date   Tue, 1 Apr 2014 16:56:38 -0400

Hi Joe,

Thanks, that is what I was looking for (should have looked closer at
help...).

Anthony

On Tue, Apr 1, 2014 at 4:46 PM, Joe Canner <jcanner1@jhmi.edu> wrote:
> Anthony,
>
> 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?
>
> Regards,
> Joe Canner
> Johns Hopkins University School of Medicine
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Thomas, Anthony
> Sent: Tuesday, April 01, 2014 4:41 PM
> To: statalist@hsphsun2.harvard.edu
> 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
> others?
>
> Thanks,
>
> Anthony
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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