0
votes

I have a catalog into which I would like to place uncompiled macros stored as .sas files. For example, I would like a catalog called "myMacros" which contains "Macro1.sas", "Macro2.sas", etc.

I am using SAS 9.4 on Windows.

Everywhere I have looked only tells me how to access a catalog once it already exists. I cannot find how to assign objects to a catalog. I have spent hours scouring the documentation, having read most of the SAS 9.4 Macro Language Reference and trying to make sense of FILENAME Statement, CATALOG Access Method and CATALOG Procedure.

1
In general, if you can't find how to do something search lexjansen.com to find user written papers on the topic.Reeza

1 Answers

0
votes

The gist of the idea is you create a FILE definition to the catalog and then PUT the code in the catalog.

FILENAME CODE CATALOG "WORK.TEST.SOURCE";
DATA _NULL_;
   FILE CODE ;
   PUT "PROC PRINT";
RUN;

or 1. Define where macros are stored via MSTORED SASMSTORE options. 2. Assign the library 3. Use the SOURCE option on the macro code to store the code.

Example from Michael Raithels Paper (link below):

OPTIONS MSTORED SASMSTORE=MYSTORE;
LIBNAME MYSTORE "S:\PROJECTS\SGF2015\COMPILED_MACROS";
2
%MACRO RUNCONTS (IN=, OUT=) / STORE SOURCE DES="Run Contents and Test Print";
 TITLE1 "CONTENTS AND TEST PRINT OF DS &IN. - &SYSDATE - &SYSTIME";
 PROC CONTENTS DATA = &IN. VARNUM;
 RUN;
 PROC PRINT DATA= &IN. (OBS=5) NOOBS;
 RUN;
%MEND;

Useful references: http://analytics.ncsu.edu/sesug/2005/AD07_05.PDF http://support.sas.com/resources/papers/proceedings15/3459-2015.pdf