BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi, we create a lot of excel and text files that are picked up by users. From time to time someone will have the file open when we are trying to overwrite it, which generates the following error in the log :
ERROR: File is in use, \\svrbu3file\etc........

I'm looking for a way of trapping this error and doing something in the code when it occurs. I tried checking syscc but it is still 0. Has anyone else had this problem or anyone able to offer a suggestion?

Thanks.
2 REPLIES 2
deleted_user
Not applicable
Further investigation shows a proc export will set the syscc to 1012 however when using ods syscc is still 0.

Naturally it is ods that we are using 😞

So if you know a way to check a file in use when creating a file using ods .... 🙂
DanielSantos
Barite | Level 11
Try to open the file through the external file functions, for example like this:

%let FILENAME=D:\temp\Teste.xls;
data _null_;
RC=filename('MYFILE',"&FILENAME");
FID=fopen('MYFILE','I');
if not FID then put "File &FILENAME is in use!";
else put "File &FILENAME opened successfully.";
RC=fclose(FID);
run;

FOPEN functions returns a file identifier (non zero integer) if the file was opened successfully.

See more on this here:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000209683.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2122 views
  • 1 like
  • 2 in conversation