We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Me and SASPy (SASPy working with HP-UX sever vs. Windows Client)

by Occasional Contributor EdwardJin ‎06-26-2017 01:06 AM - edited ‎07-19-2017 01:11 AM (685 Views)

This article is to address how to setup SASPy on Windows client to connect to SAS servers installed on UNIX. And, my goal is to utilize the new interface SASPy to facilitate SAS environment adminitration remotely via python. 


Before we start, I would like to say that it is a good move to have a interface with python, which is like opening a door to another world. And, it reminds me a picture I saw "Windows Loves Linux", so I draw a similar one just for fun :-)



In the comming paragraphs, I will introduce the story between me and SASPy (how to setup): 

  • Install SASPy and dependencies
  • Configure SASPy on Windows client
  • Examples
  • My wish (compatible to python 2.7)

Before installation, you may find a lot of useful information about SASpy from here

To install SASpy, I installed python 3.6.1 first, and then run the following commands under the command line of my Windows PC, 


# pip install pygments
# pip install saspy
# pip install pandas

To install Python, please refer to link

Next, I need to install SAS Integration Technologies Client, which is used to connect to SAS servers via IOM. You can find it over here, in case of need.  

Jupyter Notebook has also been installed to show the examples, you can find the howtos at here


After installation, it is time to configure SASpy to connect to SAS servers, which is the key point of this article. 

How to locate SASpy configuration file sascfg.py: 


>> import saspy
>> saspy.SAScfg

About how to update it, you need to define a configure name first: 



SAS_config_names = ['winiomhpux']

Then, build out a local classpath variable to use below for Windows clients: 

cpW = "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94140__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94140__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94140__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94140__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Python36-32\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

In fact, the jar files can be found under the installation of SAS Integration Technologies Client. 



And, the following configuration definitions are for connecting over IOM: 


winiomhpux  = {'java'   : 'C:\\Program Files\\SASHome\\SASPrivateJavaRuntimeEnvironment\\9.4\\jre\\bin\\java',
            'iomhost'   : '<server name>',
            'iomport'   : <port # of workspace server>,
            'encoding'  : '<SAS session encoding>',
            'classpath' : cpW,
	    'omruser'   : '<username>',
	    'omrpw'     : '<password>'

Please note that the user name have to have the relevant permissions to run the examples, e.g. SAS Metadata Server. 

So far, you have finished all the configuration. 


Now, it's the show time!


Here are some examples to demostrate how it works with python code. 

To access sashelp at SAS servers: Access to sashelp


To list active users on SAS servers: 

List active users

Both the 2 examples are running on Windows client. And, you can also put the code input into a file to run it in batch mode. 

It is pretty exciting, right?


Finally, it is one of my wish -- I hope SASpy can support python 2.7 for SAS 9.4.

Because my SAS server is SAS 9.4M2, so only python 3+ is supported. And, I can only install python 2.7 on HP-UX somehow. 

Generally, I like this function very much. Thanks to the innovation of SAS, it makes that is possible for me to port my python code to work with SAS. 


That is it. Hope the story between me and SASpy can give you some inspiration somehow. 


by SAS Employee Jared
on ‎06-27-2017 04:20 PM - last edited on ‎06-27-2017 05:42 PM by Community Manager

-- Edward,

Thank you for your write up on SASPy and and SAS 9.4+. I saw your wish to have the package supported on python 2.7. I think you can accomplish what you're after (to have a Jupyter notebook server running from your HPUX server) if you install Python3. It looks like ActiveState has a port here. You might also check Anaconda but I didn't see a port for HPUX explicitly listed.


Python 2.7 support is something we're evaluating but many of the extensions for Juypter are only supported on Python 3 and so I think moving to Python 3 is the better long term move.


Your example is great. For those looking for more background the documentation for the package is here: https://sassoftware.github.io/saspy/


by Occasional Contributor EdwardJin
on ‎06-28-2017 01:51 AM

Hi Jared, 


Thanks for your suggestion and the link about python 3. 


BTW, may I ask if SASpy has any functions or interface to handle daily operation tasks?  

Thanks in advance. 




by SAS Employee Jared
on ‎06-28-2017 04:01 PM


Can you give an example of what you mean by "daily operation tasks"? 




by Occasional Contributor EdwardJin
on ‎06-29-2017 05:59 AM



They can be some interfaces/functions like what "proc iomoperate" does, e.g. user administration / monitoring / auditing / performance. Maybe, it is ice on the cake. ;-)




by SAS Employee Jared
on ‎07-01-2017 05:39 PM


I don't think we have any of those at the momemnt but if you enter an issue on the GitHub repo (https://github.com/sassoftware/saspy/issues) for what you're looking for one of hte maintainers or community members can help you get it created.




Your turn
Sign In!

Want to write an article? Sign in with your profile.

Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.