Announcement

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

  • error r(9901) using table1_mc

    Hello all -

    I'm using table1_mc to output a series of descriptive tables to different tabs in an excel workbook and when I get to the 4th table, I get the following error code:

    _xlshwritestrcol(): 9901 Stata returned error
    export_excel_write(): - function returned error
    export_excel_write_file(): - function returned error
    export_excel_export_file(): - function returned error
    <istmt>: - function returned error
    r(9901);


    I'm not sure what this means so can't troubleshoot. Have others experienced this error in table1_mc before, and what have you done to resolve it?

    Thanks so much,
    Alison

  • #2
    Ran into this issue. It's likely one of the variables created for the purpose of descriptive tables contain characters that either Excel does not like or Stata does not like exporting to Excel. I was running:

    Code:
    foreach f of local files {
        use "${dtapth}/`f'", clear
        
        describe, replace clear
        list 
        local fname = subinstr("`f'",".dta","",.)
        export excel using "${upath}/data/`fname'.xls", replace first(var)
    }
    to export a bunch of codebooks for a list of dta files in dtpath. It resulted in the error until I corrected with

    Code:
    foreach f of local files {
        use "${dtapth}/`f'", clear
        
        describe, replace clear
        rmaccents varlab, replace
        replace varlab = usubinstr(varlab, "`=uchar(65533)'", "_", .)
        list 
        
        local fname = subinstr("`f'",".dta","",.)
        
        export excel using "${upath}/data/`fname'.xls", replace first(var)
    }
    Code:
    rmaccents
    removes all non-english accents.
    Check out https://www.statalist.org/forums/for...tring-variable to find out what character code for the weird symbols you need to use with
    Code:
    usubinstr

    Comment

    Working...
    X