Hi,
I'm trying to update my dataset by using update query in data step.
I'm getting error every day at this step. say's locked by someother process.
Added %FILE_LOCKED STATUS macro as well, it checks and gives below error
" NOTE: Following symbolic link, temporary output file is
/path/dataset.sas7bdat.lck
ERROR: A lock is not available for M_M.dataset.DATA.
ERROR: Lock held by process 111111.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements.
This might cause NOTE: No observations in data set.
NOTE: There were 1 observations read from the data set M_M.dataset.
NOTE: There were 1 observations read from the data set X_X.dataset.
WARNING: The data set M_M.dataset was only partially opened and will not
be saved."
i'm manually running update part every day.
how to overcome this lock issue.
is there a way where other porcess can have read access, and i can able to update. so that other process will not fail at the same time
Thanks,
Kenneth.
OK, in that case you could try the FILELOCKWAIT option on the LIBNAME being used for this library, to get your batch jobs to wait until the dataset frees up. I use this myself and it works well. This option works under both Unix and Windows.
Use system tools to identify which program is Process=111111 (or whatever the actual value may be). Then diagnose why that program is using the file. Then make sure it isn't using the file when you want to update.
Some programs just lock files when using them, even for "read only". Though I consider attempting to update data while another program is reading it is a way to creating inconsistent reports and such.
How are you updating this dataset? In SAS batch jobs, running programs in EG, SAS Studio, SAS Windowing System or some other way? Bear in mind that viewing a SAS dataset in EG, SAS Studio, SAS Windowing System will lock it and prevent it from being updated. You need to identify what processes are locking it before deciding on how to avoid it.
OK, in that case you could try the FILELOCKWAIT option on the LIBNAME being used for this library, to get your batch jobs to wait until the dataset frees up. I use this myself and it works well. This option works under both Unix and Windows.
If you run your SAS on UNIX/Linux, look here:
libname abc path/aaaa/bbb filelocks=none;
above is removing existing file lock if any.
@Asbon wrote:
libname abc path/aaaa/bbb filelocks=none;
above is removing existing file lock if any.
Wrong. From the documentation of LIBNAME on UNIX:
FILELOCKS=NONE | FAIL | CONTINUE
specifies whether file locking is turned on or off for the files that are opened under the libref in the LIBNAME statement. The FILELOCKS statement option works like the FILELOCKS system option, except that it applies only to the files that are associated with the libref. The following values for the FILELOCKS statement option are available:
- 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.
FILELOCKS=NONE will only prevent checking for a lock and setting a lock, but if another process has a lock on the file, the operating system will prevent access. And if two SAS sessions update the dataset simultaneously, it will most likely be destroyed.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.