DATA Step, Macro, Functions and more

rename data set that is read-locked

Reply
Occasional Contributor
Posts: 10

rename data set that is read-locked

Hi

My issue is that when some process is reading data set i cannot rename it with sas utilities. E.g. "Change statement in datasets procedure". Sas says that "data set XX is in use by user YY" or something like that.

We now overcome this by issuing OS-commands. OS is Solaris. When we want to rename XX, we have macro that do "rm or mv XX".

I wonder, whether SAS actually has some way to do this without me going to issue OS-commands?
Occasional Contributor
Posts: 10

Re: rename data set that is read-locked

And when i try to use 'rename' or 'delete' function like that
data _null_;
sysrc=delete('TABLENAME');
run;
SAS says
The function DELETE is unknown, or cannot be accessed.
Trusted Advisor
Posts: 2,113

Re: rename data set that is read-locked

SAS is designed to "play well with others". It's behavior is consistent in not allowing you to rename a dataset while someone else is using it.

Unix was written with the philosophy that the user know what they are doing and will take the consequences of his behavior. If you rename a dataset with with the OS and the other user does another read, their process fails.

I think that you are stuck with using the OS to do the rename. BTW, other OSs will not allow you to do a rename while another process has a file open.
Occasional Contributor
Posts: 10

Re: rename data set that is read-locked

Processes in question are in ETL environment. In most cases they read tables only once.
So when they read and processes that builds table can't update table - this is the issue.
While doing UNIX-tied deletes and removes we can update tables well.

It's strange why not to have some options for this case.
Super Contributor
Super Contributor
Posts: 3,174

Re: rename data set that is read-locked

You may want to explore the behavior differences with the FILELOCKS system / CONFIG option. The SAS UNIX Companion Guide should have reference information.

Scott Barry
SBBWorks, Inc.
PROC Star
Posts: 1,567

Re: rename data set that is read-locked

>So when they read and processes that builds table can't update table - this is the issue.

A product called SAS/Share exists to manage multi-user table access, so you can read and write (as in update, not delete or rename, see below) tables at the same time

>In most cases they read tables only once. While doing UNIX-tied deletes and removes we can update tables well.

If the table is still locked, it is still being being read, unless the process does bizarre things. Your deleting/renaming will likely cause errors and abort the reading process. If it doesn't, maybe the reading process can release it earlier? Does it use sasfile statements or similar?
Ask a Question
Discussion stats
  • 5 replies
  • 164 views
  • 0 likes
  • 4 in conversation