Chapter Contents

Previous

Next
SAS/SHARE User's Guide

LOCK Statement

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. You cannot lock a data object that another user is working on.

You must first access a SAS data library through a SAS server before you can lock that library or any data object in it.

When you use a LOCK statement to lock a data object, you can open that data object as often as you want and in any mode that you want (for example, to create, replace, update, or read the object), as long as your PROC or DATA step does not conflict with what is allowed by the engine that is used by the SAS server to access the data object.

You release a lock on a data object by using the CLEAR argument in the LOCK statement. To find out if a data object is locked and by whom, use the LIST argument in the LOCK statement.


Syntax

LOCK libref<.member-name<.member-type |
.entry-name.entry-type>>
<LIST | QUERY | SHOW | CLEAR>;

libref
is a valid SAS name that refers to a SAS data library that is currently accessed through a SAS server, that is, the server library.

member-name
is a valid SAS name that specifies a member of the SAS data library that is associated with the libref.

member-type
is the type of the SAS file to be locked. Valid values include DATA, VIEW, and CATALOG. The default is DATA.

If member-type is omitted or it is specified as the value DATA or VIEW, two locks are obtained: one on libref.member-name.DATA and the other on libref.member-name.VIEW.

entry-name
is the name of the catalog entry to be locked.

entry-type
is the type of the catalog entry to be locked.

LIST|QUERY|SHOW
writes to the SAS log whether the specified data object is locked and by whom. This argument is optional.

CLEAR
releases a lock on the specified data object that was acquired by using the LOCK statement in your SAS session. This argument is optional.

See Locking SAS Data Objects for more information about how and when a lock is released.


Examples

lock educlib.mycat.choice1.menu;
lock educlib.mycat.choice2.menu;
/* Update the two catalog entries as needed. */
lock educlib.mycat.choice1.menu clear;
lock educlib.mycat.choice2.menu clear;

The first LOCK statement acquires implicit locks on the SAS data library EDUCLIB and on the SAS catalog EDUCLIB.MYCAT. It then acquires an explicit lock on the catalog entry EDUCLIB.MYCAT.CHOICE1.MENU. The second LOCK statement acquires an explicit lock on the catalog entry EDUCLIB.MYCAT.CHOICE2.MENU.

The first LOCK statement that contains the argument CLEAR releases the explicit lock on the catalog entry CHOICE1.MENU, but it does not release the implicit locks because an entry in the catalog is still locked. The second LOCK statement that contains the argument CLEAR releases the explicit lock on the catalog entry CHOICE2.MENU. Because no catalog entries remain locked, the second statement that contains the argument CLEAR also releases the implicit lock on the SAS catalog EDUCLIB.MYCAT. Because no other members of the library are locked, it also releases the implicit lock on the SAS library EDUCLIB.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.