Thanks Patrick. The manual looks helpful.
I saw autocalls before and know about saving each macro as one file. This felt very strange to me coming from Python/C++ background. I feel my %start_timer %end_timer macros should be in one file in one folder and my %start_parallelisation %end_parallelisation macros should be in one file in another etc. If I have a large number of macros, and they all have their own files in one place.... then it will go very chaotic. Maybe I just haven't gotten use to the concept.
However, I know that autocall can read macro definitions from a catalog. I haven't gotten that to work because the SAS documentation didn't give much explanation for this. I am still trying to work it out.
It's about "modularization" - but you can call macros in macros if that makes sense (I normally don't do it as I try to keep things simple).
ma.sas
%macro ma();
....
%mend;
mb.sas
%macro mb();
....
%mend;
m_comb.sas
%macro m_comb();
%ma();
%mb();
%mend;
You could have these 3 .sas files all in the same folder (part of Autocall). If a user calls "m_comb()" then SAS will work out "on the fly" that it first has to compile the macros called within macro "%m_comb()".
Thanks everyone for all their suggestions.!
the autocall and compiled features are different.
* autocall means that SAS search for a macro definition reference in a set of filerefs (folders) which are the value of the option sasautos
the autocall is turned on my default
%put mautosource:%sysfunc(getoption(mautosource));*is boolean;
%put %sysfunc(getoption(sasautos,keyword));* is character;
when a macro is called SAS searched the filerefs for a file with the name of the macro
and %includes it, the result of which is that the macro is compiled and stored in the work.sasmacr catalog.
* compiled and stored
(stored and compiled: not alphabetical, nor the sequence of events, but ...)
macros have the %macro statement option "/store" and when they are submitted, or %included,
then they are compiled and written not to work.sasmacr catalog
but to the libref which is the value of the option sasmstore.
%put mstored:%sysfunc(getoption(mstored));*is boolean;
%put %sysfunc(getoption(sasmstore,keyword));*is character
I kind of like the idea of copying the compiled and stored catalog to the user's work fileref
but that is a solution for multiple users in multiple sessions.
I think that is a lot of copying
another solution is to reset the libref of sasmstore.
it does not have to be 'library'.
note: files with macros with the store option set ought not to be in any of the filerefs in the sasautos search list.
see also:
http://www.sascommunity.org/wiki/SASautos_Companion_Reusing_Macros
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.