如何在 python 中调用 sas 脚本? [英] How do I invoke a sas script in python?

查看:96
本文介绍了如何在 python 中调用 sas 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以打开一个 sas 实例,但我不确定如何让它运行特定的 sas 脚本.

I can open a sas instance but im not certain how to get it to run a specific sas script.

我使用下面的代码来启动sas:

Im using the following code to start sas:

import subprocess
subprocess.call(['C:\Program Files\SAS\SASFoundation\9.2\sas.exe'])

推荐答案

您可以通过子进程调用将附加参数传递给 SAS,但您还需要记住的重要事项是:

You can pass additional parameters through to SAS via subprocess call, but the important things you also need to remember are:

  1. 您需要告诉 SAS 在哪里可以找到 AUTOEXEC 文件

  1. You need to tell SAS where to find the AUTOEXEC file

您需要告诉 SAS 在哪里可以找到配置文件

You need to tell SAS where to find the config file

我有一个用于调用 SAS 脚本的 shell 脚本,调用如下所示:

I have a shell script that I use to invoke SAS scripts and the call looks like:

sas -config $SAS_CONFIG -autoexec $SAS_AUTOEXEC $SAS_CODE/$1

所以你的电话应该是这样的:subprocess.call(['C:\Program Files\SAS\SASFoundation\9.2\sas.exe', '-config', config_path, '-autoexec', autoexec_path, '-sysin', sas_script_path])

So your call should look like: subprocess.call(['C:\Program Files\SAS\SASFoundation\9.2\sas.exe', '-config', config_path, '-autoexec', autoexec_path, '-sysin', sas_script_path])

您需要为上述路径设置变量.

You'll need to set up the variables for the paths above.

祝你好运!

这篇关于如何在 python 中调用 sas 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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