SAS: How do I put entries into a catalog?

时光毁灭记忆、已成空白 提交于 2019-12-12 05:05:50

问题


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:


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



来源:https://stackoverflow.com/questions/39502208/sas-how-do-i-put-entries-into-a-catalog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!