BookmarkSubscribeRSS Feed
Riana
Pyrite | Level 9

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?

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

JuanS_OCS
Amethyst | Level 16

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.

 

 

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Riana
Pyrite | Level 9

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? 

ChrisHemedinger
Community Manager

@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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Resa
Pyrite | Level 9

@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.

Jupyter_HowDoesItWork.PNG

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

 

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1760 views
  • 11 likes
  • 5 in conversation