Announcement

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

  • Error with number of variables to export excel - STATA 15

    Hello,

    My dataset has 1,562 variables. I wanted to export all variables to Excel. However, I was not able to export it and the error message was "too many or no variables specified". I used drop down options to export (i.e., File> Export>Data to Excel spreadsheet). I left the "variables" box empty as recommended for exporting all variables and I checked the "save variable names to first row in Excel file".

    I am using Stata/IC 15.

    I saw another post asking about the similar topic and trying to export using .xlsx file, but it doesn't work...

    If you know what is wrong or why I cannot export all variables of my dataset to Excel, pleas advise.

    Thank you so much in advance,

  • #2
    I think it is a good idea to check the specification of the limits of your version of Excel, although if I recall correctly, most recent versions of Excel can accommodate up to 16000 columns (variables).
    Another option could be to export in other formats such as .csv or .txt and then try to convert them to Excel.

    Comment


    • #3
      Played around with this a bit.
      You should be able to do this by exporting to xlsx.
      Exporting to xls goes up to 256 variables, anything over will throw the 'too many or no variables specified'

      Code:
      *does not work:
      clear
      set obs 10
      forval v=1(1)257{
      gen v`v'=runiform()*`v'
      } 
      export excel using "test export.xls", firstrow(variables) replace
      *returns error 'too many or no variables specified'
      changing export format to xlsx:
      Code:
      *works:
      clear
      set obs 10
      forval v=1(1)1600{
      gen v`v'=runiform()*`v'
      } 
      export excel using "test export.xlsx", firstrow(variables) replace
      And when pushing it:
      Code:
      *does not work:
      clear
      set maxvar 100001
      set obs 10
      forval v=1(1)100000{
      gen v`v'=runiform()*`v'
      } 
      export excel using "test export.xlsx", firstrow(variables) replace
      /*
      returns error:
      variables must be between 1 and 16384


      Comment


      • #4
        Thank you so much for your reply. I tried to do it with .csv, but when I do it, discrepancies between variables and answers happen.
        For example, even if the collum is asking about the place, the answers come from other variables... Stata has a correct data sets, so there are some issues happening when exporting data from Stata to .csv
        Does anyone have any clue for this?

        Comment


        • #5
          What code did you use, and what is the error code (or what goes wrong) when you export to xlsx? That should work.

          Comment


          • #6
            Did you follow the advice given in #3 by @Jorrit Gosens? As noted in #5 it would be helpful if you showed your Stata code.

            Comment


            • #7
              Thank you so much everyone! Solved the problem, didn't work anyways you suggested, but I go to "Data Editor" and just copy all the cells and paste them into a xlxs file.

              Comment


              • #8
                Good to hear you found a fix, but it can be done as suggested in #3. Without seeing code and a data example we are all just guessing what the problem might be though.

                Comment

                Working...
                X