Hi,
How can I connect to SAS via Python? What should be installed on SAS side to be able to do this? Or is there any other thing that should be considered?
In what sense do you mean "connect"? For instance, you could just want to run programs in batch which is a simple command line call, or maybe you want to access data which may need a driver or specific software. Give as much detail about what your doing/expect as possible.
Hello @Riana,
please give a look to this great post published by @ChrisHemedinger : https://blogs.sas.com/content/sasdummy/2017/04/08/python-to-sas-saspy/
It is about SASPy, the tool you can use to connect from Python to SAS.
To expand on what @JuanS_OCS suggested:
SAS provides an open-source library called SASPy that allows you to connect your Python console or Jupyter Notebook to SAS. You can find the library on the sassoftware GitHub account. It works with SAS on any OS: Windows, Unix/Linux, even z/OS.
SASPy brings a "Python-ic" sensibility to this approach for using SAS. That means that all of your access to SAS data and methods are surfaced using objects and syntax that are familiar to Python users. This includes the ability to exchange data via pandas, the ubiquitous Python data analysis framework. And even the native SAS objects are accessed in a very "pandas-like" way.
import saspy
import pandas as pd
sas = saspy.SASsession(cfgname='winlocal')
cars = sas.sasdata("CARS","SASHELP")
cars.describe()
More details, including a video with a demo, in this article: Introducing SASPy: Use Python code to access SAS.
Thanks @ChrisHemedinger for you reply.
I'm working on a presentation about Jupyter notebook and SAS and how it works(for dummies :-)). I need to create a demonstarion of connection between SAS servers, jupyter notebook, saspy,... that how they communicate in a simple way. Is there such document or link that can be used for this purpose?
@Riana - are you looking for something like an architecture/conceptual diagram? I'm not aware of one that exists today, though it's a good idea to have one. When you draw one out, let us know 😉
There is some good information in this article by @EdwardJin.
@Riana I am not sure if this answers your question but I have once made a simplified illustration on how Jupyter works for a presentation I gave.
The "kernel" node that is shown in the image is any Jupyter Kernel of which one is the SAS kernel
The link between the Notebook Server node and the Kernel node links to zeromq
The link between the Notebook Server node and the Notebook File node links to JSON
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.