Discussion:
Can't open a dataset because a member-level lock
Add Reply
SUBSCRIBE SAS-L Tom Smith
2008-07-11 01:50:45 UTC
Reply
Permalink
Raw Message
Here is the error message:

ERROR: You cannot open SASLIB.MYDATA.DATA for output access with member-
level control because SASLIB.MYDATA.DATA is in use by you in resource
environment DATASTEP.

Here is what I did:

1) created a dataset with
proc sql;
create table xxx
( varx char(3).
vary num
);
quit;

2) proc sql;
insert into xxx
set varx='ccc',
vary=99;
quit;

3) data xxx;
set xxx;
if varx='ddd' then vary=0;
run;

all of above steps ran smoothly, but 2) and 3) are in a do loop and each is
run conditionally. It seems that there is a step which did not close the
dataset, and I tried adding a close statement and also tried close( )
function after each step. But still got the error message.

I doubt there may be some mechanism behind that handles the lock of a
dataset, but can not tell exactly what.

Thanks in advance for any hint.
Howard Schreier)
2008-07-11 02:54:01 UTC
Reply
Permalink
Raw Message
On Thu, 10 Jul 2008 21:50:45 -0400, SUBSCRIBE SAS-L Tom Smith
Post by SUBSCRIBE SAS-L Tom Smith
ERROR: You cannot open SASLIB.MYDATA.DATA for output access with member-
level control because SASLIB.MYDATA.DATA is in use by you in resource
environment DATASTEP.
1) created a dataset with
proc sql;
create table xxx
( varx char(3).
vary num
);
quit;
2) proc sql;
insert into xxx
set varx='ccc',
vary=99;
quit;
3) data xxx;
set xxx;
if varx='ddd' then vary=0;
run;
all of above steps ran smoothly,
I doubt that because there is a period in #1 which should be a comma. When
posting code to SAS-L, it's not a good idea to retype it. Better to copy and
paste from the actual source.
Post by SUBSCRIBE SAS-L Tom Smith
but 2) and 3) are in a do loop and each is
run conditionally. It seems that there is a step which did not close the
dataset, and I tried adding a close statement and also tried close( )
function after each step. But still got the error message.
I can run #2 and #3 in turn and/or repeatedly in various patterns (eg,
23233223) and I don't get the error. If th error occurs consistently, it
makes me think there is something important not shown.
Post by SUBSCRIBE SAS-L Tom Smith
I doubt there may be some mechanism behind that handles the lock of a
dataset, but can not tell exactly what.
Thanks in advance for any hint.
Patrick
2008-07-11 05:34:43 UTC
Reply
Permalink
Raw Message
The simplest explanation would be:
The dataset is locked because it’s opened. This could for example
happen if you run your code in SAS EG and have this not so clever
option enabled that datasets are opened as they are added to the
project (“Open generated data/results automatically”).

Another cause for such a problem that I’ve seen:
The dataset is accessed using SAS/Share. I don’t know why it happened
(a bug?) but using SQL/Insert lead to a locked dataset. We had to
change the code and use modify instead.
s***@gmail.com
2017-08-09 08:55:28 UTC
Reply
Permalink
Raw Message
Post by Patrick
The dataset is locked because it’s opened. This could for example
happen if you run your code in SAS EG and have this not so clever
option enabled that datasets are opened as they are added to the
project (“Open generated data/results automatically”).
The dataset is accessed using SAS/Share. I don’t know why it happened
(a bug?) but using SQL/Insert lead to a locked dataset. We had to
change the code and use modify instead.
Thanks! I just had to close the open dataset and it worked.

Anindya Mozumdar
2008-07-11 05:27:12 UTC
Reply
Permalink
Raw Message
Are you sure you did not "open" the dataset for viewing it (before
steps 2 and 3) by double-clicking in the explorer window? :)

On Fri, Jul 11, 2008 at 7:20 AM, SUBSCRIBE SAS-L Tom Smith
Post by SUBSCRIBE SAS-L Tom Smith
ERROR: You cannot open SASLIB.MYDATA.DATA for output access with member-
level control because SASLIB.MYDATA.DATA is in use by you in resource
environment DATASTEP.
1) created a dataset with
proc sql;
create table xxx
( varx char(3).
vary num
);
quit;
2) proc sql;
insert into xxx
set varx='ccc',
vary=99;
quit;
3) data xxx;
set xxx;
if varx='ddd' then vary=0;
run;
all of above steps ran smoothly, but 2) and 3) are in a do loop and each is
run conditionally. It seems that there is a step which did not close the
dataset, and I tried adding a close statement and also tried close( )
function after each step. But still got the error message.
I doubt there may be some mechanism behind that handles the lock of a
dataset, but can not tell exactly what.
Thanks in advance for any hint.
SUBSCRIBE SAS-L Tom Smith
2008-07-11 15:58:17 UTC
Reply
Permalink
Raw Message
Thanks for reply.
Post by Howard Schreier)
I doubt that because there is a period in #1 which should be a comma.
Sorry, that is a type error in my post. The actual code is fine.
Post by Howard Schreier)
Are you sure you did not "open" the dataset for viewing it by double-
clicking in the explorer window?

I used Unix batch mode to submit the code. The dataset was not opened
mannually.
Post by Howard Schreier)
The dataset is accessed using SAS/Share ...but using SQL/Insert lead to
a locked dataset.

I guess two things may be relevant:
1. SQL/insert and UNDO-POLICY, I tested UNDO-POLICY=required and optional,
not work;
2. Modify dataset in place:
data mydata;
set mydata;
...
run;

If we can't tell a potential mechanism on this issue, I may consider the
unix SAS is not clever enough to handle the lock problem.
Terjeson, Mark
2008-07-11 16:23:50 UTC
Reply
Permalink
Raw Message
Hi Tom,

I'm kind of coming into this thread part way
so not sure what all has been covered, but a
couple of thoughts that may be relevant. If a
Unix SAS job has somehow died mid-way or killed
mid-way, it can be possible the xxx.sas7bdat.lck
file was orphaned and still exists, if you know
your process is no longer running, you can just
remove(rm) this .lck file. Another thing you can
check is the permissions(ls -l) on the .sas7bdat file.
Thirdly, we presume you have already insured
that another process is not hung and still looking
like it is running(ps -ef).




Hope this is helpful.


Mark Terjeson
Senior Programmer Analyst
Investment Management & Research
Russell Investments


Russell Investments
Global Leaders in Multi-Manager Investing






-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-***@LISTSERV.UGA.EDU] On Behalf Of
SUBSCRIBE SAS-L Tom Smith
Sent: Friday, July 11, 2008 8:58 AM
To: SAS-***@LISTSERV.UGA.EDU
Subject: Re: Can't open a dataset because a member-level lock

Thanks for reply.
Post by Howard Schreier)
I doubt that because there is a period in #1 which should be a comma.
Sorry, that is a type error in my post. The actual code is fine.
Post by Howard Schreier)
Are you sure you did not "open" the dataset for viewing it by double-
clicking in the explorer window?

I used Unix batch mode to submit the code. The dataset was not opened
mannually.
Post by Howard Schreier)
The dataset is accessed using SAS/Share ...but using SQL/Insert lead
to
a locked dataset.

I guess two things may be relevant:
1. SQL/insert and UNDO-POLICY, I tested UNDO-POLICY=required and
optional,
not work;
2. Modify dataset in place:
data mydata;
set mydata;
...
run;

If we can't tell a potential mechanism on this issue, I may consider the
unix SAS is not clever enough to handle the lock problem.
Loading...