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
SAS Super FREQ
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

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