Hi SAS Experts,
I am new to SAS programming. My task is to use a linux client to download data sets in a remote SAS server (9.4 and a linux server) over IOM method.
I am using saspy. Successfully login to the remote SAS. I am able to get data sets from default libraries such as SASHelp. But I am not able to access some other libraries which my Enterprise Guide can access.
I am wondering how to fix this problem.
Here is my code. The error is highlighted below. Thanks!
Python 3.5.4 (v3.5.4:3f56838976, Aug 7 2017, 12:56:33) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import saspy >>> import pandas as pd >>> sas = saspy.SASsession(cfgname='iomlinux') SAS Connection established. Subprocess id is 5342 >>> sas.datasets('ua19') 6 The SAS System 08:13 Friday, September 21, 2018 37 38 proc datasets dd=ua19; ERROR: Libref UA19 is not assigned. 38 ! quit; NOTE: Statements not processed because of errors noted above. NOTE: The SAS System stopped processing this step because of errors. PROCEDURE| _DISARM| STOP| _DISARM| 2018-09-21T08:13:58,178+10:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 25968640| _DISARM| 15634432| _DISARM| 11| _DISARM| 11| _DISARM| 16| _DISARM| 17600| _DISARM| 0.010000| _DISARM| 0.002233| _DISARM| 1853100838.176265| _DISARM| 1853100838.178498| _DISARM| 0.000000| _DISARM| | _ENDDISARM NOTE: PROCEDURE DATASETS used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 39 40 >>> sas.datasets('sashelp') 5 The SAS System 08:13 Friday, September 21, 2018 31 32 proc datasets dd=sashelp; Directory Libref SASHELP Levels 3 Level 1 Engine V9 Physical Name /opt/sas/SASHome/SASFoundation/9.4/nls/en/sascfg Filename /opt/sas/SASHome/SASFoundation/9.4/nls/en/sascfg Inode Number 7742298 Access Permission rwxr-xr-x Owner Name sas File Size 4KB File Size (bytes) 4096 Level 2 Engine V9 Physical Name /opt/sas/SASHome/SASFoundation/9.4/nls/en/sascfg Filename /opt/sas/SASHome/SASFoundation/9.4/nls/en/sascfg Inode Number 7742298 Access Permission rwxr-xr-x Owner Name sas File Size 4KB File Size (bytes) 4096 Level 3 Engine V9 Physical Name /opt/sas/SASHome/SASFoundation/9.4/sashelp Filename /opt/sas/SASHome/SASFoundation/9.4/sashelp Inode Number 7734990 Access Permission rwxr-xr-x Owner Name sas File Size 16KB File Size (bytes) 16384 Member # Name Type Level File Size Last Modified 1 AACOMP DATA 3 448KB 31/08/2017 11:25:27 AACOMP INDEX 184KB 31/08/2017 11:25:27 2 AARFM DATA 3 256KB 31/08/2017 11:25:38 AARFM INDEX 40KB 31/08/2017 11:25:38 3 AC CATALOG 3 24KB 10/08/2017 12:04:49 .... result committed
cool, yes, the problem with the 'exist' function not finding VIEWs is fixed in 2.2.9. Can you install that version of saspy and give it a try? Then you can use the autoexec key in your config definition to have this pre-assigned for you whenever you connect.
Tom
You need a libname statement before the
proc datasets dd=ua19;
statement.
Also you can add option noprint to the statement above.
Thanks ChrisNZ.
The statement
proc datasets dd=ua19;
is created by python code. I am not able to change it.
Here is the connection configuration.
# build out a local classpath variable to use below for Linux clients cpL = "/Users/abc/Documents/bit/uac-extract/java_lib/sas.svc.connection.jar" cpL += ":/Users/abc/Documents/bit/uac-extract/java_lib/log4j.jar" cpL += ":/Users/abc/Documents/bit/uac-extract/java_lib/sas.security.sspi.jar" cpL += ":/Users/abc/Documents/bit/uac-extract/java_lib/sas.core.jar" cpL += ":/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/saspy/java/saspyiom.jar" iomlinux = {'java' : '/usr/bin/java', 'iomhost' : 'sashostname.edu.au', 'iomport' : 8591, 'encoding' : 'latin1', 'authkey' : 'uacauthkey', 'classpath' : cpL, 'appserver' : 'SASApp - Workspace Server' }
Thanks ChrisNZ to follow up. The library UA19 exists. When I use Enterprise Guide using the same connection, I am able to download data sets from UA19
Hey, glad to see you got connected up and are running with saspy. So, there's a couple of possibilities here.
You are connected to a workspace server, and if that server had pre-assigned libraries, they would be available to you through the code you're running. So, either the library you do see assigned in your EG session is not pre-assigned in the workspace server via metadata, but perhaps by EG, or another possibility is that there is more than one Appserver, and EG is connecting to a different one that you've configured for saspy.
Not knowing which is the case, the other obvious question is whether you can simply assign it yourself and at least accomplish your task.
there's a saslib() method off the SASsession you can use to assign it. Or, of course, you can submit() the libname statement as well. If that works, and until you find out why it's not already there, you can add another key to your configuration definition to have saspy pre-assign it for you when you make a connection (new in 2.2.9);
'autoexec' : 'libname ua19 whatever_path_or_options_you_need;'
Can you verify that this workspace server is the same one as in EG, and, I suppose the other thing is if you are connecting with the same credentials. It could be possible that the library could be pre-assigned via mnetadata, but only for some users. I don't know for sure, but if you're using the same creds then that's moot.
Thanks,
Tom
Hi @sastpw
Thanks heap for your answer.
I tried and I am now able to assign my library after finding its path. But sasdata function is not able to recognise APPLIC is a View. Is there any chance to fix it?
cool, yes, the problem with the 'exist' function not finding VIEWs is fixed in 2.2.9. Can you install that version of saspy and give it a try? Then you can use the autoexec key in your config definition to have this pre-assigned for you whenever you connect.
Tom
2.2.9 is the current version, so you can just do
pip uninstall saspy
and then
pip install saspy
and you should get the current 2.2.9 version.
Be sure your configuration is in your sascfg_personal.py file, not the example sascfg.py file that is part of the saspy repo, because sascfg.py can be overwritten when you do this. That's why you put your configurations in the _personal file so they don't get clobbered when you upgrade!
Tom
Thanks a lot @sastpw !
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: