comp.soft-sys.sas - The SAS statistics package.
My goal is to have one SAS session lock all other SAS sessions out of a particular SAS table while it needs to work with it. I want to be able to lock the table, then open it with the OPEN function (in update or input mode), run data steps that read the table, run data steps that update the table, run PROC APPEND to update the table, etc, etc. Then finally unlock the table when done. rc = LOCK('mylib.mytable','LOCK'); ... ... dsid = OPEN('mylib.mytable','I'); ... ... dsid = OPEN('mylib.mytable','U'); ... ... SUBMIT CONTINUE; DATA work.newtable; SET mylib.mytable; ... RUN; ENDSUBMIT; ... ... SUBMIT CONTINUE; DATA mylib.mytable; SET work.othertable; ... RUN; ENDSUBMIT; ... ... ETC, ETC, ETC ... ... rc = LOCK('mylib.mytable','CLEAR'); This seems to work with some initial testing. However, I'm wondering if there are any cases where this technique would not work (i.e. where this session would lock itself out of the table somehow, or where the LOCK function somehow would not lock out other users). One situation I can think of where this would not work is if I did a remote submit. The remote session would be locked out of the table when it finds that the table is locked, even though the remote session corresponds to this user. Other than that are there any problems with this approach? I don't see alot of info in SAS Help about how exactly the LOCK function works. Thanks
So the LOCK statement is not able to detect locks from other processes, even though there is a QUERY/LIST option supplied just for that purpose. Problem Notes 6029 and 2859 list this as a known bug, one which isn't fixed on Solaris. Per note 6029, the only workaround is to attempt to place a lock, and check for an error condition. Since I run all my scheduled jobs with ERRORABEND I don't find this terribly helpful. Shockingly, Google turned up NO discussion of the matter anywhere, including SAS-L. Is there anyone else out there who has been burned by this? How did you end up dealing with it? Using 'touch'/FILEEXIST/etc to roll my own lock indicators is always an option, but that seems a bit silly; and I'm trying to keep the amount of Stupid Unix Tricks to a bare minimum, out of consideration for those who come behind me. LOG sample: 17 lock skippy.lms_2005_20080603 query; NOTE: SKIPPY.LMS_2005_20080603.DATA is not locked or in use by you or any other users. 20 lock skippy.lms_2005_20080603; ERROR: A lock is not available for SKIPPY.LMS_2005_20080603.DATA, lock held by process 15711. 23 lock skippy.lms_2005_20080603 query; NOTE: SKIPPY.LMS_2005_20080603.DATA is not locked or in use by you or any other users. 26 lock skippy.lms_2005_20080603 clear; ERROR: SKIPPY.LMS_2005_20080603.DATA is not locked by you. 29 lock skippy.lms_2005_20080603 query; NOTE: SKIPPY.LMS_2005_20080603.DATA is not locked or in use by you or any other users. Thanks, clh Christopher L Hamilton Washington Mutual | Deposit Risk Management
Hi, I am writing a macro which will try to lock the dataset using LOCK DS_name command. If due to contention the Lock fails then we need to trigger an email which will contain details about the user/process holding the lock on given table. By using LOCK DS_name LIST we can know this but these details from LOCK LIST get written into Log file. Is there any way to redirect output of this command to some dataset which we can use for sending an email. Regards, Amol Deshmukh
We are having a problem(in windows SAS Version 9.1 on a network server) where during a proc sort the dataset that is being sorted to itself locks and we can not get access to it. The problem is when SAS sorts a dataset to itself it creates a tempory file with an extension of .lck. During the sort it locks the orginal file so that no one can access it during the sort. When the sort finishes correctly the orginal file is freed and the .lck file is delete. However if the sort does not complete correctly the orginal file remains locked ,administrator has to free it and the lck file is saved. All the SAS processes after that fail so the job fails. We've been working with SAS support and they claim something is touching (like a anti-Virus) the file during the sort or we have a SAS server that to weak or a bad disk drive. We tried everything nothing has worked.I was hoping someone has run into this problem before and can help.