Announcement

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

  • Problem with importing excel on new MacBook

    Hi,

    I recently started working on a new MacBook from my old MacBook (i.e. I transferred all files, and am now using the new MacBook, Stata 12 on both devices). The Do-files were working perfectly fine on my old Mac, and are also working fine on my new Mac. However, one of my Do-files start with importing an Excel file. When I move the Excel file in question from my old Mac to my new one, and I do not open the file in Microsoft Excel (2016) first, the Excel file can be imported and the Do-file works perfectly fine. However, when I first open the file on my new Mac (regardless of whether I make any changes) I would get the following error:
    Code:
    . * Import Data:
    . import excel "/Users/Rob/Documents/PhD Exercise Science/3. Data/Data_list_statalist.xlsx", sheet("All_data") clear
    file /Users/Rob/Documents/PhD Exercise Science/3. Data/Data_list_statalist.xlsx could not be loaded
    r(603);
    I have attached the excel spreadsheet that is not working (i.e. after I opened and saved it on my new MacBook).

    Can anyone reproduce this error, and is there a solution?

    Another piece of information that may be important is that on my Old Mac I used MS Excel 2011, and on my new Mac I use MS Excel 365 (2019?).

    Thanks so much.
    Attached Files
    Last edited by Rob Henst; 28 Feb 2019, 05:38.

  • #2
    And here is exactly the same file, after I open it in Excel 2011 on my old MacBook, which runs fine on both MacBooks, as long as I don't open it on my new MacBook There appears to be something that Excel from office 360 is doing, that makes the file not readable in Stata.
    Attached Files

    Comment


    • #3
      r(603) is a code for problems with Stata, or you, having insufficient privileges for that folder. First try to copy the file to another location and import excel from there.

      Comment


      • #4
        Thanks for your quick reply.

        Location does not seem to be the issue. I tried opening the error-file from another location, and it would still give the same error. On the other hand, if I import the working file from that same folder, it would import without any problems.

        My problem persists.

        Comment


        • #5
          I can import either file in Stata. Bit of a weird data layout but no errors. That's on 15.1
          Code:
          import excel "Downloads\Data_list_statalist.xlsx", sheet("All_data") firstrow clear
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input double(A B C D E F G)
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
          .9937962962962964 .21046296296296296 6.5   312 285.5    24   21
                          .                  .   .     .     .     .    .
          .9605324074074074 .26122685185185185   4   433 410.5  13.5 18.5
                   .9209375 .20913194444444447   0   415 350.5  41.5 64.5
          .9057638888888889                .22   1 452.5 379.5  68.5   72
          .9658796296296296  .2485185185185185   5   407   368    64   34
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
                          .                  .   .     .     .     .    .
          .9394212962962962 .20608796296296297 6.5   384   281 285.5 96.5
                          .                  .   .     .     .     .    .
          .9428935185185185 .26928240740740744 3.5 470.5 452.5  58.5 14.5
                          .                  .   .     .     .     .    .
          .9107291666666667 .22913194444444443   4 458.5 441.5  68.5   13
          end

          Comment


          • #6
            This is a difficult problem to assist with, because few of us have Stata 12 available to experiment with. Let me ask the following questions:
            • if you copy the file in post #1 - which has been opened in Office 365 - back to your old MacBook, can Stata 12 open it there?
            • if you create a new workbook in Excel on your new MacBook, can Stata 12 then open it on your new MacBook?

            Comment


            • #7
              Originally posted by Jorrit Gosens View Post
              I can import either file in Stata. Bit of a weird data layout but no errors. That's on 15.1
              Code:
              import excel "Downloads\Data_list_statalist.xlsx", sheet("All_data") firstrow clear
              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input double(A B C D E F G)
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              . . . . . . .
              .9937962962962964 .21046296296296296 6.5 312 285.5 24 21
              . . . . . . .
              .9605324074074074 .26122685185185185 4 433 410.5 13.5 18.5
              .9209375 .20913194444444447 0 415 350.5 41.5 64.5
              .9057638888888889 .22 1 452.5 379.5 68.5 72
              .9658796296296296 .2485185185185185 5 407 368 64 34
              . . . . . . .
              . . . . . . .
              . . . . . . .
              .9394212962962962 .20608796296296297 6.5 384 281 285.5 96.5
              . . . . . . .
              .9428935185185185 .26928240740740744 3.5 470.5 452.5 58.5 14.5
              . . . . . . .
              .9107291666666667 .22913194444444443 4 458.5 441.5 68.5 13
              end
              Thanks Jorrit. Did you not open the Excel file on your computer first? Because if you did, you did not replicate my problem.

              The layout is weird, I am sure, I just captured a part of the data sheet.

              Comment


              • #8
                No, didn't open it. Just downloaded and imported.

                Comment


                • #9
                  Originally posted by William Lisowski View Post
                  This is a difficult problem to assist with, because few of us have Stata 12 available to experiment with. Let me ask the following questions:
                  • if you copy the file in post #1 - which has been opened in Office 365 - back to your old MacBook, can Stata 12 open it there?
                  • if you create a new workbook in Excel on your new MacBook, can Stata 12 then open it on your new MacBook?
                  Thanks William. I understand what you're saying about few of you having Stata 12.

                  Question 1: No, Stata can also not open a file on my old MacBook, when it has been opened in Office 365 on my new MacBook.
                  Question 2: Great question! In this case, Stata can also not read the file.

                  So it seems that it has nothing to do with the data sheet (which is a relief), but it does have something to do with Stata 12 (not Office 365, because it opens fine in Stata 15, to it seems). If no-one can replicate the problem using Stata 15. It seems that a sensible thing to do is upgrading to Stata 15?

                  Comment


                  • #10
                    Originally posted by Jorrit Gosens View Post
                    No, didn't open it. Just downloaded and imported.
                    Thanks for letting me know. Time to upgrade then!

                    Comment


                    • #11
                      Just to close the loop: I upgraded to Stata 15, and the files now open.

                      For anyone coming across this post experiencing the same problem. It seems to be an incompatibility problem between Office 365 and Stata 12. Using an older version of office (tested on Office 2011 for Mac), or upgrading to a newer version of Stata (tested for Stata15 SE), solved the issue.

                      Thanks Jorrit and William for your input. It's much appreciated.

                      Comment

                      Working...
                      X