Hi, I would like to know if it is possible to know in SAS which person has locked a SAS table.
Is it possible??
Thanks in advance,
@juanvg1972 wrote:
Hi, I would like to know if it is possible to know in SAS which person has locked a SAS table.
Is it possible??
Thanks in advance,
I use the ps command to retrieve information about the process that has a file open. If you need to know all processes that have an active file handle on the file, use the fuser command.
Hi Juan,
It will highly depend on your operating system. In Windows, you can use the Resource Monitor to search the "Associated Handles" this would give you the PID(s) that locks the file. You then use the task manager to find the user owning the culprit process.
If UNIX/Linux, as Kurt pointed out, the fuser command will do it for you.
Thanks.
I am using Unix.
Can you give an example of fuser command?
Thanks
Pretty straightforward: fuser [filename]
For more information, you can run the "man fuser" command on any UNIX/Linux box or refer to the following page: http://man7.org/linux/man-pages/man1/fuser.1.html
Luckily for you, on a UNIX/Linux environment, you can easily automate unlocking datasets thru shell scripting.
If your problem lies in updating a dataset that's opened by other users, I have created a macro that helps in this by using operating system commands to remove the file.
UNIX has a different layout of filesystems than Windows:
Filenames in directories are just links to the inode table (in Windows the filename in the directory is a link to the allocation table); a physical file (represented by an inode that contains allocation information) can have several links pointing to the same inode. Removing such a link does not immediately remove the physical file. As long as an open file handle for the inode (not the filename!) exists, the file will keep on existing even when all links to it have been removed; only when the last file handle is closed will the inode be removed and the physical space be freed.
This allows to "remove" an open file.
My macro determines the physical filename from the library path and the dataset name, and issues a rm command. Other processes that have the file open will keep on "seeing" the old version until they close/reopen the dataset.
Base SAS don't have any functionality to know which user locked the dataset. You can know by running the operating system commands. Which operating system are you using?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.