2
votes

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
Did my solution work? Were you able to invoke SAS as you needed?Maurice Reeves
@Maurice Yes thank you very much! I can confirm that the -sysin option is required for this to work. Also, I had to use double backslashes '\\' instead of single ones in all my path variables to get this to work.user3767327
Excellent! I'm glad you were able to get it work for you. Best of luck with SAS!Maurice Reeves

1 Answers

5
votes

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!