SAS宏保存以便快速调用的三种解决方案

2024-06-22 11:46:04阅读量:48 字体:

1.方式一:%include
%include "full_pathsortds.txt"; inserts any code in the file called sortds.txt into your program
at the location of the %include statement. Using this method, the macro must be recompiled every
time a %INCLUDE is executed.

Advantage: This approach was presented in SAS? at least 15+ years ago; it is an easy to use and straight
forward approach.
Disadvantage: The macro definition is compiled every time the %INCLUDE is executed.
2.方式二:mautolocdisplay
Example:
filename autoM “C:SESUGTESTAUTOCALL_MACROS”;
options mautolocdisplay mautosource sasautos = (autoM) ;

The macro is saved in the folder with fileref autoM as sortDS.sas but it is not a SAS? program, it is a macro. In our
program, we call the macro using %sortDS. Once the macro is called, we can see the source of macro code in the
log .

The advantage of using the autocall facility is that all user-defined macros are stored in a standard location and they
are not compiled until they are actually needed. The macro is stored uncompiled in an autocall library. It removes the
macro definition from the calling program itself. Macros defined in separate programs must be recompiled every time
that program is execute but the macro is compiled only once and then the compiled version can be reused during the
SAS? session without recompilation.

3.方式3:STORED COMPILED MACRO FACILITY

The most exciting method of saving macros is using the store compiled macro facility. The stored compiled macro
facility compiles and saves the macro source code in a permanent catalog. This compilation occurs one time, and can
store the source code permanently in a SASMACR catalog. Programs can always be retrieved, the macro will work,
but SAS? (macro processor) will not compile the macro again. This is the great feature of the stored compiled macro
facility.

具体实现:
options mstored sasmstore=mjstore;
libname mjstore “C:SESUGTESTCompiled_macro_library”;

%macro sortDS (in=, out =, by=) / store source des="get sortDS macro“ ;
* Macro for sorting data set &in. ;
proc sort data = &in.
out = &out. ;
by &by. ;
run ;
%mend sortDS;

Advantages:
? No repeated compiling of macro programs that are repeatedly used
? Possibility of displaying the entries in a catalog containing compiled macros saving macro compile time
? There is no need to save and maintain the source for the macro definition in a different location
? Keeping track of macros is easy
? Storing more then one macro per file
? Compile and Store is faster because there is a decrease in time for searching, %including, compiling and storing
in the WORK.SASMACR catalog.
Disadvantage:
? Cannot be moved directly to other operating systems.
? Must be saved and recompiled under new OS at any new location.

将方式3的宏屏蔽的方法:
There is a way to hide code when executed so that it does not appear in the log. To avoid displaying code in the log,
store the code as a stored compiled macro. Because the macro is stored compiled, it cannot be seen in an editor.
More importantly, the options that write information about the code to the log can be turned off in the macro. The
following is a simple example:
屏蔽宏的程序实例
libname libref ’macro-storage-library-name’;
options mstored sasmstore=libref;
%macro sortDS / store;
options nonotes nomlogic nomprint nosymbolgen nosource nosource2;
...more SAS? statements...
%mend;

By storing the code as a compiled macro, virtually no information is written to the log about the code. Only warnings
and errors will be written to the log
 

以上就是SAS宏保存以便快速调用的三种解决方案的全部内容,望能这篇SAS宏保存以便快速调用的三种解决方案可以帮助您解决问题,能够解决大家的实际问题是谜爱阁生活网一直努力的方向和目标。

推荐阅读

  • 快手怎么买热门

    快手怎么买热门

    上了快手热门的视频可以推送给更多的用户,让视频得到更高的热度,在快手买热门的具体操作方式如下: 快手怎么买热门 1、打开快手,点击左上角的三条横线”,进入功能栏”界面。 2...

    阅读: 873

  • 微信闭关中是什么状态

    微信闭关中是什么状态

    微信闭关中是不与外界往来的状态。微信状态显示闭关,可能是因为最近比较忙,又或者是碰到烦心的事情,有一种自我封闭的含义。以下是设置微信状态的操作方法: 微信闭关中是什么状态 1、打开微信,点击我&rdq...

    阅读: 863

  • qq打开文件默认设置怎么改

    qq打开文件默认设置怎么改

    qq,为腾讯qq的简称,是一款基于互联网的即时通信软件。修改qq打开文件默认设置的具体操作如下: qq打开文件默认设置怎么改 1、点击手机设置”-应用与权限”-应用管理&rdq...

    阅读: 833

  • 微信注销后聊天记录还能恢复吗

    微信注销后聊天记录还能恢复吗

    如果对聊天记录进行备份或迁移的话,微信注销后聊天记录可以恢复。如果没有对聊天记录进行备份或迁移的话,微信注销后聊天记录无法恢复。以下是注销微信的操作步骤: 微信注销后聊天记录还能恢复吗 1、打开微信A...

    阅读: 941

  • 微信群太多怎么实现分组管理

    微信群太多怎么实现分组管理

    微信群太多可以使用折叠群的功能进行分组管理,将群设置为折叠群的具体操作步骤如下: 微信群太多怎么实现分组管理 1、打开微信app,点击下方的通讯录,再点击群聊进入群聊界面。 2、进入群聊界面后,选择...

    阅读: 892

  • 微信预约挂号怎样切换就诊人

    微信预约挂号怎样切换就诊人

    以梧州市中医院公众号为例,在梧州市中医院微信公众号预约挂号切换就诊人的具体操作步骤如下: 微信预约挂号怎样切换就诊人 1、打开微信APP,搜索梧州市中医院公众号”,点击该公众号,再点击发消...

    阅读: 832