BookmarkSubscribeRSS Feed
SASER
Fluorite | Level 6

Hello,

 

Could someone please suggest me a method/function that helps SAS not to stop/terminate when a non sas file like a LOG file is in use. The LOG file is not used/opened by me, I guess Windows or some third party app is doing it. Any suggestion would be of great use. 

 

Thanks. 

18 REPLIES 18
Reeza
Super User

Why would your SAS log file be locked? Virus scanner? 

SASER
Fluorite | Level 6
Thanks Reeza for the reply. Seriously I have no idea why it gets locked. I do not think its a virus scanner coz, this happens only to a "constant" couple of programs.
ChrisNZ
Tourmaline | Level 20

How do you use the file? is it a log file you write to via proc printto? or is this log file an input file that you need reading?

SASER
Fluorite | Level 6

Its a log file that I get from running SAS in BATCH. I do not use/read it other than in notepad++ to check where/how the program is. 

Reeza
Super User

@niranvijay wrote:

Its a log file that I get from running SAS in BATCH. I do not use/read it other than in notepad++ to check where/how the program is. 


So you open the log file in Notepad++ and then SAS throws an error because it's locked? What happens if you don't open file while process is running? Do you still get a File Lock?

SASER
Fluorite | Level 6

Reeza,

Not really. I look at the log only after the program has finished running. But I have the program itself opened in NOTEPAD++. But this file locking started to happen very recently. I know that Notepad++ dont keep a lock on the file, but still?. The worst part is that It happens randomly(days) to the same program. 

 

Thanks

Kurt_Bremser
Super User

If a file is explicitly locked for any type of access (not just write/update), there's nothing you can do except identify the process that holds the lock, and then terminate it.

 

Which is a very rude way to go about it. (And you need to have the rights/permissions to do this. I have found that the execrable Windows does not really have a "superuser" type UserID like UNIX. Even "the" Administrator is often unable to to stop a process, short of restarting the system.)

 

So, after having identified the offending process with operating system tools, check why the file is locked. If there is an update underway at the moment SAS tries to read the file, the lock is quite natural. In this case you have to set up time windows during which the file will not be updated so SAS can safely read it.

SASER
Fluorite | Level 6

Kurt,
Could you please tell me what you meant by "In this case you have to set up time windows during which the file will not be updated so SAS can safely read it."

 

Thanks

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Just going to ad to the great advice above, encountering file locks should be almost never.  If you are finding files locked then you have a structural or process fault.  For instance, if you have users who use the data, then don't have them doing that in the production branch, otherwise when you try to run production you will encounter this.  A way of seperating users working areas out from production (which should be run at fixed - known times) shuld remove file lock issues.

SASER
Fluorite | Level 6

I agree with what you have said,RW9. But in my case I have no idea why the log file gets locked. If I know that some app/OS is holding the lock, then I can manually terminate it. 

 

Thanks

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Speak to your IT team, they will help finding out what application is locking the file.  Text files generally don't get locked, so that is unusual.  That being said, my company has applications running the background which mirror files off to a backup, and that sometimes prevents me deleting files or folders, so it could be something like that.  Its a system thing though, not really a SAS problem.

SASER
Fluorite | Level 6

Thanks again RW9

ChrisNZ
Tourmaline | Level 20
Sadly this is a system issue. If you ask sas to use a file and the file is locked, sas will complain. You must fix this at the system level. Utilities like process explorer can tell you what processes use what file handles.
SASER
Fluorite | Level 6

Thanks ChrisNZ for your suggestion.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 18 replies
  • 2546 views
  • 0 likes
  • 7 in conversation