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
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.
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";
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.