FILELOCKS System Option: UNIX

Specifies whether file locking is turned on or off and what action should be taken if a file cannot be locked.
Valid in: configuration file, SAS invocation, OPTIONS statement, SAS System Options window
Category: Files: External files | SAS files
PROC OPTIONS GROUP= EXTFILES, SASFILES, ENVFILES
Default: FAIL
UNIX specifics: all

Syntax

-FILELOCKS setting path | path setting
-FILELOCKS NONE | FAIL | CONTINUE | RESET
FILELOCKS=(setting path | path setting)
FILELOCKS=NONE | FAIL | CONTINUE | RESET

Required Arguments

setting
specifies the operating environment locking value for the specified path. The following values are valid:
  • NONE
  • FAIL
  • CONTINUE
  • RESET
path
specifies a path to a UNIX directory. Enclose the path in single or double quotation marks.
Tip:The path argument can contain an environment variable.
NONE
turns file locking off. NONE specifies that SAS attempts to open the file without checking for an existing lock on the file. NONE does not place an operating system lock on the file. These files are not protected from shared Update access.
Tip:NONE does not suppress internal locking.
FAIL
turns file locking on. FAIL specifies that SAS attempts to place an operating system lock on the file. Access to the file is denied if the file is already locked, or if it cannot be locked. FAIL is the default value for FILELOCKS.
CONTINUE
turns file locking on. CONTINUE specifies that SAS attempts to place an operating system lock on the file. If a file is already locked by someone else, an attempt to open it fails. If the file cannot be locked for some other reason (for example, if the file system does not support locking), the file is opened and a warning message is sent to the log.
Tip:CONTINUE does not suppress internal locking.
RESET
specifies that all previous FILELOCKS settings will be deleted, and resets the global setting to the default value of FAIL. If you use the FILELOCKS=(setting path|path setting) syntax, then RESET resets only those files that are in path.

Details

The Basics of File Locking

In previous releases of SAS, the FILELOCKS system option was able to lock only SAS files. In SAS 9.2 and later, the FILELOCKS system option is able to lock external files as well.
The FILELOCKS system option enables you to lock both external files and SAS files based on global settings that you set in the FILELOCKS system option. External file locking applies to all files that are opened.
You can use multiple instances of the FILELOCKS option to establish different settings for different paths. One path can be a subdirectory of another path. In this case, the most specific matching path currently in effect governs operating system file locking. The following example shows how you can specify multiple instances of the FILELOCKS option in a configuration file:
filelocks = ('/u/myuserid/temp' NONE)
filelocks = ('/tmp' CONTINUE)
When the value of the FILELOCKS option is a set of path and setting, the path must be enclosed in quotation marks. If you use FILELOCKS on the command line, then quotation marks are not needed.
Note: To prevent data corruption, setting FILELOCKS to NONE or CONTINUE is not recommended.

Resetting Paths by Using the path and setting Arguments

The path and setting arguments enable you to apply a setting to a particular directory and its subtrees. If you set the value of setting to RESET, then the path and setting values are deleted.
For example, in the following case, filelocks=('/' reset), the current values for path and setting are deleted, and FILELOCKS resets the values to the following default: ('/' fail).

When FILELOCKS Is Set to FAIL

When FILELOCKS is set to FAIL (the default value), the following actions occur:
  • SAS prevents two sessions from simultaneously opening the same SAS file for update or output.
  • SAS prevents one session from reading a SAS file that another SAS session has open for update or output.
  • SAS prevents one session from writing to a file that another SAS session has open in Read mode.

See Also