Announcement

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

  • Problem with PUTEXCEL file cannot be saved and return code is 603

    Hi everyone,
    I am trying to use putexcel in a forvalues loop.
    At some point, the loop fails and I get the result " the file cannot be saved" and the return code assocaited with it is 603.
    I find some reference to it in the following webpage "http://www.stata.com/manuals13/m-5xl.pdf" but I cannot understand it .
    Does anyone has experienced it. I am not sure How I can circumvent this problem.
    Thank you,
    Anwar

  • #2
    There are a few possibilities:

    1. Although the Excel file you are trying to save exists, you do not have permission to access it on your system. See if it is read-only, or perhaps, if you are working on an enterprise computer, you may not have privileges to write to that file or the directory it's in. If this is the problem, you should encounter the error the very first time you try to write to the file. You say that "at some point the loop fails...," so I'm guessing it runs along for a while and then breaks after numerous successful accesses. If this is the problem, you need to get the privileges changed.

    2. If the file is in a location where it might be shared with others, somebody else may have opened the file--which precludes your making further modifications to it. In that case, trying again later may help. (Or you might have opened it yourself to "peek" at emerging results--don't do that!)

    3. Another possibility is that your loop runs so quickly that it exceeds the ability of your operating system to flush the buffers and write to the file. I have encountered this problem myself on numerous occasions, particularly (but not exclusively) when writing to a file on a networked drive. The solution here is to slow down the loop by inserting a -sleep- command just before or after each -putexcel- so as to give the operating system time to get caught up. You may have to experiment a while to find the smallest amount of sleep time you can get away with and solve your problem. If you're doing this on a network drive, another possible solution is to move the file temporarily to a drive on your own computer, run your code, and then move the file back to its original location--which may or may not be possible depending on your privileges over these files.

    There may be other possibilities that I don't know about, but these are the three that I, or people I know, have encountered.

    Comment


    • #3
      Hello Clyde
      Sleep works perfect. Thanks Clyde.
      Anwar

      Comment


      • #4
        Sorry to resurrect this thread, but for anyone Googling this error (this thread is the top result), the issue for me was Dropbox syncing. The difference is dramatic. With syncing paused, no sleep statement is necessary. With syncing enabled, sleep 1000 is needed between putexcel statements.

        Clyde mentioned "saving to a network drive" as a potential issue, but I didn't recognize that this, of course, includes Dropbox.
        Last edited by Geoff Clarke; 26 Sep 2018, 07:21. Reason: grammar

        Comment


        • #5
          The new "putexcel set ... , open" option should also now solve this problem, even with fast loops or Dropbox syncing -- it changes putexcel's behavior so that it does not write out changes to disk until the system receives the command "putexcel close".

          Comment


          • #6
            Originally posted by Isaac Maddow-Zimet View Post
            The new "putexcel set ... , open" option should also now solve this problem, even with fast loops or Dropbox syncing -- it changes putexcel's behavior so that it does not write out changes to disk until the system receives the command "putexcel close".
            White using sleep milliseconds worked well enough, I can confirm that putexcel set ... , open also works and does a better job of solving the problem with cloud syncing. Thanks everyone!

            Comment

            Working...
            X