user3767327
user3767327

Reputation: 23

How do I invoke a sas script in python?

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'])

Upvotes: 2

Views: 9450

Answers (1)

Maurice Reeves
Maurice Reeves

Reputation: 1583

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!

Upvotes: 5

Related Questions