Announcement

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

  • metaxl: error _m not found

    Trying to run metaxl.do (ancillary file for the dm0014.pkg, see net describe dm0114, from(http://www.stata-journal.com/software/sj25-2)) to test metaxl written by the BPLIM-team (Gustavo Iglésias, Paulo Guimaraes, & Marta Silva; see The Stata Journal, 25(2), 285-308), the following command produces an error message I can't solve:
    Code:
    . metaxl extract, meta(meta1) replace
    _m not found
    r(111);
    I used set trace on to locate the error (extract here:
    Code:
              ----------------------------------------------------------------------------------------------------------------- end merge ---
            - if _rc {
              }
            - else {
            - qui replace label = "" if _m == 2
    _m not found
              qui count if _m == 1
              local m1_prob = `r(N)'
              if `m1_prob' {
              qui gen obs = "Label not used" if _m == 1
              local var_obs`lbl' "obs"
              }
              drop _m
              qui export excel value label `var_obs`lbl'' using `"`filename'"', sheet("vl_`lbl'", replace) first(var)
              }
              }
              frame drop `vlframe'
              }
              }
            ----------------------------------------------------------------------------------------------- end metaxl_extract.metavallab ---
          --------------------------------------------------------------------------------------------------- end metaxl_extract.descvars ---
    but this didn't help me to solve the issue. Any ideas?
    Last edited by Dirk Enzmann; 01 Jul 2025, 10:44.

  • #2
    Do you have set varabbrev off by any chance?

    Edit/added:

    I guess that _m is supposed to refer to the variable _merge that merge creates by default. If you disable variable abbreviations (which is a good idea, IMHO), Stata won't recognize _m as _merge. The authors should have spelled out _merge in their code. Anyway, a quick workaround is
    Code:
    varabbrev metaxl extract, meta(meta1) replace
    Last edited by daniel klein; 01 Jul 2025, 11:54.

    Comment


    • #3
      Excellent! This solves the issue.

      I have turned variable abbreviation off (permanently) because I think that is the better (safer) way. Indeed, the authors should modify their program accordingly because programs should be general.

      Thanks a lot!

      Comment


      • #4
        I replaced _m by _merge in the .ado-files "metaxl_cmp.ado" and "metaxl_extract.ado". A similar issue with variable abbreviation occurs in the .ado-files "metaxl_apply.ado" and "metaxl_diff.ado", here I replaced all variable names Feature by Features. If you don't want to wait for an update of metaxl and don't want to prefix the command by varabbrev (as suggested by daniel klein in #2), if you modify "metaxl_apply.ado" and "metaxl_diff.ado" yourself take care not to replace the name of the local macro `feature', hence, you should take care that you match the case of the characters when replacing Feature by Features.

        Additionally (if the authors will read this post): In the ancillary example file "metaxl.do" the command metaxl diff will produce warnings in red (not named as such), for example
        Code:
        . varabbrev metaxl diff, pattern(meta*) save(diff) diffonly replace
        Worksheet value_label_default not exported because of option diffonly
        Worksheet vl_ccitylbl not exported because of option diffonly
        Worksheet vl_gradlbl not exported because of option diffonly
        Worksheet vl_indlbl not exported because of option diffonly
        Worksheet vl_marlbl not exported because of option diffonly
        Worksheet vl_nev_mar not exported because of option diffonly
        Worksheet vl_racelbl not exported because of option diffonly
        Worksheet vl_smsalbl not exported because of option diffonly
        Worksheet vl_southlbl not exported because of option diffonly
        Worksheet vl_unionlbl not exported because of option diffonly
        Because I am not absolutely sure that this is what the authors intended I suggest to add a comment to this command in the .do-file "metaxl.do" to inform the users that the option diffonly is intentional and consequently some worksheets will not be exported.

        Comment


        • #5
          Unfortunately, to me metaxl is useless because I rely heavily on labeled missing values, but metaxl cannot handle extended missing values. With more than one labeled extended missing value metaxl cmp even produces a Stata error message (not an error message captured by metaxl). Here two examples.

          Example (a): One labeled extended missing value:
          Code:
          . sysuse auto, clear
          (1978 automobile data)
           
          . recode rep78 (. = .a)
          (5 changes made to rep78)
          
          . lab def rep78 1 "one" 2 "two" 3 "three" 4 "four" 5 "five" ///
          >               .a "not available"
          
          . lab val rep78 rep78
          .
          . metaxl extract, meta("meta_auto_1") replace
          
          File meta_auto_1.xlsx saved
          
          . metaxl check, meta("meta_auto_1")
          
            +----------------------------------------+
            | worksheet | warnings | inconsistencies |
            |-----------+----------+-----------------|
            |  vl_rep78 |        1 |               0 |
            +----------------------------------------+
          
          . metaxl uniform, meta("meta_auto_1") new("meta_auto_1_new") replace
          
          Codes in sheet vl_origin harmonized
          
          Codes in sheet vl_rep78 harmonized
          
          File meta_auto_1_new.xlsx saved
          Although threre are no warnings or error messages, the sheet "vl_rep78" in "meta_auto_1.xlsx" (created by metaxl extract) showing the value labels of variable "rep78" does not show the extended missing value .a (the respective cell in column "value" is empty) although the respective cell in column "obs" (indicating whether the value is used in the current data set) contains "Label not used" -- despite the fact that in the data two cases have the value .a.

          Example (b): Three labeled extended missing values
          Code:
          . sysuse auto, clear
          (1978 automobile data)
          .
          . recode rep78 (4 = .b) (5 = .c) (. = .a)
          (34 changes made to rep78)
          
          . lab def rep78 1 "one" 2 "two" 3 "three" ///
          >               .a "not available" ///
          >               .b "not applicable" ///
          >               .c "ambiguous"
          
          . lab val rep78 rep78
          .
          . metaxl extract, meta("meta_auto_2") replace
          
          File meta_auto_2.xlsx saved
          
          . metaxl check, meta("meta_auto_2")
          
            +----------------------------------------+
            | worksheet | warnings | inconsistencies |
            |-----------+----------+-----------------|
            |  vl_rep78 |        0 |               3 |
            +----------------------------------------+
          
          . metaxl uniform, meta("meta_auto_2") new("meta_auto_2_new") replace
          
          Codes in sheet vl_origin harmonized
          Different descriptions for the same code in sheet vl_rep78
          r(198);
          The metaxl error message is a consequence of the failure to handle extended missing values (metaxl check showed 3 inconsistencies). If in this situation one tries to compare the meta data of example (a) and example (b) using meta cmp, a Stata error message (of merge used in metaxl cmp) will be produced that is hard to locate for the user because metaxl does not capture the source of the problem:
          Code:
          . metaxl cmp, f1("meta_auto_1") f2("meta_auto_2") replace
          variable value does not uniquely identify observations in the master data
          r(459);
          Last edited by Dirk Enzmann; 01 Jul 2025, 18:34.

          Comment


          • #6
            Correction of #5: The last error message shown is actually issued by metaxl cmp (it is not an error message of merge). However, the reason might be obscure to a user who is not aware that it is a consequence of several labeled extended missing values (the extended missing values themselves are not shown in the Excel file generated by metaxl extract).

            Comment


            • #7
              Dirk Enzmann is correct: metaxl_extract does not handle extended missing values correctly. The code does not seem to work directly on value labels but pick the (non-missing) values from the variables, then merge with the respective labels. From a quick glance, it might suffice to change
              Code:
              drop if missing(`var')
              in line 336 of metaxl_extract.ado to read
              Code:
              drop if `var' == .
              to get a workaround. Rewriting the entire section to work directly on value labels would probably be the better approach, though.

              By the way,
              Code:
              qui label dir
              foreach vl in `r(varlist)' {
              in lines 48 and 49 of the same file seems odd. What the authors probably wanted is
              Code:
              qui label dir
              foreach vl in `r(names)' {

              Comment


              • #8
                Unfortunately, the suggestion in #7 to change the code in line 336 of "metaxl_extract.ado" will not solve the problems described in #5 because the values (in column "value") of the value labels of variable rep78 in the Excel files created by metaxl extract are wrong: The values of extended missing values are not shown in the corresponding cells in column A "value". This would not change if additionally you would change the code in lines 48 and 49. By the way: The corresponding error message in lines 52 to 55 of "metaxl_extract.ado" talks about 27 characters and I believe it should be 25.

                If your dataset contains extended missing values (at least if they are labeled) you should not use metaxl (version 0.4 29Aug2024) until the authors fixed the problems.
                Last edited by Dirk Enzmann; 03 Jul 2025, 03:45.

                Comment

                Working...
                X