BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
duanzongran
Obsidian | Level 7

dear all:

Recently,I was confused about "A lock is not available for <dataset>".Indeed ,it's an error,but when I restart SAS and run the code again ,the error disappeared.How to avoid the error?

When I review my code,I guess 5 possibilities  may cause this error, right or wrong?

*1.set options compress=yes;
options compress=yes;

*2.in data step,input dataset and the output dataset have the same name;
data X;set X ;run;


*3. when using proc sort ,without out= option;
proc sort data=x;by id;run;

 Any suggestion is welcome!

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Patrick
Opal | Level 21

SAS throws this error if a different process locks a table (the SAS file). In your case though the tables are in WORK and that is SAS session specific (=same process).

 

What can lock a table even in WORK is if you have it already open in your EG session. Below option setting helps to avoid this.

Patrick_0-1648951829359.png

 

For the 3 cases you mention:

Option compress will never lock a table.

In your sample code the tables are in WORK which is SAS session (process) specific and no other process (like another SAS session) gets access to this WORK directory.

 

Kurt_Bremser
Super User

Another thing that can keep a file handle open is anti-virus software which immediately scans all newly created files and prevents an overwrite (or even opens exclusively).

duanzongran
Obsidian | Level 7
Yes,quite so !!!!!!!!!!!!!!!!!!!!!!!!
After checking my computer ,i found the anti-virus software installed by my IT workmate very frequently scan every file I make from sas.
When I run then code on a computer without the anti-virus software , it seems everything is OK.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2539 views
  • 3 likes
  • 3 in conversation