BookmarkSubscribeRSS Feed
juanvg1972
Pyrite | Level 9

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,

6 REPLIES 6
Kurt_Bremser
Super User

@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.

ybolduc
Quartz | Level 8

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.

juanvg1972
Pyrite | Level 9

I am using Unix.

 

Can you give an example of fuser command?

 

Thanks

ybolduc
Quartz | Level 8

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.

Kurt_Bremser
Super User

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:

  • data space
  • allocation table (shows used and free blocks)
  • inode table (this is what Windows does not have)

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.

SuryaKiran
Meteorite | Level 14

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?

Thanks,
Suryakiran

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 4584 views
  • 3 likes
  • 4 in conversation