Announcement

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

  • command export excel

    Dear all,

    Few cases supports the "export excel" command? or I'm wrong or use the command

    code:

    export excel using "`dir_HCG'\D_obs_serv_16_HCG.xls", firstrow(variables) replace
    too many or no observations specified


    thank you very much

  • #2
    Export as D_obs_serv_16_HCG.xlsx, not D_obs_serv_16_HCG.xls. The .xls file ending tells it to use Excel '97/2003 format, which has a 255 column/65,536 case limit. The .xlsx file ending tells it yo use the newer format, which has a 16,384 column/1,048,576 row limit.

    Comment


    • #3
      change the file format to xlsx and displays the error:

      . cd "`dir_HCG'"
      D:\Mis documentos\Rev_mat_statav3\HCG

      . export excel using "D_obs_serv_16_HCG.xlsx", firstrow(variables) replace
      file D_obs_serv_16_HCG.xlsx could not be saved


      Comment


      • #4
        Do you have permissions to write to the HCG directory?

        You haven't shown us exactly what Stata returned to you -- what was the full error message? It may be informative. (Follow the Forum FAQ advice to show everything; and preferably report it within CODE delimiters, as described in section 12 of the FAQ -- it really helps legibility.)

        Talking of the FAQ, please re-register to use your real name (firstname lastname). It's easy -- just hit the Contact Us button at bottom right of screen and make your request.

        Comment


        • #5
          Another possibility for the "file ... could not be saved" message. If you are running a loop doing a whole bunch of -export excel- commands, the CPU can outpace the hard drive's ability to write these files. If you are in this situation, try inserting -sleep 50- after each -export excel- to give the hard drive some time to catch up. This happened to me once, and Tech Support taught me this trick.

          Comment


          • #6

            @Stephen yes I have permissions to write

            @Clyde - add the sleep command and got the same result

            Code:
             sleep 10000
            
            . export excel using "`dir_HCG'\D_obs_serv_16_HCG.xlsx", firstrow(variables) replace
            file D:\Mis documentos\Rev_mat_statav3\HCG\D_obs_serv_16_HCG.xlsx could not be saved
            r(603);

            Comment


            • #7
              Another possibility to investigate: the full path and filename you are trying to save to is 60 characters long. Some versions of Windows will not accept a pathname that long. Can you get it to work if you use a shorter filename?

              Comment


              • #8
                The other thing I can think of that's worth checking is whether you have a previous copy of the file open in excel? If excel has the file open it locks it so Stata can't replace it.

                Comment


                • #9
                  I notice that
                  Code:
                  . error 603
                  file could not be opened
                  r(603);
                  which, interestingly, refers to opening not saving! But, whatever, it turns out not to be very helpful. I suspect you have to contact Tech Support.
                  Meanwhile, I'm unsure whether your use of sleep matches what Clyde helpfully suggested. I'm sure he'll say!

                  Comment


                  • #10
                    Just for kicks, try:
                    • re-booting the machine (sometimes solves unexplainable issues, perhaps a process in the background with a lock on the file)
                    • fully-specifying the path, instead of using a macro. Again, more voodoo than a real explanation, but simplify, simplify.
                    • Use a different filename. The first step (re-booting) should make this moot, but if voodoo works, run with it

                    Comment


                    • #11
                      I did it!

                      I re-booting the machine and only open stata, any other software. the problem was the ability to use the processor

                      thank you very much

                      @ben @stephen @Sarah @clyde


                      Comment

                      Working...
                      X