Running SAS code through Python to login to a specific SAS-database

2.6k Views Asked by At

I need to login to a SAS-database through Python, to get access to the SASdata project folders and pull data. I am using updated packages per 01/20/2020, testing via saspy and Jupyter Notebook on Windows 10.

The way I do it at the moment is to pass SAS code on SAS Enterprise login (via %let user = ****** & %let pass = ****** and libnames). My goal is to be able to pull data and work on it through Jupyter, or even just a regular code editor.

The problem I have is gaining access through my Python code. I have looked through https://sassoftware.github.io/saspy/install.html#configuration and tried messing with the authkey. However, I haven't been able to gain access to anything but a regular SAS session, with none of the libraries I need to access being available.

My thinking is that if I could pass the exact same code through my script/notebook, I should be able to connect to the underlying SASdata folder/projects.

EDIT: @Richard This is the little bit of code I use to start the session sas = saspy.SASsession()

I have my config set to 'iomwin':

iomwin   = {'java'      : '/usr/bin/java',
            'iomhost'   : 'the_specific_server',
            'iomport'   : the_specific_port,
            'encoding'  : 'windows-1252',
            'authkey'   : 'data_auth',
            'classpath' : cpL
            }

However, when I run this code I do not get access to the server. I've tried with the config set to default, typing in my user and pass, but I do not get through to the server.

EDIT 2:

This is the code I run on start up (of a SAS session):

%let user = *****;
%let pass = *****;

libname ***** ***** host="*****" server="*****" user="&user" password="&pass" schema="DBA";

libname ***** ***** host="*****" server="*****" user="&user" password="&pass" connection=unique schema="dbo";
1

There are 1 best solutions below

0
On

You can use the IOM access method to connect to the same workspace server you connect to using EG. See the doc here: https://sassoftware.github.io/saspy/install.html#remote You can get help with this directly by opening an issue on saspy github page: https://github.com/sassoftware/saspy/issues (click new issue). You can also search all of those issues for the same question and explanation of how to set this up, if you find that helpful.