Announcement

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

  • Variable __000000 already defined error (revisited) / eststo esttab error / "type mismatch error"

    I am not sure if this is a bug, but I would consider it one (or two)

    I define locals at the top of my .do file, and generate variables or run regressions based on those locals.
    However, something inside Stata seems to have changed, but the problem already happens right after loading the dataset.


    HTML Code:
    log     close _all
        macro drop _all
        cap drop __000000
    clear     all
    eststo  clear
    I run the following code
    HTML Code:
            reg cesd10a4std i.q, robust
            eststo diff1
            *esttab diff*
            macro list
            cap drop __000000
            esttab diff*
    If I do not run the line cap drop __000000, the line -esttab diff*- produces the the error "type mismatch".
    However, macro list that diff1 is stored in eststo. -cap drop __000000- removes this eststo, and then the code runs again.
    HTML Code:
    .                 macro list
    eststo_counter: 1
    eststo:         diff1
    S_E_depv:       cesd10a4std
    S_E_cmd:        regress
    S_E_vce:        Robust
    outpath:        G:\Shared drives\sharedStefan\---CHARLS\1-NRPS\outFiles
    myFolder:       C:\Users\User\Documents\RUG\---CHARLS
    myGoogle:       G:\Shared drives\sharedStefan\---CHARLS
    S_level:        95
    S_ADO:          BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
    S_StataSE:      SE
    S_OS:           Windows
    S_OSDTL:        64-bit
    S_MACH:         PC (64-bit x86-64)
    _rolloutyr:     rolloutyr
    S_FN:           C:\Users\User\Documents\RUG\---CHARLS\CHARLSdata\H_CHARLS_D_DataPanelreg.dta
    S_FNDATE:        3 Jul 2023 18:30
    This solution seems very patchy though. What is the root cause of this issue? I tried reinstalling the package estout, but that did not solve the issue.
    I do not think it is a Stata installation issue, since other files run as before. The problem must have to do with esttab or local macros.


    Edit: The problem is solved throughout the whole file when I put -cap drop __000000- right after my global directory paths, but I do not use any globals after this, only locals.
    Last edited by Castor Comploj; 14 Jul 2023, 02:07.

  • #2
    This seems difficult to diagnose without seeing more of your code and data. Please read Statalist FAQ 12. Remove as much as you can from your do-file and data while still being able to reproduce the "type mismatch" error, then post them both here.

    Comment


    • #3
      I seem to have found the solution to this (and its root cause). I confirm this is a bug of either esttab, or tempvar.
      In the data preparation file, I run the following:
      HTML Code:
          tempvar test
          gen     `test'=(cesd10a==. & cesd10a4!=.)
          reg     `test' age male ruralrsp wave if wave==1
          tempvar other 
          gen `other' =0
      This stores the following variables, locally (not globally):
      HTML Code:
      _other:         __000001
      _test:          __000000
      However, when moving to the next file and I run a regression, I use -eststo m1-. When using -esttab m1-, I get the error "type mismatch". At the same time, I noticed that inside -estpost-, I get the error variable __000000 already defined. This problem is also solved if I do not use tempvar in the data preparation do file.

      See the trace of the last error using -qui estpost sum `mainvars' `othervars' `w' if `sample2' & `grp'==1 `estpost_add'-
      HTML Code:
            = version 17: estpost_summarize  cesd10a4 cesd10a4std pubpen ipubpen age iwyr male cnear higov nchild  if s_twfe & nrps2011==1
      >  & s_ddr==1
              ---------------------------------------------------------------------------------------- begin estpost.estpost_summarize ---
              - version 8.2
              - local caller : di _caller()
              - syntax [varlist] [if] [in] [aw fw iw] [, ESample Quietly LISTwise CASEwise Detail MEANonly ]
              - if "`casewise'"!="" local listwise listwise
              = if ""!="" local listwise listwise
              - if "`listwise'"!="" marksample touse
              = if ""!="" marksample touse
              - else {
              - marksample touse, nov
      variable __000000 already defined
                _estpost_markout2 `touse' `varlist'
                }
              ------------------------------------------------------------------------------------------ end estpost.estpost_summarize ---
            -------------------------------------------------------------------------------------------------------------- end estpost ---
            }
          --------------------------------------------------------------------------------------------------- end eststo._eststo_store ---
          exit
          }
      I consider this a bug.

      Comment


      • #4
        Ah, this is https://www.statalist.org/forums/for...ng-in-data-set

        It's unrelated to esttab. The behavior is set up by tempvar and save, and in this case is triggered by marksample (which appears to tempvar in a trenchcoat). Looks like this behavior goes back to at least Stata 14, possibly earlier. I like the suggestion to drop __00* before saving. It sure seems like unintended behavior, but I'll report to StataCorp and report back if they give me more info by email.

        Comment


        • #5
          I got a response and posted about it here: https://www.statalist.org/forums/for...-with-datasets

          The short answer is you should drop all your temporary variables in your "data preparation do file" prior to saving.

          Comment

          Working...
          X