BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
7 REPLIES 7
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
LAP
Quartz | Level 8 LAP
Quartz | Level 8
Just out of curiosity... Are you running in enterprise guide? I get this when we are running code in Enterprise Guide.
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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
PatrickG
SAS Employee
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.
pcavicch
Calcite | Level 5

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

Peter_C
Rhodochrosite | Level 12

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

Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 28707 views
  • 4 likes
  • 8 in conversation