Tip: How to close all data sets in SAS Enterprise Guide

23

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.

Close All data sets window

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.)

Share

About Author

Chris Hemedinger

Senior Manager, SAS Online Communities

+Chris Hemedinger is the manager of SAS Online Communities. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies.  He also hosts the SAS Tech Talk webcasts each year from SAS Global Forum, connecting viewers with smart people from SAS R&D and the impressive work that they do.

23 Comments

  1. 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 ?

  2. 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.

  3. Pingback: Customize your keys in SAS Enterprise Guide with AutoHotKey - The SAS Dummy

    • Chris Hemedinger
      Chris Hemedinger on

      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.

  4. 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.

    • Chris Hemedinger
      Chris Hemedinger on

      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.

    • Chris Hemedinger
      Chris Hemedinger on

      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.

      • Michael Tuchman on

        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.

        • Chris Hemedinger
          Chris Hemedinger on

          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.

    • Chris Hemedinger
      Chris Hemedinger on

      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.

  5. 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 :(

    • Chris Hemedinger
      Chris Hemedinger on

      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.

Leave A Reply

Back to Top