LOCK Statement

Places an exclusive lock on a specified data object.
See: Locking SAS Data Objects

Syntax

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

Syntax Description

libref
specifies the name of a SAS library that is currently accessed through a SAS/SHARE server.
member-name
specifies the name of a member in the library libref that is to be locked.
member-type
specifies the type of SAS file to be locked. Valid values are DATA, VIEW, and CATALOG. The default is DATA.
If member-type is omitted or is specified as the value DATA or VIEW, two locks are obtained: one lock on libref.member-name.DATA and the other lock on libref.member-name.VIEW.
entry-name
specifies the name of the catalog entry to be locked.
entry-type
specifies the type of the catalog entry to be locked.
LIST
writes to the SAS log whether the specified data object is locked and by whom. This argument is optional.
Aliases:QUERY

SHOW

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.
For more information about how and when a lock is released, see Locking SAS Data Objects.

Examples

Example 1

In the following example, the first LOCK statement acquires implicit locks on the SAS 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.
lock educlib.mycat.choice1.menu;
lock educlib.mycat.choice2.menu;

Example 2

In the following example, 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.
/* Update the two catalog entries as needed. */
lock educlib.mycat.choice1.menu clear;
lock educlib.mycat.choice2.menu clear;