"lock is not available" error when using PROC APPEND

Reply
Occasional Contributor
Posts: 15

"lock is not available" error when using PROC APPEND

Hi All,

I am using proc append to combine a large amount of datasets - around 11,000. I have created these datasets within the same program (read them in from HTML files) and want to combine them.

About 8,000 datasets through, I receive an error -

ERROR: A lock is not available for DATA.COMBINED.DATA.

SYMBOLGEN:  Macro variable FILENAME resolves t"a o _2938194_A1

MPRINT(STACK):   proc append base = data.Combined data=_2938194_A1 force;

MPRINT(STACK):   run;

Any suggestions on how to fix this?

Thanks

Super User
Super User
Posts: 6,499

Re: "lock is not available" error when using PROC APPEND

Usually this means that you or someone else has the file open.

You are probably having a timing issue where you have gotten to the next APPEND step before the previous one has really finished processing the previous one.

Perhaps if you just put in a data step with a SLEEP() function call in between you can get it to work?

Occasional Contributor
Posts: 15

Re: "lock is not available" error when using PROC APPEND

I have a different question - lets say I am reading in data using a series of input statements. However, there are two different types of data I am working with - I want to insert a line of code in the beginning that looks at the first variable of each data set and then guides it to the appropriate read-in datastep. something like...

if ("First observation" = "xxyywwss") then do;

*insert readin program 1 here*

else

*insert readin program 2 here*

Thanks.

Super User
Posts: 5,256

Re: "lock is not available" error when using PROC APPEND

Since this is a new question - open new thread instead. Tip: apply some sample (input/output) data to your question for better understanding of your problem.

Data never sleeps
PROC Star
Posts: 1,230

Re: "lock is not available" error when using PROC APPEND

Tom's suggestion is good, it could be that your are locking it yourself.

If you think someone else may have locked the data, then a macro utility like %TryLock is useful for repeatedly trying to get a lock on a dataset before you update it.

http://www.lexjansen.com/pharmasug/2005/posters/po33.pdf

Occasional Contributor
Posts: 15

Re: "lock is not available" error when using PROC APPEND

Thank you. Is there a way to tell SAS to wait until the dataset is "available" instead of generating an error?

Super User
Posts: 3,102

Re: "lock is not available" error when using PROC APPEND

It's my understanding that Base SAS relies on operating system file locking hence there is no feature in SAS that will tell it to wait for a lock. Various SAS users have tried to implement their own solutions like %TryLock mentioned above, but in my experience none are entirely statisfactory. I suggest you search through the user forum using FILE LOCK as your key and you will soon get an idea whats what.

I suggest you try Tom's or my approach for starters just to see how far you get. 

Occasional Contributor
Posts: 15

Re: "lock is not available" error when using PROC APPEND

Thanks for the help. I have a different question - lets say I am reading in data using a series of input statements. However, there are two different types of data I am working with - I want to insert a line of code in the beginning that looks at the first variable of each data set and then guides it to the appropriate read-in datastep. something like...

if ("First observation" = "xxyywwss") then do;

*insert readin program 1 here*

else

*insert readin program 2 here*

Thanks.

Super User
Posts: 5,256

Re: "lock is not available" error when using PROC APPEND

Depending on the nature of your SAS implementation (that is, high availability), an alternative is to store the data in a multi-user engine, such as SAS/SHARE (small data sets), SAS SPD Server or an external RDBMS.

If you are the admin, and the lock occurs during off business hours, you can have a script that's "shooting down" non-permitted SAS sessions.

Data never sleeps
Super User
Posts: 3,102

Re: "lock is not available" error when using PROC APPEND

An alternative approach to Toms would be to have say 2 COMBINED datasets and alternate your APPENDs between the two, then at the end join the two COMBINED datasets. This may be enough to avoid your locking problem.

Ask a Question
Discussion stats
  • 9 replies
  • 6090 views
  • 0 likes
  • 5 in conversation