2

I have multiple SAS program files, each of which has various macro variables which need to be set dynamically through an excel file. I was wondering if I can pass the values from the excel file to the SAS program through a python script (or shell script). I wish to automate the process of setting parameter for each SAS program manually.

Please suggest.

9
  • Why not just import the excel files in SAS? Commented Jul 26, 2016 at 20:45
  • I am trying to automate the execution of all sas programs by setting their parameters through the common excel file.I am reading the excel file and based on the program name I want to set parameters for that particular code file in SAS. If I had to import excel in SAS it does not automate anything for me. @superfluous Commented Jul 26, 2016 at 20:57
  • 1
    @codemob Well, you could read it into SAS then set the parameters inside of the SAS job? Commented Jul 26, 2016 at 21:22
  • Anyway, are you asking a Python question (how do I run [arbitrary program] with [arbitrary parameters] given an excel file), or are you asking a SAS question (how do I run SAS in batch and pass parameters to it)? Commented Jul 26, 2016 at 21:23
  • 1
    Do you know how to run SAS in batch and pass parameters to it? Commented Jul 26, 2016 at 21:36

2 Answers 2

1

You can pass a string to SAS using the -sysparm command line option, and this string will be available in SAS as the &sysparm automatic variable.

E.g. (from the command line:)

sas myprogram.sas -sysparm myparam

If you need to parse the string inside SAS, the %scan() macro function will probably be useful.

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

Comments

1

So I did figure out how I can solve this:

        subprocess.call(['C:\\Program Files\\SASHome\\SASFoundation\\9.4\\sas.exe', '-config', config_path, '-autoexec', autoexec_path,'-sasinitialfolder',sasinitialfolder,'-sysin', sas_script_path,'-log',ori_log])

I made a subprocess call from python to run it in Bash and I am sending different parameters to this call with respect to the SAS program I am calling. The parameters which I pass from the subprocess call are captured in the SAS program through a %sysget command.Thank you.

Comments

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.