Chapter Contents

Previous

Next
SAS/SHARE User's Guide

Locking Explicitly in a SAS Window (LOCK Command)

The LOCK command provides a convenient way to lock data objects within a SAS window. As in the LOCK statement, you can use the LOCK command to obtain an explicit lock on the following data objects:
data library
data set
catalog
catalog entry.

You can specify the name of the data object that is to be locked on the command line of a window, such as the Program Editor window in the SAS Display Manager System.

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

The syntax for the LOCK command is

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

libref
is a valid SAS name that serves as a symbolic link to a SAS data library.

member-name
is a valid SAS name that specifies a member of the referenced data library.

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

If you omit member-type or if you specify either the value DATA or VIEW, two locks are obtained automatically: one on libref.member-name.DATA and one on libref.member-name.VIEW.

entry-name.entry-type
is the name and type of the SAS 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.

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

For details about releasing locks, see Clearing an Explicit Lock.


Setting and Clearing Locks by Using the LOCK Command

You can issue the LOCK command in any SAS window. It works exactly like the LOCK statement. For details about the LOCK statement, see The LOCK Statement and the LOCK Command.

Locking a Catalog Entry shows that the catalog MAPSLIB.MAPSCAT.ASIAMAP.CMAP has successfully been locked. From the Program Editor window, the LOCK command was issued to obtain a lock on another catalog- MAPSLIB.MAPSCAT.EUROMAP.CMAP.

Locking a Catalog Entry
   LOG
    Command ===>

    1   LIBNAME MAPSLIB 'SASXYZ.SHRTEST.SASDATA' SERVER=SHARE1;
    NOTE: Libref MAPSLIB was successfully assigned as follows:
          Engine:        REMOTE
          Physical Name: SASXYZ.SHRTEST.SASDATA
    NOTE: MAPSLIB.MAPSCAT.EUROMAP.CMAP is now locked for 
          exclusive access by you.
   PROGRAM EDITOR
    Command ===> LOCK  MAPSLIB.MAPSCAT.EUROMAP.CMAP

    00001
    00002
    00003
    00004
    00005
    00006

In Releasing a Lock on a Catalog Entry, you can see that MAPSLIB.MAPSCAT.EUROMAP.CMAP was successfully locked. From the Program Editor window, the LOCK command that contains the CLEAR argument was issued to release the lock on catalog MAPSLIB.MAPSCAT.EUROMAP.CMAP.

Releasing a Lock on a Catalog Entry
   LOG
    Command ===>

    1   LIBNAME MAPSLIB 'SASXYZ.SHRTEST.SASDATA' SERVER=SHARE1;
    NOTE: Libref MAPSLIB was successfully assigned as follows:
          Engine:        REMOTE
          Physical Name: SASXYZ.SHRTEST.SASDATA
    NOTE: MAPSLIB.MAPSCAT.EUROMAP.CMAP is now locked for 
          exclusive access by you.
   PROGRAM EDITOR
    Command ===> LOCK  MAPSLIB.MAPSCAT.EUROMAP.CMAP  CLEAR

    00001
    00002
    00003
    00004
    00005
    00006

In SAS Log Message after the Lock Has Been Cleared, you can see that MAPSLIB.MAPSCAT.EUROMAP.CMAP was successfully unlocked. The log also reports who clears the lock. In this example, the user who set and cleared the lock is referred to as "you."

SAS Log Message after the Lock Has Been Cleared
   LOG
    Command ===>

    1   LIBNAME MAPSLIB 'SASXYZ.SHRTEST.SASDATA' SERVER=SHARE1;
    NOTE: Libref MAPSLIB was successfully assigned as follows:
          Engine:        REMOTE
          Physical Name: SASXYZ.SHRTEST.SASDATA
    NOTE: MAPSLIB.MAPSCAT.EUROMAP.CMAP is now locked for 
          exclusive access by you.
    NOTE: MAPSLIB.MAPSCAT.EUROMAP.CMAP is no longer locked 
          for exclusive access by you.


Chapter Contents

Previous

Next

Top of Page

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