Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to check the existence of a mata object?

    Hello,

    I wonder whether there is a Mata command for checking the existence of a Mata object.
    In Stata, we can use confirm and _rc. Can we do the same thing in Mata?

    Thank you very much.

  • #2
    see mata function findexternal()

    http://www.stata.com/help.cgi?mf_findexternal

    Comment


    • #3
      Kolodziejczyk, thanks for pointing out findexternal. I had misunderstood that command. I thought it was for checking Stata's global objects. Now I realise that findexternal does allow for checking the existence of Mata objects. Below is a toy example:

      Code:
      . mata: mata drop *
      . mata: A=J(1,2,3)
      
      . mata: findexternal("A") != J(1,1,NULL)
       1
      
      . mata: findexternal("B") != J(1,1,NULL)
       0

      Thanks a lot.

      Comment

      Working...
      X