pip install saspy
Configure SASPy
SASPy
SASPy is a Python module that allows one to use the best of Python and SAS in a single environment. With SASPy, data manipulation and preparation can be performed with Pandas while statistical procedures can be conducted in SAS. Essentially, SASPy allows you to bridge a Python session with a SAS session running in the background. The following instructions are to configure a locally installed version of SAS with Python (refer to the SASPy documentation for additional options).
Install SASPy
- Activate the Python virtual environment
- Install SASPy
Configure SASPy
- Start a Python console or continue in the activated Python environment in PowerShell.
- Create a personal template cfg file. This creates a file that will be modified and used to configure SASPy. When executing the autocft.main() command, the path of the personal template file will be displayed upon execution. Make not of the path as this file will need to be modified.
# Load the autocfg function from the saspy module
from saspy import autocfg
# Create a template personal cfg file that is used to configure SAS sessions
autocfg.main()
- Navigate to the path of the displayed directory
- Open the sascfg_personal.py file
- Modify the file to set the path of the Java run time executable
- Install Java SE Runtime Environment if needed
- Save and close the file
= {
autogen_winlocal "java" : "C:\\Program Files (x86)\\Java\\jre1.8.0_451\\bin\\java.exe",
"encoding" : "windows-1252"}
Check that SASPy can start a session
import saspy
= saspy.SASsession(cfgname = 'autogen_winlocal') sas