BookmarkSubscribeRSS Feed
Gsamaritan
Calcite | Level 5

Dear all,

I have developed five macros, AA, BB, CC , DD and EE and compiled them in a user library.

To finish a task, CC would be called three times. The short calling sas program is like:

%AA

%BB

%CC

%CC

%CC

%DD

%EE

Each time the calling program stops after the first %CC is executed, the program will give error message like:

ERROR: Windows Error Reporting failed because the client was not found.

ERROR: Reac Access Violation In Task [Submit]

Exception Occurred at (6780EB72)

Task Traceback

Address Frame (DBGHELP API Version 4.0 rev 5)

bla

Even I slashed out all the three %CC, the program stops after %BB is executed and the error message shows up again, the later part won't be executed. But when I hit run again, the program will run all the way till the end, no error message at all!

In the code of AA.sas, BB.sas,  DD.sas,   there are small macros inside the macro definition of AA, BB, DD. But for CC.sas, EE.sas, there are small macros both inside and outside of macro definiton DD and EE. Since mstore was used for every macro definition, all the main and small macros were successfully compiled in the user library.

It's annoying to see the huge amount of red error message and to run and then stop at some point, hit run again and then verything is fine!!!

A SAS session only search the user library once and can only get 2-3 macros? Why it's ok when hit run gain? How to make them re-searching the user library?

Can anybody help, tons of thanks in advance!

15 REPLIES 15
Tom
Super User Tom
Super User

Is it possible that you have some nesting of the macro definition?  Perhaps %CC is trying to redefine a macro that is already running.

I would recommend separating your source code so that each macro is stored in a single file.  Each file shoud have only one macro definition in it and the first line should be the %MACRO statement and the last line the %MEND statement.  This will make it impossible to store all the files in one directory and have two different definitions for the same macro.

Save the program that calls these macros and run it non-interactively and see if you get the error messages.

Personally I normally just use autocall libraries rather than storing compiler macro definitions.  Then I only need to manage the source code files do not need to manage the compiler macro catalogs also.

Ksharp
Super User

Defaultly,A SAS session only search the user library once.

But  there is an option to force SAS search many times.

You should check it in documentation. Sorry. I have forgotten.

Ksharp

Peter_C
Rhodochrosite | Level 12

mrecall         

Gsamaritan
Calcite | Level 5

Tom, Ksharp and Peter,

Thank you all for your kind help!

It seems mrecall searches autocall library for an undefined macro name, the .sas program of the macro definition is stroed in the library and then use:

options mautosource sasautos='G:\mymac\'

to reuse the macro.

But how about already compiled macro defintions? Is there any option to force a sas session search multiple times of the compiled macro catalog? The client was not found error message is because the sas session stopped or failed to search the macro name in the compiled catalog. I tried the above code for the compiled macro call, still does not work. I still need hit run, stop and hit run again to run all the macro calls.

If I use %include 'path\AA.sas';

           %include 'path\BB.sas';

           ....

           %include 'path\EE.sas';

Then no such problem. But apparently that's not a professional way to use and put open sas code on company public space.

I'm really frustrated with this situation.

Any further help deeply appreciated!

Peter_C
Rhodochrosite | Level 12

don't think we can help much more until you reveal those macros AA, BB and CC

Tom
Super User Tom
Super User

You will probably need to provide more details as to where exactly in the program it is getting the error.

A couple of things to try.

1) Make sure that the catalog with the compiled macros is READONLY.  You can do this with the operating system but you can also use the access=readonly option on the libname that you are using to point to the folder with the catalog.

2) Make sure that the programs are not trying to change the options that specify which macro catalog to use.

Ksharp
Super User

I am curious that You can't use compiled macro.

Once you stored compiled macro ,then you can use it as other SAS automatic macro like %ds2csv.

Did you try to use mstore to store this compiled macro firstly? and use sasautos and other option to search this compiled macro?

You can reference it in Macro documentation which illustrate how to store and reuse complied macro.

Ksharp

Gsamaritan
Calcite | Level 5

Ksharp:

I'm so appreciate to your help!

The

auto call library and

compiled stored macro facility

are two different things. SAS's search order is:

1. macros defined in the current session

2. auto call library

3. compiled stored macro facility.

The auto call library is the kind that we define sas source code and then store the source code somewhere, the macro name should match the .sas program name. The MAUTOSOURCE, SASAUTOS, MRECALL options are associated with this situation.

But for compiled stored macro facility, the associated options are MSTORED, SASMTORE:

When compile I used:

options mstroed sasmstore=mymac;

libname mymam 'G:\myproj\';

%macro AA(            ) / store;

%mend;

When call the macro in other SAS session I used:

options mstroed sasmstore=mymac;

libname mymac 'G:\myproj\';

%AA;

I also tried to put those three options for autocall there, still doesn't work

It seems there is no much talk about how to force SAS search compiled stored macro facility many times, even no much talk about compiled stroed macro facitlity. I really hope I can get help from gurus here.

Tom
Super User Tom
Super User

Try changing the LIBNAME statement that you use when using the macros to include the ACCESS=READONLY message.

Then if for some reason one of the macros was attempting to redefine a compiled macro it should complain about access and you might be able to trace the cause of your current error message.

libname mymac 'g:\myproj\' access=readonly;

Gsamaritan
Calcite | Level 5

Tom,

I tried with your code there, still doesn't work.

Thanks a lot! In any case you get or run into the answer, please share with us.

Ksharp
Super User

I tested it. You should close the first SAS session which create compiled maro .then use this compiled maro again.

When I open a SAS session and input:

%macro myfile /store;

proc print data=sashelp.class;

run;

%mend myfile;

libname xx v9 'c:\';

options mstored sasmstore=xx;

Then close this SAS session and open another SAS session input:

libname xx v9 'c:\';

options mstored sasmstore=xx;

%myfile

It worked.

Ksharp

Peter_C
Rhodochrosite | Level 12

why use compiled macros?

Gsamaritan
Calcite | Level 5

Ksharp,

Every time when I call the macros in another session, the SASMACR catalog is permanently stored and the compiling program is closed/nerver open. I still got the problem there, maybe too many macros and there is no much thing about force sas to search the catalog repeatedly.

Peter, we should not use compiled macros? I saw lots of this practice in company, I would like to get your suggestions.

Thanks, all!

Peter_C
Rhodochrosite | Level 12

my suggestion

use Sas autocall

Lots of flexibility and control

can add without overriding all

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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