DATA Step, Macro, Functions and more

ERROR: Unable to clear or re-assign the library MACROS because it is still

Reply
N/A
Posts: 0

ERROR: Unable to clear or re-assign the library MACROS because it is still

I am getting the following error message everytimeI run the sas program. The error message is not being displayed when I start a new SAS session.

The syntax which i am trying to use is as follows
libname macros 'U:\Macros';
options mstored sasmstore =macros;
options linesize=200 pagesize=100;
ods listing;


646 libname macros 'U:\Macros';
ERROR: Unable to clear or re-assign the library MACROS because it is still in use.
ERROR: Error in the LIBNAME statement.
646! 647 options mstored sasmstore =macros;
648 options linesize=200 pagesize=100;
649 ods listing;

Is there a way to get around this?
Super Contributor
Super Contributor
Posts: 3,174

Re: ERROR: Unable to clear or re-assign the library MACROS because it is still

Clearly you have SAS code being executed in advance of the code that is giving the error -- so what is that code doing and how is it using the "libref" allocation for "MACROS"? You need to review yourself, and, if needed, share the code (preferably in a SAS log) that is being executed before the error, such as lines 1 through 645 -- I expect you will see why SAS is complaining about the open LIBNAME allocation.

Scott Barry
SBBWorks, Inc.
Frequent Contributor
Frequent Contributor
Posts: 76

Re: ERROR: Unable to clear or re-assign the library MACROS because it is still

Just out of curiosity... Are you running in enterprise guide? I get this when we are running code in Enterprise Guide.
Super Contributor
Super Contributor
Posts: 365

Re: ERROR: Unable to clear or re-assign the library MACROS because it is still

Hello Lucy,

I has this message in Enterprise Guide. The reason is that when you assign a library for saving macros it is locked until the SAS session is closed.

When you run your program second time you are trying to reassign the locked macro library which is impossible. My advice is to highlight the part of the program excluding "libname macros 'U:\Macros';" and execute the highlighted part only.

Sincerely,
SPR
SAS Employee
Posts: 58

Re: ERROR: Unable to clear or re-assign the library MACROS because it is still

This won't help you now, but when 9.3 is released, it will include a
%SYSMSTORECLEAR statement that will allow users to specifically
have the catalog associated with the libref specified in the SASMSTORE=
closed and the libref cleared.
Occasional Contributor
Posts: 6

ERROR: Unable to clear or re-assign the library MACROS because it is still

I haven't found an elegant solution, but I'm using this code in Enterprise Guide:

*-- start code --;

data _NULL_;

  length WORD $8;

     do j = 1 to 8;

        WORD = byte(int(65 + ranuni(0)*26)) || WORD;

     end;

     call symput("mylibrary", WORD);

run;

libname &mylibrary 'physical_path_to_library';

*-- end code --;

This assign every time a different random LIBREF to you library.

It works.

Regards

Paolo

Valued Guide
Posts: 2,175

ERROR: Unable to clear or re-assign the library MACROS because it is still

Lucy

this seems a very parallel thread.

See my response in the other, at

http://communities.sas.com/message/102072#102072

When (if) this problem occurs in enterprise guide, instead of puting code in the autexec, place your "one-time-code" at the code box in

menu: tools/options/sas programs/"submit code when server is connected"/edit

Super User
Super User
Posts: 6,500

ERROR: Unable to clear or re-assign the library MACROS because it is still

Are you trying to point the libref to a different location? Or are you just re-running the code that assigned the libref?

If the latter then test first before defining the library.  Here is can example command using the IFC and LIBREF functions to conditionally issue the libname statement only when the libref does not already exist.

4    %sysfunc(ifc(%sysfunc(libref(macros)),libname macros '~/temp',));

NOTE: Libref MACROS was successfully assigned as follows:

      Engine:        V9

      Physical Name: /home/abernt/temp

5    %sysfunc(ifc(%sysfunc(libref(macros)),libname macros '~/temp',));

The other thing to consider is changing the SASMSTORE option before trying to modify the libref.

Ask a Question
Discussion stats
  • 7 replies
  • 6095 views
  • 0 likes
  • 8 in conversation