日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2023/12/2 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SAS宏保存以便快速调用的三种解决方案(转载) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.方式一:%include

%include "full_path\sortds.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:\SESUGTEST\AUTOCALL_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.

具體實(shí)現(xiàn):

options mstored sasmstore=mjstore;

libname mjstore “C:\SESUGTEST\Compiled_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:

屏蔽宏的程序?qū)嵗?/p>

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

總結(jié)

以上是生活随笔為你收集整理的SAS宏保存以便快速调用的三种解决方案(转载)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。