sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
367 stars 149 forks source link

sas.sd2df error #508

Closed Jennyyangyzy closed 1 year ago

Jennyyangyzy commented 1 year ago

Hi,

I've established successful connection with SAS from my local Jupyter notebook, and able to submit queries using sas.submit; however, I'm having trouble using sas.sd2df to convert it into a df, it would always give me an error 'error occurs in SAS during sasdata2dataframe. Trying to return the saslog instead of a data frame' instead.

By checking the SAS log, it seems like it stated that there's the ERROR: Connection refused.

Could you please help me resolve the issue? Really appreciate your time and help!

tomweber-sas commented 1 year ago

Can I see the code and the output/log?

tomweber-sas commented 1 year ago

I have a feeling (I can't know as I've not seen any information to be sure) that you have a production deployment you're trying to connect to. Like I mentioned in the other issue, if this is set up w/ metadata and all of that then you should be using IOM to access the workspace servers so that all of the things set up by your SAS admins is used like was configured. I think you were just specifying the wrong host/port before. Now your 'tunneling' into the machine where SAS is installed, and running your own separate SAS process having nothing to do with any of that configuration. The fact that that SAS process can't connect on a socket to your client kind of makes it seem more like this. Like that system isn't supposed to be reaching out to other systems.

But again, I have no info for real on any of this.

If it's not allowed to connect to your client, then you could try using the tunnel/rtunnel options to get around that, but again, this seems like your going down a rabbit hole trying to get around using the deployment correctly.

Don't know where that bug label thing came from, happened while I was typing.

Can you tell me if your deployment is just a stand alone Linux SAS install or if this is a real production deployment w/ Metadata and all of that?

Thanks, Tom

Jennyyangyzy commented 1 year ago

Hi Tom, Thanks so much for getting back to me so quickly! The code is like below:

import saspy
sas = saspy.SASsession(cfgname='ssh')
# result: SAS Connection established. Subprocess id is 7216

tt = sas.submit("""

libname jy '<path to my personal folder on the server>'
data jy.test;
    set sashelp.cars;
run;
""")
# This step runs without error and can find the test table in library jy

df = sas.sd2df('test','jy')
#result: error occurred in SAS during sasdata2dataframe. Trying to return the saslog instead of a data frame.

sastab = sas.sasdata('test','jy', result='text')
sasstab
# output: libref = jy
                 Table = test
                Dsopts = {}
                Result = text

sastab.contents()
#result shows in python without issue and I can see the table test has been created with correct values.

SAS log is super long, and it contains some sensitive information about deployment on the company server, so could you please kindly specify which part of the log you would like to see if not too much trouble?

As to the production deployment w/ Metadata or stand-alone Unix SAS, I'm sorry I'm not sure as I'm the end user of SAS and python instead of the Admin.

Also here is my configuration as follows:

ssh = {'sshpath': 'This is given by Admin team', 'ssh' : 'C:\Windows\System32\OpenSSH\ssh.exe', 'host' : 'This is give by Admin team for the SAS Server', 'port' : 22, 'luser' :'my user name on the SAS server', 'encoding': 'latin1', 'options' : ["-fullstimer"] }

Thanks again for helping!

tomweber-sas commented 1 year ago

Ok, you can just email me the log. I'm SAS, so it's the same NDA as if you were working with Tech Support. I want to see the part from the sd2df(). But the whole log will be helpful too. So, are you admins SAS admins, or system admins? I guess system; they told you where ssh was on your client machine? Though you also mention Admins for SAS. Do they know if they deployed this w/ Workspace servers or if it's just a single Linux SAS installation? I'm still thinking you ought to be using the IOM access method to connect to a Workspace server, but I have no info either way to be sure. At least, the log should help be see what the actual problem you're hitting now is though.

Thanks, Tom

tomweber-sas commented 1 year ago

We've addressed this offline. The connection is being blocked (firewall or something), so using the tunnel / rtunnel options in the configuration allow for the connections to work and sd2df/df2sd to function correctly. I'm still curious if this could be a deployment to use IOM, but we haven't gotten to that yet.

tomweber-sas commented 1 year ago

I'm going to close this, since you're up and running. Let me know if there's anything else, or if you find out if the deployment actually has Workspacce servers, then we can configure it for IOM. Thanks, Tom

devashree610 commented 9 months ago

Hi Tom, just wanted to know..can sd2df load 15gb sas dataset from sas enterprise guide?

tomweber-sas commented 9 months ago

hey @devashree610 can you open an issue for this, or open a discussion which is probably more appropriate, instead of adding on to a closed issue that really has nothing to do with your question? And the first thing will be what do you mean load data from EG? Thanks! Tom