Announcement

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

  • Error 9901 in Excel export

    Hi, I'm getting the following error when trying to export this dataset to Excel: https://drive.google.com/open?id=0B3...W91SVlMbzlzX1k

    Code:
    export excel using file.xlsx, firstrow(variables) replace
          _xlshwritestrcol():  9901  Stata returned error
    export_excel_write_file():     -  function returned error
    export_excel_export_file():     -  function returned error
                     <istmt>:     -  function returned error
    It exports fine as a CSV but I'm confused as to why there is an issue with Excel export.



  • #2
    This might happen if you are trying to export the data to the current directory which might happen to be a system directory. Sometimes, your operating system does not allow files to be written to such directories. I tried the following, and worked fine. So try to export the data to a different directory than the one you have been trying.

    Code:
    use "C:\Users\Attaullah Shah\Downloads\NHS_cultures.dta", clear
    export excel using "C:\Users\Attaullah Shah\Downloads\out.xls"
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Thanks, looks like it was a weird permissions issue (system was unable to write anything to that directory, despite my being able to work in it directly, save Stata files, etc). I reset permissions for the directory and it's working now.

      Comment


      • #4
        Hi,

        I am having the same issue where my data is as follows and I cannot export it as excel:

        domicile Household_size
        Rural 4.59587
        Urban 3.88085
        Yerevan 3.23244

        A second ago, I was exporting fine but now I get this error message:
        _xlshwritestrcol(): 9901 Stata returned error
        export_excel_write_file(): - function returned error
        export_excel_export_file(): - function returned error
        <istmt>: - function returned error


        I have permission to save into my current directory so I'm quite confused.

        This is my code:
        export excel using demographic_data, firstrow(variables) sheet("Average household size by strata")

        I'm adding it to an existing xls file.

        Thanks in advance for any assistance.

        Comment


        • #5
          I think you should contact the Stata support team.
          Regards
          --------------------------------------------------
          Attaullah Shah, PhD.
          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
          FinTechProfessor.com
          https://asdocx.com
          Check out my asdoc program, which sends outputs to MS Word.
          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

          Comment


          • #6
            I had this issue and STATA support helped me and said the following:

            You may have invalid UTF8 characters in your dataset. You will need to run -unicode translate- or use the -locale()- option with -export excel- to export your data correctly

            . unicode analyze example.dta


            or

            ------------------------------------------------------------------------------
            . export excel using example.xlsx, nolabel firstrow(variables) locale(C)

            Both options worked for me.

            Best,
            Paul M.

            Comment


            • #7
              I just had this 9901 error and it turned out to be the length of the sheet name... they're limited to 31 characters... (posting for completeness in case someone else happens across this post and had the same issue I had)

              Comment


              • #8
                Originally posted by Alan Haynes View Post
                I just had this 9901 error and it turned out to be the length of the sheet name... they're limited to 31 characters... (posting for completeness in case someone else happens across this post and had the same issue I had)
                How did you fix this issue?

                Comment


                • #9
                  Originally posted by Son Dinh View Post
                  How did you fix this issue?
                  Code:
                  set obs 1
                  generate byte one = 1
                  
                  capture noisily export excel using `c(pwd)'/Test.xlsx, sheet(`="A"*32') firstrow(variables)
                  
                  *
                  * Begin here
                  *
                  export excel using `c(pwd)'/Test.xlsx, sheet(`="A"*31') firstrow(variables)

                  Comment

                  Working...
                  X