- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Friends -
Is there any way to execute python code from SAS Environment (Base SAS and SAS EG ?
What are all the steps we need to follow or enable any settings or any config changes in SAS inorder to run the python code ?
We are using SAS 9.4 M7 on Redhat linux ?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is it an entirely separate process or are you expecting Python to use SAS data sets and such? If it's the latter look into SASpy
If it's the former, look into CALL SYSTEM where you can execute system tasks via SAS. You basically find the command line equivalent (Unix) to execute your Python Script and then ask SAS to execute that command as needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So details would be like what type of python code and libraries you want to use, and what type of code you plan to run. If it's a process to take a CSV file and do something that Python can do but SAS can't then that's probably easy enough. If you want to run a flask app, I'm seeing possible issues. If you're planning to interface with SAS data somehow I'm also seeing issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS recently introduced PROC PYTHON -- but it's only in SAS Viya, not in SAS 9.4.
You can include Python code within custom functions using PROC FCMP, and that works in SAS 9.4 Maint 7.
Or you can run Python scripts by kicking off an external process via SYSTASK or another mechanism to call out to the shell, if that's something you're allowed to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do I need to enable any settings for this python code to run from SAS Enterprise Guide ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A Python runtime (of course) and some environment variables are needed to set it up. See the documentation for the FCMP Python object and these config instructions.
Set these at SAS startup (usually a SAS admin task) or you might be able to use the OPTIONS statement in code right from EG.
Examples of setting these (your paths may be different):
options set=MAS_M2PATH="/install/SASServer/SASHome/SASFoundation/9.4/misc/tkmas/mas2py.py"
options set=MAS_PYPATH="/usr/bin/python";