SAS:使用热键执行SAS代码 [英] SAS: Execute SAS code using hotkey

查看:178
本文介绍了SAS:使用热键执行SAS代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要执行的代码是独立我目前的计划的通过在SAS 9.4增强型编辑器中的键盘快捷键的Windows.我已经有限的成功能够只执行宏语句来实现这一点.但是,我也希望能够执行非宏语句.我该怎么做?

I want to execute code which is independent of my current program via keyboard shortcuts within the Enhanced Editor in SAS 9.4 for Windows. I've achieved this with limited success being able to execute only macro statements. However, I want to be able to execute non-macro statements, too. How do I do this?

这是我到目前为止已经想通了.

Here's what I've figured out so far.

得到通过输入KEYS"进入命令提示符或提交KEYS菜单

Get to the KEYS menu by either entering "KEYS" into the command prompt or submitting

dm 'keys';

有关的关键之一,输入定义

For one of the keys, enter the definition

%put Hello, world!;

保存新的密钥按结合.为了本说明的目的,我将其绑定到.保存后,请按和你好,世界!"将被打印到日志中.

Save the new key binding by pressing Ctrl+s. For the purposes of this explanation, I will bind it to F7. Once saved, press F7 and "Hello, world!" will be printed to the log.

我们可以进一步通过将上面的代码中的宏扩展这个概念.

We can extend this concept further by placing the above code in a macro.

%macro HelloWorld();
  %put Hello, world!;
%mend;

编译的宏.如果我们然后结合,我们可以证明一个宏可能与快捷方式被调用.

Compile the %HelloWorld macro. If we then bind %HelloWorld(); to F7, we can demonstrate that a macro may be called with a shortcut.

我们可以采取进一步的事情还没有和我们的宏保存为一个程序<7>.然后如果我们把这个在<8>库(运行寻找到那些位于您的计算机上),我们可以在任何新的SAS会话中执行它.

We can take things further yet and save our %HelloWorld macro as a program HelloWorld.sas. If we then put this in an AUTOCALL library (run %put %sysfunc(pathname(sasautos)); to find where those are located on your computer), we can execute it within any new SAS session.

它的出现,然而,只有宏语句用这种方法工作.为了证明这一点,假设我们代替定义作为

It appears, however, that only macro statements work with this method. To demonstrate this, suppose that we instead defined %HelloWorld as

%macro HelloWorld();
  data _null_;
    put 'Hello, world!';
  run;
%mend;

再次保存为并将其放置在一个自动调用目录.对我来说,当我尝试执行此,我得到以下错误:

Again, save this as HelloWorld.sas and place it in an AUTOCALL directory. For me, when I try to execute this, I get the following error:

ERROR: The SAS/EIS product with which the procedure is associated is either not licensed for
       your system or the product license has expired. Please contact your SAS installation
       representative.

经%INCLUDE

由于一个自动调用需要的宏被编译和调用,我想可能直接执行该代码.

Via %INCLUDE

Since an AUTOCALL requires a macro to be compiled and called, I thought %INCLUDE might execute the code directly.

创建一个名为HelloWorld.sas的文件,其中包含%put Hello, world!.将其保存到较短的文件路径.然后,在菜单KEYS绑定.现在将打印你好,世界!"到日志中.

Create a file called HelloWorld.sas containing %put Hello, world!. Save it to a short file path. Then, in the KEYS menu bind F7 to %include "C:\Short Path\HelloWorld.sas";. Now F7 will print "Hello, world!" to the log.

如果我们代替保存

data _null_;
  put 'Hello, world!';
run;

到<7>并尝试使用运行它我们的<12>快捷方式,我收到了同样的错误:

to HelloWorld.sas and try to run it using our %INCLUDE shortcut, I receive the same error:

ERROR: The SAS/EIS product with which the procedure is associated is either not licensed for
       your system or the product license has expired. Please contact your SAS installation
       representative.

混杂.尝试

我也试过直接输入代码放到一个按键定义,但再次,它似乎只对宏语句的工作.

Misc. Attempts

I've also tried entering code directly into a KEYS definition, but again, it only seems to work for macro statements.

可能可以使用<20>,但我的最终目标是能够使用或数据的步骤,我不认为<20>可以做到这一点.

It might be possible to use %SYSFUNC, but my ultimate goal is to be able to use PROC SQL or data steps and I don't think %SYSFUNC can do this.

推荐答案

可以使用提交命令,即定义一个键为:

You can use the submit command, i.e. define a key as:

submit "data _null_ ; put 'Hello World!'; run;"

也可用于宏调用:

submit "%HelloWorld()"

这篇关于SAS:使用热键执行SAS代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆