BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
peiranchen
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
sastpw
SAS Employee

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

View solution in original post

10 REPLIES 10
ChrisNZ
Tourmaline | Level 20

You need a libname statement before the 

  proc datasets dd=ua19; 

statement.

Also you can add option noprint to the statement above.

peiranchen
Calcite | Level 5

Thanks 

proc datasets dd=ua19; 

# 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'
            }    
ChrisNZ
Tourmaline | Level 20
The library must be be created for you to use it. Either in the python code or in an autoexec file.
You can't use it if it's not defined.
peiranchen
Calcite | Level 5

Thanks 

ChrisNZ
Tourmaline | Level 20
The message is clear.
ERROR: Libref UA19 is not assigned.

Clearly the connection differs or the configuration is different in some way.
sastpw
SAS Employee

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

 

peiranchen
Calcite | Level 5

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?

 

>>> sas.submit("""
... libname statslib meta library=ua19;
... """)
{'LOG': "\x0c25                                                         The SAS System                              09:22 Monday, October 8, 2018\n\n183        ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue;\n183      ! ods graphics on / outputfmt=png;\nNOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1\n184        \n185        \n186        libname statslib meta library=ua19;\nNOTE: Libref STATSLIB refers to the same library metadata as libref UA19.\nNOTE: Libref STATSLIB was successfully assigned as follows: \n      Engine:        META \n      Physical Name: /sasdata/lev1/secure/ua19\n187        \n188        \n189        ods html5 (id=saspy_internal) close;ods listing;\n190        ", 'LST': ''}
>>> a = sas.sasdata("APPLIC","STATSLIB")
Table STATSLIB.APPLIC does not exist. This SASdata object will not be useful until the data set is created.
>>> sas.saslib('STATSLIB',path='/sasdata/lev1/secure/ua19')
 
27                                                         The SAS System                              09:22 Monday, October 8, 2018
 
201        
202        libname STATSLIB    '/sasdata/lev1/secure/ua19'  ;
NOTE: Libref STATSLIB was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasdata/lev1/secure/ua19
203        
204        
>>> a = sas.sasdata("APPLIC","STATSLIB")
Table STATSLIB.APPLIC does not exist. This SASdata object will not be useful until the data set is created.
sastpw
SAS Employee

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

sastpw
SAS Employee

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 3894 views
  • 1 like
  • 3 in conversation