Announcement

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

  • Check whether -moremata- is installed

    When writing .do-files which make use of user written commands, first I check whether these programs exist already and then I use commands to install them *only* if they do not exist already.

    For example, if my .do-file will use -fre- (available at SSC), at the beginning of the .do-file I write
    Code:
    cap which fre
    if _rc ssc install fre
    However, this does not work with -moremata- (available from SSC) because -which- will not find the command -moremata- as either a built-in or an .ado-file. Is there another way to check whether -moremata- is installed so that I can use a command to install it *only* if it does not exist already?

  • #2
    The output of
    Code:
    ssc describe moremata
    lists the files it installs - choose one of those, such as lmoremata.mlib, to use with which.

    Comment


    • #3
      Thanks a lot! I will use the help file:
      Code:
      cap which moremata.hlp
      if _rc ssc install moremata

      Comment


      • #4
        Here are two other options:
        Code:
        cap findfile lmoremata.mlib
        cap mata mata which mm_invtokens() // or any other mata function from moremata
        Last edited by Wouter Wakker; 11 Jan 2021, 00:19.

        Comment


        • #5
          A similar problem occurs if the command we check for with which does not equal the package name to be installed. For example,

          Code:
          capture which esttab
          would have to be followed by

          Code:
          if ( _rc ) ssc install estout
          I have written a convenience command, rqrs, to do this, which I have announced here. The command does not handle the problem that Dirk describes here.

          Comment

          Working...
          X