Let's say I stored a macro the following way :
options mstored sasmstore=FOO;
%macro hello_world() / STORE SOURCE DES='hello world';
%put hello world;
%mend;
Now I want to copy this macro from library FOO
to library BAR
, I would like something like (this obviously doesn't work):
%copy hello_world /source LIB = BAR;
This would be the equivalent of doing :
options mstored sasmstore=BAR;
%macro hello_world() / STORE SOURCE DES='hello world';
%put hello world;
%mend;
The goal is to conveniently copy macros from a development library to a production library. How can I do this ?
Proc CATALOG
is used to copy entries from one member to another
%macro One;
%put ONE;
%mend;
proc catalog catalog=work.sasmacr;
copy out=work.holdmacr;
select one / et=macro;
run;
An alternative to copying entries is to use the concatenation feature that is provided automatically with LIBNAME
.
From SAS Help
Example 3: Concatenating SAS Catalogs
This example concatenates three SAS libraries by specifying the physical filename of each and assigns the libref ALLMINE to the concatenated libraries:
libname allmine ('file-1' 'file-2' 'file-3');
If each library contains a SAS catalog named MYCAT, then using ALLMINE.MYCAT as a libref.catref provides access to the catalog entries that are stored in all three catalogs named MYCAT. To logically concatenate SAS catalogs with different names, see the CATNAME Statement.
If the same name catalogs contain same named entries, the entry in the earliest library is used.
This is really handy during unit tests as the original does not have to be altered until updates are proven to be non-damaging. You have integration unit tests right ? ;-)