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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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