Announcement

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

  • What does _rc 111 mean in merge?

    I have a merge statement that returns 111 return code, but appears to have worked.

    Code:
    merge 1:m _taxsimid state year using `original'
    
    Result                           # of obs.
        -----------------------------------------
        not matched                             0
        matched                                 1  (_merge==3)
        -----------------------------------------
    Merge failed 111
    
                     _merge |      Freq.     Percent        Cum.
    ------------------------+-----------------------------------
                matched (3) |          1      100.00      100.00
    ------------------------+-----------------------------------
                      Total |          1      100.00
    Note that all (one) of the records matched, and I can list the record to confirm that the merge was done correctly. So what could be the problem causing the "Merge failed 111" error message?

  • #2
    Hmm...in the manual section [U] Chapter 8 Error Messages and Return Codes, section 8.1, error code 111 is listed as an error when no variables are defined (or found by that name).

    Also, error codes 100-199 are reserved for syntax errors (see the help file behind -help error-). The following possibilities are listed:
    • variable(s) not found/defeind
    • variable(s) out of order
    • variable(s) not found in using data
    • ambiguous abbreviation
    Could it be that one of your variables among -_taxsimid state year- were not found in the using dataset? Perhaps you could post a reproducible example?

    Comment


    • #3
      Answering my own post - 111 seems to be the default value for _rc until -capture- is executed. I forgot the -capture- on the -merge- statement, as is evident in the code snippet posted.

      Code:
      . di _rc
      111
      
      . capture di " "
      
      . di _rc
      0

      Comment


      • #4
        Originally posted by [email protected] View Post
        111 seems to be the default value for _rc until -capture- is executed
        No, it is not. Every session of Stata starts with the return code set to 0.

        Code:
        . display _rc
        0
        
        . capture display " "
        
        . display _rc
        0
        I second Leonardo's query: please provide a reproducible example(s).

        Best
        Daniel

        Comment


        • #5
          Originally posted by [email protected] View Post
          Answering my own post - 111 seems to be the default value for _rc until -capture- is executed. I forgot the -capture- on the -merge- statement, as is evident in the code snippet posted.
          I second daniel's response to this. Per the help file for -capture- (emphasis mine).

          capture executes command, suppressing all its output (including error messages, if any) and issues a return code of zero. The actual return code generated by command is stored in the built-in scalar _rc.
          I'm almost positive there's problem with your data setup.

          Comment


          • #6
            Could you post enough data code to reproduce the "Merge failed 111" output? It is very odd.

            As for the _rc code:

            111 seems to be the default value for _rc until -capture- is executed.]
            This isn't quite right. If you start Stata from scratch and try

            Code:
            display _rc
            you'll see that _rc is 0 to start with.

            _rc retains its value from one -capture- to the next regardless of the return codes of any commands in between, so _rc == 111 means that the most-recent -capture- caught a return code of 111:

            Code:
            clear
            * capture an r(111), since hmmmm does not exist:
            capture summarize hmmmm
            display _rc
            * a command that works, and hence has a return code of 0:
            display "This is just fine"
            * _rc still has the value from the last -capture-:
            display _rc

            Comment


            • #7
              I suppose it isn't reproducible on your system, it must be something special about our system, but here is my test case cut-and-pasted from my screen. The sysprofile.do executes without error when executed by itself but there is no profile.do, so attempts to execute that return r(601). Neither does a -capture- so neither should affect the _rc if the documentation cited above is applicable.

              Code:
              Notes:
                    1.  Unicode is supported; see help unicode_advice.
                    2.  More than 2 billion observations are allowed; see help obs_advice.
                    3.  Maximum number of variables is set to 5000; see help set_maxvar.
              
              running /disk/admin/Linux-7-local/stata15/sysprofile.do ...
              
              running /disk/homedirs/nber/feenberg/profile.do ...
              
              . di _rc
              111
              
              . capture di _rc
              
              . di _rc
              0
              This was run on Statamp 15.1 on a Linux 64-bit system. It is consistent.

              Daniel Feenberg

              Comment


              • #8
                Well, whatever is causing the return to be set to 111 must be inside

                Code:
                /disk/admin/Linux-7-local/stata15/sysprofile.do
                and/or

                Code:
                /disk/homedirs/nber/feenberg/profile.do
                We cannot see either content, so we cannot comment on that. My guess is that one of those files contains a capture statement that catches return code 111.

                However, I do not see how any of these files could possibly produce the error message

                Code:
                Merge failed 111
                that appears to be specific to merge (although the capitalization seems odd, too).

                Best
                Daniel

                Comment


                • #9

                  My sysprofile.do contains several -adopath.ado- commands. This is an unmodified -adopath.ado- as supplied with Stata. None print an error in the log when executed, but there are capture commands in -adopath.ado- that do not print a message for non-zero returns, perhaps because the situation is not an error. The matter is closed.

                  Comment

                  Working...
                  X