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.
Why would your SAS log file be locked? Virus scanner?
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?
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.
@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?
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
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.
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
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.
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
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.
Thanks again RW9
Thanks ChrisNZ for your suggestion.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.