How do I invoke a sas script in python?

蓝咒 提交于 2020-01-13 05:33:29

问题


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

Im using the following code to start sas:

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

回答1:


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

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

  2. You need to tell SAS where to find the config file

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

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.

Good luck!



来源:https://stackoverflow.com/questions/24365609/how-do-i-invoke-a-sas-script-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!