BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

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 - but...it 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

Davo
4 REPLIES 4
data_null__
Jade | Level 19
I've written a couple of macros and never needed to do what you describe. I think you need the system option


MRECALL | NOMRECALL

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

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


--------------------------------------------------------------------------------

Details


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.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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;
%x;
proc catalog cat=work.sasmacr;
delete x / et=macro;
quit;


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
thanks that worked a treat!
deleted_user
Not applicable
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.

Cheers
Peter

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
  • 4 replies
  • 4871 views
  • 0 likes
  • 3 in conversation