BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Can you save a group of macros in a library type folder? I want to be able to have access to all of my macros without having to open and rerun each macro file.

Can you do something like

libname library 'C:\macros';

%macro library.sortby(filename, var);
proc sort data=&filename;
by &var;
run;
%mend library.sortby;

Then next time I open sas I can just run

libname library 'C:\macros';

and have access to these macros?
4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
The Macro facility has several ways for you to streamline and call already defined and debugged macro programs. For more information, reference the macro documentation topic, entitled Storing and Reusing Macros:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002062214.htm

which is composed of these 3 sub-topics:
Introduction to Storing and Reusing Macros
Saving Macros in an Autocall Library
Saving Macros Using the Stored Compiled Macro Facility


cynthia
Patrick
Opal | Level 21
The most convenient way for what you want to achieve (avoid re-running) would be an Autocall Library (SASAUTOS).
SAS_user
Calcite | Level 5
Yes you can.

Storing a macro:
libname AAA "C:/macros";
options mstored sasMSTORE=AAA;
%macro TestStore/store;
%put stored macro;
%mend testStore;

The macro will be stored in library AAA.

If you want to use it, you have to use the same option, and assigned library AAA.

libname AAA "C:/macros";
options MSTORED SASMSTORE = AAA;
%testStore;
Peter_C
Rhodochrosite | Level 12
others have provided guidance to a proper solution, so there is little left for me to add,
except to show how you can save macros in a library.
I'm referring to macro code. Not the compiled macros (which when compiled can be stored and retrieved through the mstored and sasmstore options)..[pre]filename macros catalog team.macros ;[/pre]where TEAM would be a libref (perhaps) pointing at a shared area.
The filename engine CATALOG, allows us to store source like macro code progrms, in catalog entries.. The catalog can be addressed usin the fileref as "an aggregate storage location", just like a folder in hierarchical storage or a pds in zOS.

you still need to refer to the macros catalog fileref in the sasautos option value, but you have your
"macros saved in a library"

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

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2950 views
  • 0 likes
  • 5 in conversation