2

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'])
3
  • Did my solution work? Were you able to invoke SAS as you needed? Commented Jun 24, 2014 at 13:07
  • 2
    @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. Commented Jun 25, 2014 at 8:53
  • Excellent! I'm glad you were able to get it work for you. Best of luck with SAS! Commented Jun 26, 2014 at 19:38

1 Answer 1

5

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!

Sign up to request clarification or add additional context in comments.

4 Comments

Note that if you are running this in Unix, the above will work, but if you're running it under Windows, you need -sysin before the sas_script_path.
Ah good point. Haven't done it in Windows forever. I'll amend my answer to include sysin.
I think unix specifically does not use it though I can't verify that at the moment. SAS is weird.
I agree. It's an odd bird. When I describe SAS to other programmers who've never dealt with it they look at me like I'm lying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.