SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

SASPy: Cannot Access SAS Libraries That Are Available in DI Studio

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

SASPy: Cannot Access SAS Libraries That Are Available in DI Studio

[ Edited ]

My question relates to the SASPy module for Python and specifically how to connect to all libraries that are available in SAS DI Studio. I have setup a winiomwin connection using the package configuration file. I have the following lines in sascfg.py :

 

SAS_config_names = ['winiomwin']
SAS_config_options = {'lock_down': True}

# build out a local classpath variable to use below for Windows clients
cpW = "C:\\Program Files\\SASHome94\\SASDeploymentManager\\9.4\\products\\deploywiz__94390__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome94\\SASDeploymentManager\\9.4\\products\\deploywiz__94390__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome94\\SASDeploymentManager\\9.4\\products\\deploywiz__94390__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome94\\SASDeploymentManager\\9.4\\products\\deploywiz__94390__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Users\\hsej\\AppData\\Local\\Programs\\Python\\Python36-32\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

# and, if you've configured iom to use encryption, you need these client side jars
cpW += ";C:\\Program Files\\SASHome94\\SASVersionedJarRepository\\eclipse\\plugins\\sas.rutil_904300.0.0.20150204190000_v940m3\\sas.rutil.jar"
cpW += ";C:\\Program Files\\SASHome94\\SASVersionedJarRepository\\eclipse\\plugins\\sas.rutil.nls_904300.0.0.20150204190000_v940m3\\sas.rutil.nls.jar"
cpW += ";C:\\Program Files\\SASHome94\\SASVersionedJarRepository\\eclipse\\plugins\\sastpj.rutil_6.1.0.0_SAS_20121211183517\\sastpj.rutil.jar"

# Windows client and Windows IOM server
winiomwin = {'java': 'C:\\ProgramData\\Oracle\\java\\javapath\\java.exe',
             'iomhost': 'xx.xxx.xx.xx',
             'iomport': 8591,
             'authkey': 'xxx',
             'encoding': 'windows-1252',
             'classpath': cpW,
             'appserver' : 'xxx'
             }

 

In addition, I have placed the _authinfo file in my home folder and have updated all classpath variables. This connection works technically and I can start my session.

 

For example, I start a SAS session like this:

 

import odksas
from odksas import output
from odksas.constants import CONSTANTS, SYNTAX

# Start session
sas = odksas.create_sas_session_object()

# Execute code
code = sas.submit(SYNTAX.get('test_1'))
output.get_sas_output(code)
output.get_sas_output(sas.datasets('yyy'))

test = sas.sasdata('data_file_name', 'yyy')
output.get_sas_output(test.describe())
output.get_sas_output(test.head(100))

# SAS model object
cars = sas.sasdata('cars', 'sashelp')
output.get_sas_output(cars.bar('EngineSize'))

stat = sas.sasstat()
my_dict = {'model': 'horsepower = cylinders enginesize', 'by': 'type', 'data': cars.sort('type')}
model = stat.reg(**my_dict)
output.get_sas_output(model)

 

This code executes without error.

 

Now here is my question:

In DI Studio I can access data that I am not able to access through the SASPy session. How is this possible? I would like to access the same data via the SASPy session.

 

For example, when I "check out" a job with at least one source table and run;

 

libname _ALL_ list;

 

I can access the following libref (log):

 

NOTE: Libref=   xxx
      Scope=    IOM ROOT COMP ENV
      Engine=   BASE
      Physical Name= x:\xxxx\xxxx\xxx\xxx\Data
      Filename= x:\xxxx\xxxx\xxx\xxx\Data

 

However, I cannot access the same libref when I run the same statement (libname _ALL_ list) from the SASPy session. Also when I try to run the libname assignment that works in DI Studio, I get this error:

 

/* Access the data for xxx  */
LIBNAME xxx BASE "x:\xxxx\xxxx\xxx\xxx\Data";
NOTE: Library xxx does not exist.

 

I think there is something wrong with my connection, can someone figure it out? I have read the guides and troubleshooting section on the package webpage without finding answers.


Accepted Solutions
Solution
‎07-26-2017 12:28 PM
New Contributor
Posts: 3

Re: SASPy: Cannot Access SAS Libraries That Are Available in DI Studio

[ Edited ]

I had to add the full path to the data file directory in the libref assignment, including iomserver and parent directories. Here is an example:

 

/* Assign libref from SASPy session */
LIBNAME mylib BASE "!SAS_REP\xxxx\xxxx\xxx\xxx\Data";

 

!SAS_REP is a user-defined environment variable on the Windows client machine, for example: "\\sas-app-x-xx\Data". Remember to add the environment variable to the client machine.

 

However, it is not necessary to use the environment variable. This works as well:

 

/* Assign libref from SASPy session */
LIBNAME mylib BASE "\\sas-app-x-xx\Data\xxxx\xxxx\xxx\xxx\Data"; 

View solution in original post


All Replies
Solution
‎07-26-2017 12:28 PM
New Contributor
Posts: 3

Re: SASPy: Cannot Access SAS Libraries That Are Available in DI Studio

[ Edited ]

I had to add the full path to the data file directory in the libref assignment, including iomserver and parent directories. Here is an example:

 

/* Assign libref from SASPy session */
LIBNAME mylib BASE "!SAS_REP\xxxx\xxxx\xxx\xxx\Data";

 

!SAS_REP is a user-defined environment variable on the Windows client machine, for example: "\\sas-app-x-xx\Data". Remember to add the environment variable to the client machine.

 

However, it is not necessary to use the environment variable. This works as well:

 

/* Assign libref from SASPy session */
LIBNAME mylib BASE "\\sas-app-x-xx\Data\xxxx\xxxx\xxx\xxx\Data"; 
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 606 views
  • 1 like
  • 1 in conversation