2

I have a program which creates a stored compiled macro in a library using the syntax:

options mstored sasmstore=MyLib; 
%macro MyMac() /store source des='My Macro'; 
  %let x=1;
%mend;

However I cannot seem to re-assign my library (MyLib) afterwards - I get the following message (sas 9.1.3):

ERROR: Unable to clear or re-assign the library MYLIB because it is still in use.
ERROR: Error in the LIBNAME statement.

Can anyone advise?

flag

3 Answers

2

Short answer - I don't think you can in the same SAS session.

You can't clear the libref because the macro catalog (SASMACR) remains open. It stays open since it takes resources to open and close the catalog and SAS assumes that compiled macros are going for speed in production jobs and as a trade-off, lose some dynamic abilities. All resources have to be closed before you can clear the libref. Since SASMACR remains in use (and short of closing the session doesn't appear to be a way to close it), ther is no way to clear the libref.

link|flag
2

In a large project with total dependence on stored compiled macros (SCM) programs, I learned several important things:

1) Keep your sources for the SCMs. Sounds obvious but heh! Completeness is important.\

2) Never update the macro library while someone else might be using the macro library or possibly also updating it. Your macro library can become corrupted. It is better to rebuild the macro library in a stand-alone job which does nothing else.

3) If multiple users are using the macro library, consider several macro libraries if the jobs from different persons can be differentiated. This was in the context of using the SCM library with SAS/IntrNet, in which we knew where each job was originating.

4) Rather than clear the macro library, physically delete it and rebuild it. If you are in a high-demand situation, do this in a timed job at 3 AM every day. Rebuilding the entire library keeps it compact and fast. If macros are added back into the library, they are deleted and this makes the storage inefficient.

link|flag
1

MSTORED tells sas to look for macros in MYLIB.SASMACR. By default sas looks in WORK.SASMACR. The stored compiled macro is designed to speed things up and should hellp prevent unauthorized macro tweaking. Have you tried sas option NOMSTORED? That might tell SAS to ignore the MYLIB.SASMACR lookup . If it does, then you should be able to clear MYLIB. If you can't clear it after that, then bailing out of the session might be the answer.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.