Using External Files and Devices |
File Locking for External Files: The LOCKINTERNAL Statement Option
File Locking for External Files: The FILELOCKS System Option
Sharing External Files |
If more than one user has simultaneous Write access to an external file, or if a single user has Write access to the same file from different SAS sessions, the results of sharing the file can be unpredictable. To remedy this situation, you can use a statement or a system option to restrict Write access to one user, while allowing multiple users Read access. (For information about sharing SAS files, see Sharing SAS Files.)
Options to Use for File Locking: External Files |
File locking applies to all files that are opened. You can turn off file locking for external files in the following ways:
Use the LOCKINTERNAL option in the FILENAME statement.
Use the FILELOCKS system option.
File Locking for External Files: The LOCKINTERNAL Statement Option |
You can control file locking for external files by using the LOCKINTERNAL option in the FILENAME statement. The AUTO option value locks a file exclusively for Write access, or non-exclusively for Read access. For example, if a file is opened for update or output, then all other access from internal processes will be blocked. If a file is opened for input, then other users can also open the file for input. In this case, opening the file for update and output will be blocked. The SHARED option value allows for all of the behavior of the AUTO option, except that the file can be shared by one writer and multiple readers. The external file that is associated with the fileref is the file that is locked. By default, multiple users can simultaneously read an external file. For more information, see FILENAME Statement: UNIX.
File Locking for External Files: The FILELOCKS System Option |
You can control file locking for external files (as well as for SAS files) by using the FILELOCKS system option. This option enables you to apply a behavior globally to individual files or directories. Using FILELOCKS restricts writer access to one user. With file locking turned on, multiple SAS sessions are able to simultaneously read the same file. You can use FILELOCKS at start-up, in the OPTIONS statement, or in the command line. You can specify multiple instances of the FILELOCKS option. Each instance is added to an internal table of paths and settings. For more information, see FILELOCKS System Option: UNIX.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.