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
366 stars 149 forks source link

How can i write back to the SAS academics library? #545

Closed sourabh2404 closed 1 year ago

sourabh2404 commented 1 year ago

Hi,

I have the following code:

sas = saspy.SASsession(**iomj) print("SAS Connection Successful !!") print("Accessing SAS Table Now....") print(" ")

data = sas.sd2df(table='FISH', libref='SASHELP')

print(data.head(5)) sas.dataframe2sasdata(data, table='FISH_Out', libref='WORK')

but when I go and check the WORK library, i cannot find the 'FISH_Out' table. Can anyone please advise.

sourabh2404 commented 1 year ago

I tried checking the other issues reported and by running the below code, I get the following error message if I change the library name from WORK to SASHELP print('ERROR: '+sas.saslog().rpartition('ERROR:')[2][:200])

ERROR: User does not have appropriate authorization level for library SASHELP.

How can I provide the user the access to this library to perform a write operation?

tomweber-sas commented 1 year ago

Hey, I can help with this. Can we see the log from the original problem with fishout going to the work library? I don't see any information about that. Can you show the output from running your code? Along with the extra code here; just run the following and show the output:

sas = saspy.SASsession(**iomj)
print(sas)

print("SAS Connection Successful !!")
print("Accessing SAS Table Now....")
print(" ")

data = sas.sd2df(table='FISH', libref='SASHELP')

print(data.head(5))
sd = sas.dataframe2sasdata(data, table='FISH_Out', libref='WORK')

print(sd)
print(sas.lastlog())

If you're running this in a notebook, separate the code into different cells to get all of the output. If just interactively in a shell, then everything will show up, no worries.

As for the sashelp library, it's a read only library and you can't write to it. You can definitely write to the work library, so let's see what's going on with that.

Thanks, Tom

sourabh2404 commented 1 year ago

Hi Tom,

Thanks for the response, instead of writing to work library, I created a new library and was able to write to it. We can close this issue now.

tomweber-sas commented 1 year ago

well, ok. Though there's no reason you shouldn't be able to write to the work library as well. Let me know if you want to pursue this. Thanks, Tom