As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Tips:Using the LOCK Statement for Exclusive Use of a SAS Data Set

From sasCommunity
Jump to: navigation, search
options msglevel=I;
libname templib "c:\temp";
proc copy in=sashelp out=templib;
    select orsales;
lock templib.orsales;
proc summary nway data=templib.orsales;
    class Product_Line;
    var quantity profit;
    output out=summ1 sum=;
lock templib.orsales clear;

You can use the LOCK statement to prevent other SAS programs from either reading from or writing to a SAS data set that your program needs until you release the lock. This can be handy in cases where multiple programmers have access to SAS data sets residing on shared disk space; such as can be found on network drives, Windows servers, UNIX servers, etc. Using the LOCK statement can guarantee that you have exclusive control of a SAS data set for the time period when you need it

LOCK is a Base SAS statement. Although there is increased functionality with SAS/SHARE, LOCK can be used to simulate some of the capabilities of SAS/SHARE.

See the sample code at right for the syntax for the LOCK statement. After the first LOCK statement, you will see the following in the SAS Log:

NOTE: TEMPLIB.ORSALES.DATA is now locked for exclusive access by you.

After the second LOCK statement, with the CLEAR option, you will see the following in the SAS Log:

NOTE: TEMPLIB.ORSALES.DATA is no longer locked by you.

The LOCK statement might be just the thing that you need to ensure your privacy when processing SAS data sets on shared disk space!

Submitted by Michael A. Raithel, The man who wrote the book on performance. Contact me at my Discussion Page.