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

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.

具体实现:

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:

屏蔽宏的程序实例

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/352312.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

log4j.properties log4j.xml 路径问题

自动加载配置文件: (1)如果采用log4j输出日志,要对log4j加载配置文件的过程有所了解。log4j启动时,默认会寻找source folder下的log4j.xml配置文件,若没有,会寻找log4j.properties文件。然后加…

webpack4+react多页面架构

webpack在单页面打包上应用广泛,以create-react-app为首的脚手架众多,单页面打包通常是将业务js,css打包到同一个html文件中,整个项目只有一个html文件入口,但也有许多业务需要多个页面不同的入口,比如不同的h5活动&am…

Spring安全性和密码编码

在以前的文章中,我们深入探讨了Spring安全性。 我们实现了由jdbc支持的安全性,基于自定义 jdbc查询的安全性以及从nosql数据库检索安全性的信息。 通过足够小心,我们会发现密码为纯文本格式。 尽管这在实际环境中可以很好地用于示例目的&…

SAS宏技术中,%let和call symput有什么区别?

平时经常使用的宏变量定义方法有三种: 1. %let xxxyyy; 2. Call Symput(xxx,yyy); 3. select xxx into: yyy. 三种定义方式最大的区别是在MACRO函数内定义所生成的宏变量的类型不同: Call Symput在宏函数中定义的宏变量可以在函数外调用;而%…

阿里巴巴的开源项目Druid(关于数据库连接)

原文地址:http://www.iteye.com/magazines/90文章简介 Druid首先是一个数据库连接池,但它不仅仅是一个数据库连接池,它还包含一个ProxyDriver,一系列内置的JDBC组件库,一个SQLParser。Druid支持所有JDBC兼容的数据库&a…

springcloud服务注册和发现

微服务架构中,服务发现组件是一个非常关键的组件,服务消费者、服务提供者、服务发现组件的关系大致如下: 各个微服务启动时,将自己的网络地址等信息注册到服务发现组件中,服务发现组件会存储这些信息服务消费者可从服务…

sas infile和filename

3.1 追加原始文件 原始数据可以使用以下的方法进行纵合并。INFILE语句 FILENAME语句 FILEVAR选项 操作系统自身的技术 首先,你可能要察看原始数据。可以用FSLIST过程。 语法: PROC FSLIST FILE file-specification; RUN; 实际使用中,专门的编…

Java 多线程(六) synchronized关键字详解

多线程的同步机制对资源进行加锁,使得在同一个时间,只有一个线程可以进行操作,同步用以解决多个线程同时访问时可能出现的问题。 同步机制可以使用synchronized关键字实现。 当synchronized关键字修饰一个方法的时候,该方法叫做同…

java自动化_作为测试工程师进阶自动化选Java还是Python?

这是很多测试工程师从功能跨入自动化纠结的问题,今天本文带大家一探究竟。Java和Python一直都是两种很火的语言,用Python的一定觉得Python好,用Java的只觉得Java好。Java语言 VS Python语言Java自动化方法 VS Python自动化方法综上所述&…

Spring –添加Spring MVC –第2部分

在上一部分中,我们为经理和员工实现了控制器。 既然我们知道了自己的出路,我们将做很少(但仅做很少)更复杂的事情-任务和时间表的控制器。 因此,让我们从org.timesheet.web开始。 TaskController 。 首先创建一个类&am…

CALL SYMPUT与CALL SYMPUTX区别

call symput 在data步中将值塞入宏变量http://www2.sas.com/proceedings/sugi29/052-29.pdf [SAS] CALL SYMPUT与CALL SYMPUTX CALL SYMPUT的功能是可以在DATA step内将值塞到一个macro变量里面。如果这个macro变量已经存在,那这个call就会更新该macro变量的值。 CA…

Linux基本结构

一个完整地Linux操作系统由4部分组成,即内核(Kernel)、外壳(Shell)、实用程序(Utilities)和应用程序(Applications)。 (1)内核是Linux的心脏&…

jmeter使用_jmeter工具的使用

1.本地下载到官网,5.3版本的对应的是jdk8版本,就用这个了2.解压进入bin目录,找到jmeter.bat启动它,会弹出两个窗口,一个是启动窗口,使用jmeter不可以关了它,另一个是jmeter的工作界面进入界面默…

UliPad 初体验----python 开发利器

学习python 有段时间,最近博客更新比较慢了,空闲时间在零零碎碎的学python ,难成文,也就没整理成博客。 学习python 最苦恼的就是没有趁手IDE ,之前学java 时 Eclipse 肯定是不二之选。eclipse pydev 也可以开发python…

Neo4j:找到两个纬度/经度之间的中点

在过去的两个周末中,我一直在处理一些运输数据,并且我想运行A *算法来查找两个车站之间的最快路线。 A *算法将一个EstimateEvaluator作为其参数之一,然后该评估器查看节点的经度/纬度,以确定一条路径是否值得遵循。 因此&#x…

猫狗大战

可行性背包 令dp[i][j]表示选i个人能否达到j这个状态,那么转移就和背包一样了,外层枚举选哪一个(K),2、3层枚举i,j,那么\[dp[i][j] | dp[i-1][j-val[k]];\] 转载于:https://www.cnblogs.com/bullshit/p/9902003.html

SAS的数组array介绍

SAS可以把一组同为数值型或同为字符型的变量合在一起,使用同一个名字称呼,用下标来区分。这与通常的程序设计语言中的数组略有区别,通常的程序设计语言中数组元素没有对应的变量名,而SAS数组每个元素都有自己的变量名。 一、数值型…

python while循环if_详解python基础之while循环及if判断

wlile循环while True表示永远为真,不管是什么条件都会向下执行,下面是写的一个例子。#!/usr/bin/env pythonage 24                            #给age赋一个值while True:                       …

关于页面的多种自适应布局——两列布局

我们在切页面的时候打交道最多的就是关于布局排版的技巧&#xff0c;我这里总结了一些平时做页面时用的到各种布局技巧&#xff0c;作为笔记便于日后随时查询。 1、简单结构1&#xff0c;列表在前&#xff0c;内容在后 1 <style type"text/css">2 .layout{back…

很全的sas基础知识

5.1 SAS表达式简介   &#xff11;&#xff0e;SAS常数表达式   (1)数值常数 如: 1.23、 -5、 0.5E-10。   (2)字符常数 如: name1TOME、 name2MARY、name3JOHN。   (3)日期(d)、时间(t)、日时(dt)常数 如: d101JAN80d、t19:25:19t、   dt118JAN80:9:27:05dt。  …