01-17-2012 05:53 PM
A scheduled job creates an ODS HTML file with a table of contents five times daily, with the following error occurring 11 times over the last 150 executions:
"ERROR: File is in use"
pointing to the HTML body file. If I re-run the report, the file is usually (but not always) open for write by the time I detect the error. There's at least 35 minutes between any two executions.
The destination directory (Windows XP) is restricted to read-only for all clients, so I suspect that my report job might be the culprit. Any idea as to how SAS might be leaving a file open, or why ODS HTML CLOSE wouldn't assure a close? Or should I suspect something else?
01-17-2012 07:04 PM
I might be misunderstanding, but are you trying to write the same file the that is a 'read only' for clients?
Even if someone didn't have write access having a file open in read only would cause issues for SAS I'd guess.
Ideally you should be creating the file somewhere then calling a second job that copies the relevant files to the read only location probably using X commands upon successful completion of the first file.
01-17-2012 07:30 PM
The directory in which the file resides is read-only for clients (to prevent them from locking the file), but I have full control. 93% of the time, my scheduled job rewrites the file without problem.
Your idea of creating a local copy and copying to the public location might be a good one for more than one reason, but I don't see how it solves the problem of the file lock. If something in SAS is locking the file (and I don't know where else it comes from), then the lock will affect the local copy. If it's a network problem, then COPYFILE will be affected.
Thanks, though; it gives me something to try.
01-17-2012 08:25 PM
I created a file using the following code:
ods html file='C:\temp.html' style=meadow;
proc print data=sashelp.class;
ods html close;
I then opened the file in Read Only mode and tried to re-run my SAS code and got the same error.
AFAIK SAS can't replace the file while its open so someone has the file open when you're trying to rewrite the file.
Not sure about the windows system process.
01-17-2012 10:47 PM
Not so -- I update the file while it is being read through multiple browsers. Some applications (e.g., MS/Word) will put an exclusive hold on the file -- if they are permitted. For that reason, I make the directory read-only for my users. If they try to open it with MS/Word, it opens read-only.