1

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";
mmhj
  • 121
  • 1
  • 10
  • 1
    SAS does not have "databases". Are you saying you want to use saspy to connect to the same application server to launch SAS that you connect to when you run Enterprise Guide to launch SAS so that any libnames that it creates are there? Are you sure used the application server to launch SAS and didn't just launch a vanilla SAS session? Are you sure the application server is creating the libnames you see in Enterprise Guide? Perhaps the libnames are bring setup by your settings in Enterprise Guide instead. – Tom Jan 25 '20 at 16:28
  • The data I need to get to is only accessible through SAS, the libraries themselves are setup via SAS, that is why I referred to it as SAS-databases. I want to do what you mention, gain access to the libraries. I'm not sure how distinguish between the application server used for accessing the libraries vs. the vanilla session, since without being able to use my login credentials they effective look exactly the same. How would one distinguish between the application server creating the libnames, and the libnames being setup by settings? I have separate logins for the server, and for the user. – mmhj Jan 25 '20 at 18:09
  • The link you posted lists many ways for saspy to connect a SAS session. Which did you use? Did you discuss it with your local SAS administrator? – Tom Jan 25 '20 at 21:36
  • Sounds like you have a SAS server set up somewhere. Do you happen to know if you're connecting to the server via your python code that you're calling a 'session' or just a local version of SAS? – Reeza Jan 26 '20 at 01:18
  • @Tom I have had most success with this particular approach: https://sassoftware.github.io/saspy/install.html#remote - Since I am forced to use SAS EG, following the same method as in EG itself is closest to what I know the config for. Whether that is the best way to do it, I'm sure I cannot judge properly. I discussed it with the other department who have the contact to SAS and their admins (whom I assume are the database/server admins). I was simply told to use EG, however it is inconvenient, and I am willing to fight for a better option. Which is why I am trying to solve it on my own. – mmhj Jan 26 '20 at 13:11
  • @Reeza That is what I think as well, the department I am in is forced to connect to a SAS server (Workplace Server? Not even a SAS Server? I have no clue) via SAS EG. I haven't had any success connecting to the server via python, however I am using the host and port info that I use to connect to it in EG. My guess is that I am simply getting into a local version of SAS, with no connection to backend database. Perhaps I should try to connect to the server itself outside of saspy? I haven't done any prodding in that area. – mmhj Jan 26 '20 at 13:28
  • Can you update the question to show the python code you tried and any error messages observed? Also show the properties of the EG connection profile you are using. Is it ? If not, is the server remote or local ? Integrated authentication ? Saved login in profile ? Auth domain ? A profiled connection connects to workspace server. The abilities of the of workspace session can be limited if so desired by the SAS admin (such a no new libnames) or have predefined libnames for all connections made to the WS server. Show any code (masked) you submit to setup your librefs – Richard Jan 26 '20 at 14:50
  • 1
    Also, if you're a SAS customer you can call tech support and they'll help you get connected with SASpy. You pay for it, so may as well use it. – Reeza Jan 26 '20 at 18:14
  • @Richard I've updated the question. I use an EG connection profile, with a server address, port number, and my user and password filled out. The server is remote. I believe it is integrated auth yes, I am not entirely sure. My login is saved in profile. No auth domain that I know of. Yes, I believe I am connecting to a workplace server (through EG). The workspace session has predefined libnames for all connections made. I do not have my work laptop with me atm, I will update with the specific libref code. – mmhj Jan 28 '20 at 16:57

1 Answers1

1

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.

Tom
  • 68
  • 6