BookmarkSubscribeRSS Feed
Jared
SAS Employee

The shipped version of the sascfg.py includes configuration details for the various connection methods for saspy. These are guidelines and likely your environment will require some modifications.

The latest version of the file can be viewed on GitHub

The documentation has configuration section that walks through the options step by step. If you have feedback or enhancements I welcome your input.

 

Here are a few common items to check (line 35)

  • SAS_config_names=['default']
    this line is a python list of the available configuration names. If there is only one configuration name then saspy will use that, if there are multiple and not explicitly specified the user will be prompted. A winlocal reference configuration is included in the file, to use it change the above line to this and saspy will automatically attempt to connect to your local PC SAS version. winlocal is just a name that represents a python dictionary 
    SAS_config_names=['winlocal']

 or if you're connecting to multiple SAS servers then you might want to have something like this:

 

SAS_config_names=['winlocal', 'zos', 'viya']

 

  • To connect using IOM, you will need to have java installed where python (or Jupyter) will be run and several SAS jars that came with your deployment. On PC SAS, that will just be a matter of finding the location on your system (line 145 shows a default path for 9.4m3 install yours will likely be different). If you're connecting to a remote server via IOM then you'll need to copy the jars from one system to another.

 

  • lock_down. This prevents users from overriding configuration options. For PC SAS this won't really matter, but for a server installation I would set it to True (the default). Here is the inline documentation beginning at line 26
# Based upon the lock_down configuration option below, you may or may not be able to override option
# that are defined already. Any necessary option (like user, pw for IOM or HTTP) that are not defined will be 
# prompted for at run time. To dissallow overrides of as OPTION, when you don't have a value, simply
# specify options=''. This way it's specified so it can't be overridden, even though you don't have any
# specific value you want applied.

 

 Jared

mmyrto
Quartz | Level 8

only trying to connect to local pc sas version...

 

ccaulkins9
Pyrite | Level 9
@mmyrto, be careful if this is using JBoss, Red Hat Linux and other Unix apps, there may be mention of fprint.d in the SasConfig file -
delete that as it will cause SAS Grid architecture to
e-SAS regards,

mich1
Obsidian | Level 7

Robot wink

These comments are for other SAS Programmers who want to run saspy in Anaconda3 in Windows 10 using a local BASE SAS installation. I found the existing documentation and posts confusing, but I think I've managed to navigate it in the end...

 

Download Anaconda and install using the recommended option

Note...Your computer may have mutiple versions of Python installed and configured various ways.The Anaconda distribution takes care of most of the setup problems by installing all this within an App

Verify the following:
(base) C:\Users\YOURWINDOWSNAME>python --version
Python 3.6.3 :: Anaconda custom (64-bit)

From the Anaconda DOS prompt (It's an app in your Anaconda3 folder): (base) C:\> pip install saspy
That'll install the saspy package. If you want the SAS kernel too, type pip install sas_kernel. Then you will be able to use the SAS kernel in Jupyter (i.e. write SAS code from a Jupyter notebook - cool eh?)

 

Now that the saspy package is installed, you have to add the directory that contains the file sspiauth.dll to our Path variable. This file is located at ~\SASHome\SASFoundation\9.4\core\sasext

Update your Path in Windows 10...You need to have Admin rights
In Windows 10 > From the Power User Task Menu > click System > Advanced Settings > Environment Variables > Edit a variable labelled "Path". There are already several folders in a list displayed - Add ~\SASHome\SASFoundation\9.4\core\sasext to the list.

As a check, if you open the cmd line in DOS and type c:\>path you will see something like:

PATH=C:\Oracle\product\11.2.0\client_X64\bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;F:\SAS\SASHome\SASFoundation\9.4\ets\sasexe;F:\SAS\SASHome\Secure\ccme4;F:\SAS\SASHome\SASFoundation\9.4\core\sasext;C:\Users\YOURWINDOWSNAME\AppData\Local\Microsoft\WindowsApps;

Or, Open Base SAS and run the following to find the PATH – The results will be the same
data _null_;
x=sysget('PATH');
put x;
run;

Now you use IDLE to edit saspy.cfg - It's in C:\Users\YOURWINDOWSNAME\AppData\Local\Continuum\Anaconda3 (somewhere...).
You will need to go to ~\SAS\SASHome\SASDeploymentManager\9.4\products\~ and make updates according to the versions you see. Note that '\\' means '\' when you are setting paths in your Python editor

The saspy.cfg file looks like
…scroll down to the config names below and make some changes

SAS_config_names=['winlocal','winiomwin','winiomIWA']

…scroll down to the path files below

# build out a local classpath variable to use below for Windows clients
cpW = "F:\\SAS\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__NUMBER__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";F:\\SAS\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__NUMBER__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";F:\\SAS\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__NUMBER__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";F:\\SAS\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__NUMBER__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\ProgramData\\Anaconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

…cpW is aliased as winlocal (see below)

winlocal = {'java' : 'java',
'encoding' : 'windows-1252',
'classpath' : cpW
}

The following Python code will start a session: sas = saspy.SASsession(cfgname='winlocal')

You can test your installation using
import saspy
import saspy.sascfg
sas = saspy.SASsession(cfgname='winlocal')
cars = sas.sasdata("CARS","SASHELP")
cars.describe()

and you should see a SASHELP data set about cars.

 

 - Bread Crumbs and Circuses for all

Bread Crumbs and Circuses for All
mmyrto
Quartz | Level 8

I still get the java error

 

Java Error:
Error: Could not find or load main class pyiom.saspy2j

mich1
Obsidian | Level 7

I'm not sure...You may try to double-check all the edits, try another PC (if possible), or review the following info...

 

https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean/180939...

 

The link above suggests it's an issue with java finding the class. The post lists the following as possible reasons...

Reasons why Java cannot find the class

When you get the message "Could not find or load main class ...", that means that the first step has failed. The java command was not able to find the class. And indeed, the "..." in the message will be the fully qualified class name that java is looking for.

So why might it be unable to find the class?

Reason #1 - you made a mistake with the classname argument Reason #2 - the application's classpath is incorrectly specified Reason #2a - the wrong directory is on the classpath Reason #2b - the subdirectory path doesn't match the FQN Reason #2c - dependencies missing from the classpath Reason #3 - the class has been declared in the wrong package

 

If you have an active SAS license, you could also submit a ticket to help troubleshoot. If you have access to IT support in your org, they can probably review your edits and help with the class issue. If I come across a solution I'll post it here. - Good luck!

 

-Bread Crumbs and Circuses for all

Bread Crumbs and Circuses for All
Jared
SAS Employee

You should take a look at the issues that have been reported on SASPy in GitHub: https://github.com/sassoftware/saspy/issues

From the limited information Issue 24 (https://github.com/sassoftware/saspy/issues/24) or Issue 58 might give you some trouble shooting https://github.com/sassoftware/saspy/issues/58

 

If looking through the issues doesn't yield a solution please open a new issue.

 

Jared

ccaulkins9
Pyrite | Level 9
Did @Myrto open a new issue?
e-SAS regards,

llogomon23
Calcite | Level 5

I am not sure if this will be of help for you:

 

I was running into the same error that you are, and I saw the path to the "saspyiom.jar" file was wrong. Please double check the path to the "saspyiom.jar" file in your machine.

 

In fact, double check the paths in this variable are pointing out to the right files in your machine:

 

cpL = "/opt/sasinside/SASHome/SASDeploymentManager/9.4/products/deploywiz__94400__prt__xx__sp0__1/deploywiz/sas.svc.connection.jar"
cpL += ":/opt/sasinside/SASHome/SASDeploymentManager/9.4/products/deploywiz__94400__prt__xx__sp0__1/deploywiz/log4j.jar"
cpL += ":/opt/sasinside/SASHome/SASDeploymentManager/9.4/products/deploywiz__94400__prt__xx__sp0__1/deploywiz/sas.security.sspi.jar"
cpL += ":/opt/sasinside/SASHome/SASDeploymentManager/9.4/products/deploywiz__94400__prt__xx__sp0__1/deploywiz/sas.core.jar"
cpL += "PathYourMachine/saspyiom.jar"

mich1
Obsidian | Level 7

Hello,

   FYI - Here is a link to my paper: https://www.lexjansen.com/scsug/2018/McCarthy-How-to-configure-Python-and-SASPy.pdf . It describes the setup using BASE SAS on a PC. Note that it's also possible to connect Jupyter to a Linux server (but it's a little weirder). Use PyCharm or "Eric" IDLE to edit C:\Anaconda\Lib\site-packages\saspy\sascfg.py. The key lines of your sascfg.py file should look like look like those below. Remember you need to copy the jars to your PC and then define the path to the jars so that your PC and server can talk:

 

How to connect a PC to a Linux server - Here's what I did anyway

...

SAS_config_names = ['winiomlinux']

...

# build out a local classpath variable to use below for Windows clients
cpW = "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94504__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94504__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94504__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94504__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Anaconda\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

...

winiomlinux = {'java': 'java',
'iomhost': 'YOUR DNS HOSTNAME',
'iomport': 8591,
'encoding': 'latin1',
'classpath': cpW
}

Good Luck Robot Very Happy Enjoy Python - Wink, wink, nudge, nudge, know what I mean, know what I mean

 

 

Bread Crumbs and Circuses for All
Jared
SAS Employee

One update that might be helpful to people who find this thread is that the options for accessing configuration files (sascfg) have been increased. You can now use the cfgfile= parameter on the SASsession method to use any configuration file visible from where saspy is installed.

Here is the code:

sas = SASsession(cfgfile='/some/path/to/your/config/sascfg_personal.py')

The full documentation section is here:

https://sassoftware.github.io/saspy/install.html#sascfg-personal-py

 

ccaulkins9
Pyrite | Level 9
And as a reminder from another thread, fprint.d is for fingerprint reading but if it makes its way into your sas.config file, suffice it to say in the Unix world and with JBoss 5.1 and Red Hat Linux installed, it'll practically equate to the "Death Star" of SAS Platform!
e-SAS regards,

dli7617
Calcite | Level 5

I am using Windows with Anaconda. And I run into the following error: 

Java Error:
log4j:WARN No appenders could be found for logger (com.sas.services.connection).
log4j:WARN Please initialize the log4j system properly.
com.sas.services.connection.FatalConnectionFactoryException: The application could not find a command to launch a SAS Workspace Server.
	at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:240)
	at com.sas.services.connection.AggregationKernel.doGetConnection(AggregationKernel.java:242)
	at com.sas.services.connection.ConnectionFactoryKernel.getConnection(ConnectionFactoryKernel.java:325)
	at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:69)
	at com.sas.services.connection.ConnectionFactoryShell.getConnection(ConnectionFactoryShell.java:51)
	at pyiom.saspy2j.main(saspy2j.java:197)
Caused by: org.omg.CORBA.NO_IMPLEMENT: The application could not find a command to launch a SAS Workspace Server.  vmcid: 0x0  minor code: 0  completed: No
	at com.sas.iom.orb.brg.Engine.flowLaunchServer(Engine.java:2952)
	at com.sas.iom.orb.brg.Engine.flow(Engine.java:709)
	at com.sas.iom.orb.brg.Engine.initClient(Engine.java:674)
	at com.sas.iom.orb.brg.ORBImpl.uri_to_object(ORBImpl.java:114)
	at com.sas.services.connection.ClusterEnvelope.createObject(ClusterEnvelope.java:293)
	at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:78)
	... 5 more

We failed in getConnection
The application could not find a command to launch a SAS Workspace Server.
Subprocess failed to start. Double check your settings in sascfg_personal.py file.

Attempted to run program java with the following parameters:['java', '-classpath', 'C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\log4j.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.core.jar;C:\\Users\\dli7617\\AppData\\Local\\Continuum\\anaconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '64251', '-stdoutport', '64252', '-stderrport', '64253', '-zero', '-lrecl', '1048576', '']

If no Java Error above, try running the following command (where saspy is running) manually to see if it's a problem starting Java:
java -classpath "C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94498__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94498__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94498__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94498__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\dli7617\AppData\Local\Continuum\anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 64251 -stdoutport 64252 -stderrport 64253 -zero -lrecl 1048576  

No SAS process attached. SAS process has terminated unexpectedly.
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
c:\Users\dli7617\Desktop\Desktop\Python\sas\run-sas-in-python.py in 
----> 1 sas = saspy.SASsession(cfgname='winlocal')

~\AppData\Local\Continuum\anaconda3\lib\site-packages\saspy\sasbase.py in __init__(self, **kwargs)
    478 
    479         # validate encoding
--> 480         pyenc = sas_encoding_mapping[self.sascei]
    481         if pyenc is not None:
    482            if self._io.sascfg.encoding != '':

KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.'

My sascfg_personal.py is located in my saspy folder and it looks like this: 

# 'winlocal': running a LOCAL copy of SAS on Windows
SAS_config_names=['winlocal']
# 'lock_down' - True | False. False = Allow runtime overrides of SAS_Config values below
# 'verbose'   - True | False. True = Allow print statements for debug type messages
SAS_config_options = {'lock_down': False,
                      'verbose'  : True
                     }
# build out a local classpath variable to use below for Windows clients
cpW  =  "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94498__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Users\\dli7617\\AppData\\Local\\Continuum\\anaconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"

winlocal = {'java'      : 'C:\\Program Files\\SASHome\\SASPrivateJavaRuntimeEnvironment\\9.4\\jre\\bin\\java',
            'encoding'  : 'windows-1252',
            'classpath' : cpW
            }

I added sspiauth.dll to my environment variables. Just wondering what more should I add to make it work? 

Thanks. 

sastpw
SAS Employee

Hey, there error is:

The application could not find a command to launch a SAS Workspace Server.

Which can be found in the troubleshooting guide at number 4, here: https://sassoftware.github.io/saspy/troubleshooting.html#iom-specific-errors

 

See if you can resolve it based upon that. Let me know and I can help you further if you still have any issues!

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
  • 28 replies
  • 20818 views
  • 34 likes
  • 9 in conversation