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.
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?
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.
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.
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.
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.