How do I stop “A lock is not available for ” errors in SAS?

前端 未结 3 465
-上瘾入骨i
-上瘾入骨i 2021-01-06 12:40

I consistently get \"A lock is not available\" errors when running SAS programs. It usually happens if I perform operations on the same dataset multiple times in one program

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 12:51

    I have been having the same problem when I run proc append in a %do loop like so:

    %do i=1996 %to 2013;
    proc append base=inscat.pc_all data = pc&i. force;
    run; quit;
    %end;
    

    This was on my local machine, so there was nobody else attempting to access the dataset. What was happening was that the loop was running so fast that the base file hadn't closed before it started writing the next part of the loop. After a lot of hair pulling and trying MANY complicated solutions, it turns out that you can just extend the time SAS waits before declaring a failed lock. You do this when you create the library:

    libname inscat 'C:\Users\...\insurercat\data' filelockwait=5;
    

    That just extends the wait time to 5 seconds before SAS decides it's a lock error (from the default of 0, I believe). This simple option fixed all the lock problems I had.

提交回复
热议问题