Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For a SAS dataset, what is the best way to prevent locking for multiple user access

Tags:

sas

Thanks for reading this.

I am using a shared service (server=sharedLib) when setting up my libref, to allow users of my SAS/IntrNet application to modify and update (add new) records of a single dataset. The application will also be used to query my dataset. To minimize locking, I am only using a data step to modify and update rather than Proc SQL (which locks the entire member). However, I wonder if locking is more or less likely if only update/modify access to the data uses the share service but queries do not.

%if &type=QUERY %then %do ;
 LIBNAME lib '/myServer/library' ;
%end ;
%else %do ;
 LIBNAME lib '/myServer/library' server=shareLib ;
%end;

this isn't my actual code, but I do know whether or not the request is going to just send data back or modify an existing record or add a new record (update);

I had originally made this distinction because we were having some failures attaching to the share service (not sure that is the correct terminology), but referencing the lib to query the data did not fail. Since then we have, I think solved this problem, but I wondering if I am setting myself up for problems.

Thanks

like image 375
Jay Corbett Avatar asked Feb 21 '09 15:02

Jay Corbett


People also ask

How to remove lock from SAS dataset?

Re: Unlocking a locked a Locked dataset The only way to unlock the table is to kill the (SAS-) process locking the table - or to ask the user locking the table to close it.

What is a lock in SAS?

In Version 7 and Version 8 of SAS/SHARE software, a LOCK statement acquires an exclusive lock on the specified data object (that is a SAS data library, SAS data set, SAS catalog, or SAS catalog entry). No other user can read or write to a data object that you have locked by using the LOCK statement.

What does a lock is not available mean in SAS?

This happens when the dataset you are trying to generate is already there and again you are running it to generate it but this time either you or someone else has opened it and it is unable to overwrite the opened dataset.

What is the maximum length of SAS dataset name?

The maximum length of a data set name is 32 bytes. The first character must be an English letter (A–Z, a–z) or an underscore (_). Subsequent characters can be letters, numeric digits (0, 1, . . ., 9), or underscores. The name cannot contain blank spaces or special characters except for an underscore.


1 Answers

Since your question is more like a request for general advice on data access and concurrency in SAS, my answer will be formed as general advice, more than a specific solution.

There are excellent SAS online documentations. Please go visit the index, and find the information relevant for your further reading.

  1. Please have a further look at the "ACCESS=READONLY" libname option. It pretty much does what it says, namely restrict access to data members in the libname to be read-only. This holds the benefit that you don't alter your data by accident during a non-altering query. It also enables SAS to leave some room for data altering queries to get higher levels of control over the data.
  2. SAS/SHARE enables concurrent data access, so if you need to provide concurrent access (read/write) to the same data, SAS/SHARE is a good choice. It means that you can get away with assigning your libname just once, giving your libname statement the option "SERVER=SHARELIB", and have SAS/SHARE manage concurrent data access. If you assign the libname to your SAS/SHARE server process, all subsequent SAS processes needing access to this libname only have to assign the libname like "LIBNAME LIB SERVER=SHARELIB" (note there is no physical path - the SAS/SHARE server process takes care of that). This setup functions at its best if you have a separate SAS process for your SAS/SHARE server.
  3. You can also lock your libname with the LOCK statement or the LOCK command. This means that your SAS program can ensure itself exclusive access rights to a libname, in case that's what you need. Other SAS processes can then use the lock command to query a specific libname and see if it can get (exclusive) access.
  4. You can also control access on the data member level. This is done with the CNTLLEV data set option. For example "DATA LIB.MYDATA(CNTLLEV=LIB);" specifies that access control is at the library level, restricting concurrent access to only one update process to the library. CNTLLEV=MEM and CNTLLEV=REC restricts concurrent access at member level and record level respectively.

These options can be combined in many different ways, giving a lot of room for you to make access as fine-grained as you need. I hope these choices will help you complete your task.

like image 184
Martin Bøgelund Avatar answered Nov 15 '22 11:11

Martin Bøgelund