DATA Step, Macro, Functions and more

Deleting compiled macro from Work.Sasmacr folder

Posts: 0

Deleting compiled macro from Work.Sasmacr folder


As I am learning to write macros - I am making lots of mistakes - so I want to work very interactively with the writing, compiling and testing of macros. The problem is that when they get compiled and stored - any further changes I make just causes an error - so I need to manually delete the compiled macro before I can continue. I have been using the sasauto option to tell my code base where to look for my macros (i.e. the source code) - as I dont know any other way to let it know where I am keeping my macros...although having said that - I have tried to just use %include - pointing it to my source code - still compiles it to the Work.Sasmacr folder.

When I try to manually delete my compiled macro from the Work.Sasmacr folder - it tells me that I cant, with the following error: Entry lock is not available for mymacro.macro in catalog Work.Sasmacr, lock held by DMS process.

Any pointer gratefully received,

Best wishes

Respected Advisor
Posts: 3,777

Re: Deleting compiled macro from Work.Sasmacr folder

I've written a couple of macros and never needed to do what you describe. I think you need the system option


searches the autocall libraries for an undefined macro name each time an attempt is made to invoke the macro. It is inefficient to search the autocall libraries repeatedly for an undefined macro. Generally, use this option when you are developing or debugging programs that call autocall macros.

searches the autocall libraries only once for a requested macro name.



Use the MRECALL option primarily for

developing systems that require macros in autocall libraries.

recovering from errors caused by an autocall to a macro that is in an unavailable library. Use MRECALL to call the macro again after making the library available. In general, do not use MRECALL unless you are developing or debugging autocall macros.
Super Contributor
Super Contributor
Posts: 3,174

Re: Deleting compiled macro from Work.Sasmacr folder

From the SAS error message, it appears that the SAS DMS process (Display Manager) has the SAS catalog (or WORK libref) open/locked, possibly in another window?

I had no difficulty deleting a just-compiled macro using the code below:

%macro x;
%put this is macro x;
%mend x;
proc catalog cat=work.sasmacr;
delete x / et=macro;

Scott Barry
SBBWorks, Inc.
Posts: 0

Re: Deleting compiled macro from Work.Sasmacr folder

thanks that worked a treat!
Posts: 0

Re: Deleting compiled macro from Work.Sasmacr folder

From what you're saying Davo I'm not sure you know exactly how the macros are being compiled.

When you assign the sasautos then call a macro SAS will check to see if the macro has been compiled already within the session (ie it is in your sasmacr catalog). If it has it just uses that compiled macro, if it hasn't SAS will look for the definition of the macro in the sasautos directory (ies) and compile it.

SAS compiles the macro simply by submitting the code in the sasautos file which holds the macro definition.

There for, if you change the macro code in the file but the macro has already been compiled in the session, SAS will not re-compile it.

The important thing here is that SAS will compile the macro by submitting the code.

I always find that simply submitting the macro definition as code (instead of through the use of sasautos) is the best way to go as SAS will always re-compile the code when you submit it yourself.

I only put it into the sasautos when I am finished developing it.

So when you make a change to your macro definition, just F3 the code and your new macro definition will be compiled.

Hope that makes sense. I'd be interested to know if anyone disagrees and maybe does things differently.

Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation