Have you seen this error when running a program in SAS Enterprise Guide?
ERROR: You cannot open WORK.YOURDATA.DATA for output access with member-level control because WORK.YOURDATA.DATA is in use by you in resource environment IOM ROOT COMP ENV.
Or maybe:
ERROR: A lock is not available for LIB.YOURDATA.DATA. NOTE: The SAS System stopped processing this step because of errors.
It has a simple cause: the data set that your program is trying to write (or rewrite) is open in the data viewer. With regard to this data file, your program is in contention with the SAS Enterprise Guide application.
Usually SAS Enterprise Guide closes all open data sets before running a program or task, and that's meant to help you avoid this error. But sometimes a data set file remains open for one reason or another, and the conflict results in the error message. Fortunately, there is a simple fix.
Select Tools->View Open Data Sets. The View Open Data Sets window shows the names of the data files that SAS Enterprise Guide has open. And it offers a convenient Close All button to clear the list. Closing the data doesn't affect the contents of the file or its place in your project. It simply removes the lock that SAS Enterprise Guide is holding on the file.
If you are running multiple SAS Enterprise Guide sessions, it's possible for one session to have a lock on a file that you're trying to update in another session. The View Open Data Sets window shows only those data sets from your current session, so be sure to check your other projects if you're multitasking.
The default behavior -- close all data before running SAS programs -- is controlled in Tools->Options->SAS Programs. If you don't want SAS Enterprise Guide to close your data windows, clear that checkbox. (It's difficult for me to imagine why you would do that...but hey, we have options for everything.)
29 Comments
It's a great tip. Thank you, Chris.
Is there a programmatic way to do that?
Leonid, no, there isn't. Although I'm sure you could use a key macro tool like AutoHotkey to automate the operation.
It looks like you can use open and close to close datasets programmatically, but not all at once. Unless there is a way to get a list of data-set-id values programmatically...
I used to close and open SAS EG session to overcome this common hiccup. Very useful info... Thanks for sharing!
This is a great tip! It would make a great submission to sasCommunity.org.
Great advice. It doesn't happen often but once in awhile a table will be mysteriously locked and this would be good way to see when that happens. But ...... in tools ->> View Open Data Sets it is greyed out for me- unavailable on my E.G. setup. Any remedies ?
Kimball, the menu item is disabled when you don't have any data in the project, or when no data sets are open.
Chris, this is great info (as always) for cases when you are a lone shooter in the data pond, however in my case this error is more often the result of another user having the dataset open in their session.
While I use the well written "lockitdown" macro to catch these scenarios, is there not a simple way to configure SAS to allow the owner to write, despite a non-owner reading the dataset?? Seems a bit counter-intuitive to prevent the owner from updating their data sets when a non-owner is using it.
Pingback: Customize your keys in SAS Enterprise Guide with AutoHotKey - The SAS Dummy
Was this option "moved" or "removed"? I don't see it in 7.13.
Nope, it's there! In the Tools menu, near the bottom. It's enabled only when there are one or more open data sets, but the menu item is always visible.
Thanks for the tip, but like another commenter experienced, I currently have a dataset that is reporting as being open and generating the error you mentioned, but 'View Open Data Sets' is greyed out. I was working the I/O function, so I tried writing a loop to try closing dataset IDs, but that didn't work either. I also can't force PROC DATASETS to delete the set (it's just a dataset in work I can easily recreate). Looks like I'm stuck restarting my session to close the set free up that dataset name for use again.
This method can track only what EG has open -- but if your SAS process has something locked outside of the interface, this action won't close it.
That option is grayed out
The option is enabled only when one or more data sets are opened -- and open by SAS Enterprise Guide. Lots of actions will close the data sets implicitly (like running code), so you might find the option not applicable in many cases. It's there when you need it.
So, in the case when we're still getting locked out, but there is no DS open in EG, what might be some next steps to take? I can get specifics by opening a ticket; this question is just about generalities.
If EG doesn't have the data set open (by any user), it could still be locked by a running SAS job. You might need access to the OS to use the lsof command (Linux) or the handle.exe or Resource Monitor on Windows. By the way, SAS Enterprise Guide v8 releases open data files quickly, by default after 3 minutes of idle time.
How to do this in BASE sas. I am not seeing the option View Open Data Sets in Tools
A community member shared an approach you can use. This macro:
You could assign that to a function key to run it.
is this still available in 8.1? I am not able to see it :(
In EG 8.1 and later, the data sets close automatically after just a short period of idle time. The data set locks are released quickly, so the need to close ALL data at once is minimized. That said, you can use File->Close All Items. And you can right-click on any tab and select Close, Close Others, or Close All.
None of these helped for me. Every now and again, when continually running big programs with lots of output data sets and continually viewing them in the output data tab, EG seems to hang onto the lock for one. When I run a snippet of code subsequently I get errors that the data set is locked, but i've not tabs available to close. I tried the "Close All" but that didn't do anything. I have to kill the session and start again :(
In EG 8.1 and later, it shouldn't be such an issue. EG locks the data tables only for a short time (configurable). If all data views are closed but you still see data is locked, it might be another process, or running code. Or even another user if it's in a shared space. Or, if working with Excel data, MS Excel can also lock the file.
In EG 8.3 (maybe 8.1 too but I'm using 8.3) there is an option under TOOLS > OPTIONS > DATA > PERFORMANCE to "Unlock all open data before running code" that did the trick for me after loosing the SAS Programs option for "Close all data before running code" that was in EG 7.1
Chris Greene - thank you! This did the trick.
Chris Greene's tip is what works to get rid of the message
ERROR: You cannot open WORK.xxx.DATA for output access with member-level control because WORK.xxx.DATA is in use by you in resource environment IOM ROOT COMP ENV.
and seems to make the statement that the default behaviour is to close all data before running SAS programs?
*seems to contradict*
Hi Chris, Is there any other way to resolve it.
> In EG 8.3 (maybe 8.1 too but I'm using 8.3) there is an option under TOOLS > OPTIONS > DATA > PERFORMANCE to "Unlock all open data before running code" that did the trick for me after loosing the SAS Programs option for "Close all data before running code" that was in EG 7.1
I wish this option was obeyed :(