Announcement

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

  • Backward Compatibility .mlib-s Complied in v17

    Hi All,

    Yesterday a user made an issue on the -domin- (SSC) package's GitHub page noting that they are getting an error that a Mata function was complied in Stata v17 and that older versions of Stata cannot use it.

    I had never come across this before and couldn't find any documentation on this as a change for developers who use Mata.

    I have access to Stata versions back to v12 but this behavior can be observed with versions as recent as v16 as well with a .mlib compiled with v17. I have an example below that is intended to be reproducible. I've included the paths to all the files for completeness. I did this on a Windows machine with Stata 17 MP and Stata 16 SE.

    Note that the .mlib complied with Stata v17 fails to run when called with v16. The .mlib compiled with v16 works with both v16 and v17 however.

    My question is whether there is a way to make an .mlib back compatible using v17 without using compiling using an older version of Stata.

    - joe

    Code:
    . version 17
    
    . 
    . clear all
    
    . 
    . cd "C:\Users\jluchman\Documents\Statalist"
    C:\Users\jluchman\Documents\Statalist
    
    . 
    . **# Define .mata file for compliation
    . file open mata_fn using st_mata.mata, write replace
    
    . 
    . file write mata_fn "mata:" _newline(2)
    
    . 
    . file write mata_fn "void say_something() {" _newline(2)
    
    . 
    . file write mata_fn `"printf("looks like it works")"' _newline(2)
    
    . 
    . file write mata_fn "}" _newline(2)
    
    . 
    . file write mata_fn "end" 
    
    . 
    . file close mata_fn
    
    . 
    . **# Define .do that compiles
    . file open lm_bld using lmbuild_it.do, write replace
    
    . 
    . file write lm_bld "clear all" _newline(2)
    
    . 
    . file write lm_bld "do C:\Users\jluchman\Documents\Statalist\st_mata.mata" _newline(2)
    
    . 
    . file write lm_bld `"lmbuild lb_statalist, replace dir(C:\Users\jluchman\Documents\Statalist\)"'
    
    . 
    . file close lm_bld
    
    . 
    . **# Define .do that calls say_something()
    . file open say using do_say.do, write replace
    
    . 
    . file write say `"adopath + "C:\Users\jluchman\Documents\Statalist\""' _newline(2)
    
    . 
    . file write say "mata: mata mlib index" _newline(2)
    
    . 
    . file write say "mata: say_something()"
    
    . 
    . file close say
    
    . 
    . **# Call V17 to compile
    . shell "C:\Program Files\Stata17/StataMP-64" /e do "C:\Users\jluchman\Documents\Statalist\lmbuild_it.do"
    
    . 
    . copy lmbuild_it.log lmbuild_it17.log, replace
    
    . 
    . file open bld using lmbuild_it17.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ ®
       3   /__    /   ____/   /   ____/      17.0
       4  ___/   /   /___/   /   /___/       MP—Parallel Edition
       5  
       6   Statistics and Data Science       Copyright 1985-2021 StataCorp LLC
       7                                     StataCorp
       8                                     4905 Lakeway Drive
       9                                     College Station, Texas 77845 USA
      10                                     800-STATA-PC        https://www.stata.com
      11                                     979-696-4600        [email protected]
      17  
      18  Notes:
      19        1. Stata is running in batch mode.
      20        2. Unicode is supported; see help unicode_advice.
      21        3. More than 2 billion observations are allowed; see help obs_advice.
      22        4. Maximum number of variables is set to 5,000; see help set_maxvar.
      23  
      24  . do C:\Users\jluchman\Documents\Statalist\lmbuild_it.do 
      25  
      26  . clear all
      27  
      28  . 
      29  . do C:\Users\jluchman\Documents\Statalist\st_mata.mata
      30  
      31  . mata:
      32  ------------------------------------------------- mata (type end to exit) -----
      33  : 
      34  : void say_something() {
      35  > 
      36  > printf("looks like it works")
      37  > 
      38  > }
      39  
      40  : 
      41  : end
      42  -------------------------------------------------------------------------------
      43  
      44  . 
      45  end of do-file
      46  
      47  . 
      48  . lmbuild lb_statalist, replace dir(C:\Users\jluchman\Documents\Statalist\)
      49  (1 function added)
      50  existing library C:\Users\jluchman\Documents\Statalist\lb_statalist.mlib replac
      51  > ed
      52  
      53  . 
      54  end of do-file
    
    . 
    . file close bld
    
    . 
    . **# Call V17 do
    . shell "C:\Program Files\Stata17/StataMP-64" /e do "C:\Users\jluchman\Documents\Statalist\do_say.do"
    
    . 
    . copy do_say.log do_say17_cpl17.log, replace
    
    . 
    . file open bld using do_say17_cpl17.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ ®
       3   /__    /   ____/   /   ____/      17.0
       4  ___/   /   /___/   /   /___/       MP—Parallel Edition
       5  
       6   Statistics and Data Science       Copyright 1985-2021 StataCorp LLC
       7                                     StataCorp
       8                                     4905 Lakeway Drive
       9                                     College Station, Texas 77845 USA
      10                                     800-STATA-PC        https://www.stata.com
      11                                     979-696-4600        [email protected]
      17  
      18  Notes:
      19        1. Stata is running in batch mode.
      20        2. Unicode is supported; see help unicode_advice.
      21        3. More than 2 billion observations are allowed; see help obs_advice.
      22        4. Maximum number of variables is set to 5,000; see help set_maxvar.
      23  
      24  . do C:\Users\jluchman\Documents\Statalist\do_say.do 
      25  
      26  . adopath + "C:\Users\jluchman\Documents\Statalist\"
      27    [1]  (BASE)      "C:\Program Files\Stata17\ado\base/"
      28    [2]  (SITE)      "C:\Program Files\Stata17\ado\site/"
      29    [3]              "."
      30    [4]  (PERSONAL)  "C:\Users\jluchman\ado\personal/"
      31    [5]  (PLUS)      "c:\ado\plus/"
      32    [6]  (OLDPLACE)  "c:\ado/"
      33    [7]              "C:\Users\jluchman\Documents\Statalist\"
      34  
      35  . 
      36  . mata: mata mlib index
      37  .mlib libraries to be searched are now
      38      lmatabase;lmataado;lmatabma;lmatacollect;lmataerm;lmatafc;lmatagsem;lmatala
      39  > sso;lmatamcmc;lmatameta;lmatami;lmatamixlog;lmatanumlib;lmataopt;lmatapath;lm
      40  > atapostest;lmatapss;lmatasem;lmatasp;lmatasvy;lmatatab;lb_statalist;lb_domina
      41  > nce;lmoremata;lmoremata10;lmoremata11;lmoremata14
      42  
      43  . 
      44  . mata: say_something()
      45  looks like it works
      46  . 
      47  end of do-file
    
    . 
    . file close bld
    
    . 
    . **# Call V16 do
    . shell "C:\Program Files\Stata16/StataSE-64" /e do "C:\Users\jluchman\Documents\Statalist\do_say.do"
    
    . 
    . copy do_say.log do_say16_cpl17.log, replace
    
    . 
    . file open bld using do_say16_cpl17.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ (R)
       3   /__    /   ____/   /   ____/
       4  ___/   /   /___/   /   /___/   16.1   Copyright 1985-2019 StataCorp LLC
       5    Statistics/Data analysis            StataCorp
       6                                        4905 Lakeway Drive
       7       Special Edition                  College Station, Texas 77845 USA
       8                                        800-STATA-PC        https://www.stata.com
       9                                        979-696-4600        [email protected]
      10                                        979-696-4601 (fax)
      11  
      17  Notes:
      18        1. Stata is running in batch mode.
      19        2. Unicode is supported; see help unicode_advice.
      20        3. Maximum number of variables is set to 5,000; see help set_maxvar.
      21  
      22  . do C:\Users\jluchman\Documents\Statalist\do_say.do 
      23  
      24  . adopath + "C:\Users\jluchman\Documents\Statalist\"
      25    [1]  (BASE)      "C:\Program Files\Stata16\ado\base/"
      26    [2]  (SITE)      "C:\Program Files\Stata16\ado\site/"
      27    [3]              "."
      28    [4]  (PERSONAL)  "C:\Users\jluchman\ado\personal/"
      29    [5]  (PLUS)      "c:\ado\plus/"
      30    [6]  (OLDPLACE)  "c:\ado/"
      31    [7]              "C:\Users\jluchman\Documents\Statalist\"
      32  
      33  . 
      34  . mata: mata mlib index
      35  .mlib libraries to be searched are now
      36      lmatabase;lmataado;lmataerm;lmatafc;lmatagsem;lmatalasso;lmatamcmc;lmatamet
      37  > a;lmatami;lmatamixlog;lmatanumlib;lmataopt;lmatapath;lmatapostest;lmatapss;lm
      38  > atasem;lmatasp;lmatasvy;lmatatab;lb_statalist;lb_dominance;lmoremata;lmoremat
      39  > a10;lmoremata11;lmoremata14
      40  
      41  . 
      42  . mata: say_something()
      43  (say_something() in lb_statalist, compiled by Stata 17.0, is too new to be run
      44  by this version of Stata and so was ignored)
      45                   <istmt>:  3499  say_something() not found
      46  r(3499);
      47  
      48  end of do-file
      49  r(3499);
    
    . 
    . file close bld
    
    . 
    . **# Call V16 to compile
    . shell "C:\Program Files\Stata16/StataSE-64" /e do "C:\Users\jluchman\Documents\Statalist\lmbuild_it.do"
    
    . 
    . copy lmbuild_it.log lmbuild_it16.log, replace
    
    . 
    . file open bld using lmbuild_it16.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ (R)
       3   /__    /   ____/   /   ____/
       4  ___/   /   /___/   /   /___/   16.1   Copyright 1985-2019 StataCorp LLC
       5    Statistics/Data analysis            StataCorp
       6                                        4905 Lakeway Drive
       7       Special Edition                  College Station, Texas 77845 USA
       8                                        800-STATA-PC        https://www.stata.com
       9                                        979-696-4600        [email protected]
      10                                        979-696-4601 (fax)
      11  
      17  Notes:
      18        1. Stata is running in batch mode.
      19        2. Unicode is supported; see help unicode_advice.
      20        3. Maximum number of variables is set to 5,000; see help set_maxvar.
      21  
      22  . do C:\Users\jluchman\Documents\Statalist\lmbuild_it.do 
      23  
      24  . clear all
      25  
      26  . 
      27  . do C:\Users\jluchman\Documents\Statalist\st_mata.mata
      28  
      29  . mata:
      30  ------------------------------------------------- mata (type end to exit) -----
      31  : 
      32  : void say_something() {
      33  > 
      34  > printf("looks like it works")
      35  > 
      36  > }
      37  
      38  : 
      39  : end
      40  -------------------------------------------------------------------------------
      41  
      42  . 
      43  end of do-file
      44  
      45  . 
      46  . lmbuild lb_statalist, replace dir(C:\Users\jluchman\Documents\Statalist\)
      47  (1 function added)
      48  existing library C:\Users\jluchman\Documents\Statalist\lb_statalist.mlib replac
      49  > ed
      50  
      51  . 
      52  end of do-file
    
    . 
    . file close bld
    
    . 
    . 
    . **# Call V17 do
    . shell "C:\Program Files\Stata17/StataMP-64" /e do "C:\Users\jluchman\Documents\Statalist\do_say.do"
    
    . 
    . copy do_say.log do_say17_cpl16.log, replace
    
    . 
    . file open bld using do_say17_cpl16.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ ®
       3   /__    /   ____/   /   ____/      17.0
       4  ___/   /   /___/   /   /___/       MP—Parallel Edition
       5  
       6   Statistics and Data Science       Copyright 1985-2021 StataCorp LLC
       7                                     StataCorp
       8                                     4905 Lakeway Drive
       9                                     College Station, Texas 77845 USA
      10                                     800-STATA-PC        https://www.stata.com
      11                                     979-696-4600        [email protected]
      17  
      18  Notes:
      19        1. Stata is running in batch mode.
      20        2. Unicode is supported; see help unicode_advice.
      21        3. More than 2 billion observations are allowed; see help obs_advice.
      22        4. Maximum number of variables is set to 5,000; see help set_maxvar.
      23  
      24  . do C:\Users\jluchman\Documents\Statalist\do_say.do 
      25  
      26  . adopath + "C:\Users\jluchman\Documents\Statalist\"
      27    [1]  (BASE)      "C:\Program Files\Stata17\ado\base/"
      28    [2]  (SITE)      "C:\Program Files\Stata17\ado\site/"
      29    [3]              "."
      30    [4]  (PERSONAL)  "C:\Users\jluchman\ado\personal/"
      31    [5]  (PLUS)      "c:\ado\plus/"
      32    [6]  (OLDPLACE)  "c:\ado/"
      33    [7]              "C:\Users\jluchman\Documents\Statalist\"
      34  
      35  . 
      36  . mata: mata mlib index
      37  .mlib libraries to be searched are now
      38      lmatabase;lmataado;lmatabma;lmatacollect;lmataerm;lmatafc;lmatagsem;lmatala
      39  > sso;lmatamcmc;lmatameta;lmatami;lmatamixlog;lmatanumlib;lmataopt;lmatapath;lm
      40  > atapostest;lmatapss;lmatasem;lmatasp;lmatasvy;lmatatab;lb_statalist;lb_domina
      41  > nce;lmoremata;lmoremata10;lmoremata11;lmoremata14
      42  
      43  . 
      44  . mata: say_something()
      45  looks like it works
      46  . 
      47  end of do-file
    
    . 
    . file close bld
    
    . 
    . **# Call V16 do
    . shell "C:\Program Files\Stata16/StataSE-64" /e do "C:\Users\jluchman\Documents\Statalist\do_say.do"
    
    . 
    . copy do_say.log do_say16_cpl16.log, replace
    
    . 
    . file open bld using do_say16_cpl16.log, read
    
    . 
    . local linenum = 0
    
    . 
    . file read bld line
    
    . 
    . while r(eof) == 0 {
      2.         
    .         local linenum = `linenum' + 1
      3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
      4.         file read bld line
      5.         
    . }
       1  
       2    ___  ____  ____  ____  ____ (R)
       3   /__    /   ____/   /   ____/
       4  ___/   /   /___/   /   /___/   16.1   Copyright 1985-2019 StataCorp LLC
       5    Statistics/Data analysis            StataCorp
       6                                        4905 Lakeway Drive
       7       Special Edition                  College Station, Texas 77845 USA
       8                                        800-STATA-PC        https://www.stata.com
       9                                        979-696-4600        [email protected]
      10                                        979-696-4601 (fax)
      11  
      17  Notes:
      18        1. Stata is running in batch mode.
      19        2. Unicode is supported; see help unicode_advice.
      20        3. Maximum number of variables is set to 5,000; see help set_maxvar.
      21  
      22  . do C:\Users\jluchman\Documents\Statalist\do_say.do 
      23  
      24  . adopath + "C:\Users\jluchman\Documents\Statalist\"
      25    [1]  (BASE)      "C:\Program Files\Stata16\ado\base/"
      26    [2]  (SITE)      "C:\Program Files\Stata16\ado\site/"
      27    [3]              "."
      28    [4]  (PERSONAL)  "C:\Users\jluchman\ado\personal/"
      29    [5]  (PLUS)      "c:\ado\plus/"
      30    [6]  (OLDPLACE)  "c:\ado/"
      31    [7]              "C:\Users\jluchman\Documents\Statalist\"
      32  
      33  . 
      34  . mata: mata mlib index
      35  .mlib libraries to be searched are now
      36      lmatabase;lmataado;lmataerm;lmatafc;lmatagsem;lmatalasso;lmatamcmc;lmatamet
      37  > a;lmatami;lmatamixlog;lmatanumlib;lmataopt;lmatapath;lmatapostest;lmatapss;lm
      38  > atasem;lmatasp;lmatasvy;lmatatab;lb_statalist;lb_dominance;lmoremata;lmoremat
      39  > a10;lmoremata11;lmoremata14
      40  
      41  . 
      42  . mata: say_something()
      43  looks like it works
      44  . 
      45  end of do-file
    
    . 
    . file close bld
    
    .
    Joseph Nicholas Luchman, Ph.D., PStat® (American Statistical Association)
    ----
    Research Fellow
    Fors Marsh

    ----
    Version 18.0 MP

  • #2
    Dear Joseph,
    Years ago, I had the same problem. My solution is to create all my mlibs using Stata 12.
    I've made some commands and do-files such that all my packages are saved and zipped using Stata 12.
    I hope this helps.
    Kind regards

    nhb

    Comment


    • #3
      Thanks, Niels. I suspected that might be the case.

      For any who are interested, below also shows an extension of the previous example with an .mlib compiled in v16.1 but run in v 15.1 and produces the same behavior (as you suggested, Niels).

      A further question, and this might be directed more at StataCorp, is whether it is the version of Stata in which an .mlib is compiled or the version in which it is run that is key to performance. That is, would an .mlib compiled in v12 not be expected to be as fast as the same routine compiled in v17, even if both are run/executed in v17, given differences in the Mata complier across versions (i.e., v17's use of the Intel MKL)?

      - joe


      Code:
      . clear all
      
      . 
      . cd "C:\Users\jluchman\Documents\Statalist"
      C:\Users\jluchman\Documents\Statalist
      
      . 
      . **# Call V16 to compile
      . shell "C:\Program Files\Stata16/StataSE-64" /e do "C:\Users\jluchman\Documents\Statalist\lmbuild_it.do"
      
      . 
      . copy lmbuild_it.log lmbuild_it16.log, replace
      
      . 
      . file open bld using lmbuild_it16.log, read
      
      . 
      . local linenum = 0
      
      . 
      . file read bld line
      
      . 
      . while r(eof) == 0 {
        2.         
      .         local linenum = `linenum' + 1
        3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
        4.         file read bld line
        5.         
      . }
         1  
         2    ___  ____  ____  ____  ____ (R)
         3   /__    /   ____/   /   ____/
         4  ___/   /   /___/   /   /___/   16.1   Copyright 1985-2019 StataCorp LLC
         5    Statistics/Data analysis            StataCorp
         6                                        4905 Lakeway Drive
         7       Special Edition                  College Station, Texas 77845 USA
         8                                        800-STATA-PC        https://www.stata.com
         9                                        979-696-4600        [email protected]
        10                                        979-696-4601 (fax)
        11  
        17  Notes:
        18        1. Stata is running in batch mode.
        19        2. Unicode is supported; see help unicode_advice.
        20        3. Maximum number of variables is set to 5,000; see help set_maxvar.
        21  
        22  . do C:\Users\jluchman\Documents\Statalist\lmbuild_it.do 
        23  
        24  . clear all
        25  
        26  . 
        27  . do C:\Users\jluchman\Documents\Statalist\st_mata.mata
        28  
        29  . mata:
        30  ------------------------------------------------- mata (type end to exit) -----
        31  : 
        32  : void say_something() {
        33  > 
        34  > printf("looks like it works")
        35  > 
        36  > }
        37  
        38  : 
        39  : end
        40  -------------------------------------------------------------------------------
        41  
        42  . 
        43  end of do-file
        44  
        45  . 
        46  . lmbuild lb_statalist, replace dir(C:\Users\jluchman\Documents\Statalist\)
        47  (1 function added)
        48  existing library C:\Users\jluchman\Documents\Statalist\lb_statalist.mlib replac
        49  > ed
        50  
        51  . 
        52  end of do-file
      
      . 
      . file close bld
      
      . 
      . **# Call V15 do
      . shell "C:\Program Files (x86)\Stata15/StataSE-64" /e do "C:\Users\jluchman\Documents\Statalist\do_say.do"
      
      . 
      . copy do_say.log do_say15_cpl16.log, replace
      (file do_say15_cpl16.log not found)
      
      . 
      . file open bld using do_say15_cpl16.log, read
      
      . 
      . local linenum = 0
      
      . 
      . file read bld line
      
      . 
      . while r(eof) == 0 {
        2.         
      .         local linenum = `linenum' + 1
        3.         if !inrange(`linenum', 12, 16) display %4.0f `linenum' _asis `"  `macval(line)'"'
        4.         file read bld line
        5.         
      . }
         1  
         2    ___  ____  ____  ____  ____ (R)
         3   /__    /   ____/   /   ____/
         4  ___/   /   /___/   /   /___/   15.1   Copyright 1985-2017 StataCorp LLC
         5    Statistics/Data Analysis            StataCorp
         6                                        4905 Lakeway Drive
         7       Special Edition                  College Station, Texas 77845 USA
         8                                        800-STATA-PC        http://www.stata.com
         9                                        979-696-4600        [email protected]
        10                                        979-696-4601 (fax)
        11  
        17  Notes:
        18        1.  Stata is running in batch mode.
        19        2.  Unicode is supported; see help unicode_advice.
        20        3.  Maximum number of variables is set to 5000; see help set_maxvar.
        21  
        22  . do C:\Users\jluchman\Documents\Statalist\do_say.do 
        23  
        24  . adopath + "C:\Users\jluchman\Documents\Statalist\"
        25    [1]  (BASE)      "C:\Program Files (x86)\Stata15\ado\base/"
        26    [2]  (SITE)      "C:\Program Files (x86)\Stata15\ado\site/"
        27    [3]              "."
        28    [4]  (PERSONAL)  "c:\ado\personal/"
        29    [5]  (PLUS)      "c:\ado\plus/"
        30    [6]  (OLDPLACE)  "c:\ado/"
        31    [7]              "C:\Users\jluchman\Documents\Statalist\"
        32  
        33  . 
        34  . mata: mata mlib index
        35  .mlib libraries to be searched are now
        36      lmatabase;lmataado;lmataerm;lmatafc;lmatagsem;lmatamcmc;lmatamixlog;lmataop
        37  > t;lmatapath;lmatapostest;lmatapss;lmatasem;lmatasp;lmatasvy;lmatatab;lb_stata
        38  > list;lb_dominance;lmoremata;lmoremata10;lmoremata11;lmoremata14
        39  
        40  . 
        41  . mata: say_something()
        42  (say_something() in lb_statalist, compiled by Stata 16.1, is too new to be run
        43  by this version of Stata and so was ignored)
        44                   <istmt>:  3499  say_something() not found
        45  r(3499);
        46  
        47  end of do-file
        48  r(3499);
      Joseph Nicholas Luchman, Ph.D., PStat® (American Statistical Association)
      ----
      Research Fellow
      Fors Marsh

      ----
      Version 18.0 MP

      Comment


      • #4
        This is a bit deep for me, so let me just point out that the discussion in the documentation of the lmbuild command talks about version control and seems to suggest - to me, with my limited understanding - that compiling a Mata library under version control will produce a Mata library that will work as far back as that version.

        Comment


        • #5
          Hi there,
          I actually contacted Stata with this precise question.
          If using version control in Mata would allow me to make complied programs and work with earlier versions.
          Unfortunately, the answer was No, it doesn't work that way, which is because of the compiler version.
          They offered two solutions.
          1) compile with an earlier Stata version (my new CSDID2 is compiled with version 14)
          2) include the mata libraries as part of the main code. That way it compiles with the Stata version.
          I suspect that this is where the version control described by William plays a role.
          HTH

          Comment


          • #6
            Readers might be interested in this thread

            Comment


            • #7
              Would like to thank everyone for their responses and follow-up with, what I think, was a workable solution to this issue.

              For context, what I hoped to achieve is to create a single set of modular Mata functions that could be used in two different commands that take different arguments. Specifically, I wanted to write the code Mata code once (i.e., in a single .mata file) and use it in two separate commands. Previously I had repeated Mata the code in both .ado files.

              The original solution was to compile an .mlib file that both Stata commands would see/be able to access and call once it was loaded by Stata. The issue there is that .mlib-s are not backward compatible. Stata versions that should, ostensibly, work with the command were failing as the compiled Mata code would not load in versions earlier than the version in which I compiled the Mata function.

              The solution I found to this issue to keep the Mata code portable across Stata versions was to -quietly include- the .mata file with the -adopath- option in both .ado files prior to defining the programs in which the Mata code in the .mata file is called. This way, each version of Stata will load/compile the code in its version-specific way and the same effect is achieved as both .ado files will call the same .mata file.

              Again, wanted to share this in case others come across this issue and it is of some assistance to them.

              Joseph Nicholas Luchman, Ph.D., PStat® (American Statistical Association)
              ----
              Research Fellow
              Fors Marsh

              ----
              Version 18.0 MP

              Comment

              Working...
              X