Giter VIP home page Giter VIP logo

saspy's Introduction

224493-SASPy-logo-OL-01

Overview

This package provides interfaces between Python and SAS. This package enables a Python developer to create mixed Python/SAS workflows to leverage the powers of both SAS and Python, by connecting a Python process to any of a variety of SAS deployments, where it will run SAS code. The SAS code is generated by the SASPy object and methods or explicitly user written. Results from SAS are returned as text, HTML5 documents (via SAS ODS), or as Pandas Data Frames. This package supports running analytics and returning the resulting graphics and result data to the Python process. It can convert data representations between SAS Data Sets and Pandas Data Frames.

This package has multiple access methods which allow it to connect to local or remote Linux SAS, IOM SAS on Windows, Linux (Including Grid Manager), or MVS, and local PC SAS. It can run within various Notebooks platforms, or IDE's/UI's or in interactive line mode Python or in Python batch scripts.

It is expected that the user community can, and will, contribute enhancements.

Badges

OpenSSF Best Practices

Prerequisites

  • Python3.x or above
  • SAS 9.4 or above
  • SAS Viya 3 or above

Connecting offering

  • Linux SAS: local or remote, including Grid Manager
  • Windows SAS: local or remote
  • MVS SAS: remote
  • Jupyter, Databricks and/or Zeppelin Notebooks
  • Interactive Line mode, Python IDE's or other UI's
  • Batch Python scripts

Installation

This package can be installed via pip or Conda. This will pull down the latest PyPI package and install it.

pip install saspy

However, if that's too easy, you can also download a specific release from SASpy project releases page, or just clone the repo and and instll from that. To install a given release, use the following, where the X.X.X is the release version you want.

pip install https://github.com/sassoftware/saspy/archive/vX.X.X.tar.gz

Getting Started

All of the doc, including install and configuration information can be found at sassoftware.github.io/saspy.

Also, example Notebooks and use cases can be found at sassoftware/saspy-examples.

Contributing

The Contributing file explains the rules and conventions to follow while Contributing to this project. It also contains the Contributor Agreement instructions.

Licensing

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at LICENSE.txt

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Additional Resources

saspy's People

Contributors

ageorgou avatar alexiajm avatar andersonh-uta avatar andyjessen avatar bagerard avatar brokenstreetlight avatar chrislockard21 avatar collinux avatar criptic avatar damjankrstajic avatar dmsenter89 avatar friedegg avatar gcamargo1 avatar glm26 avatar hahewlet avatar hhubbell avatar holdeneoneal avatar iagomez avatar jasonphillips avatar jld23 avatar kjnh10 avatar metllord avatar moshekaplan avatar paulincharliquart avatar pgranat avatar rayewright avatar sabisw avatar shuguangsun avatar sleemanmunk avatar tomweber-sas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

saspy's Issues

SASutil.hpimpute doesn't recognize the "impute" parameter.

sas.teach_me_SAS(True)
util.hpimpute(data=cars, input='input', impute='impute', performance='performance', id='id', freq='freq', code='code')

%macro proccall(d);
proc hpimpute data=WORK.cars ;
code file='code';
freq freq;
id id;
input input;
performance performance;
run; quit; %mend;
%mangobj(hpi0011,hpimpute,cars);

sasdata2dataframe() very slow to return data

Hi,
this could be related to changes made to sasioiom.py as a result of issue #37, I'm not sure.

This code is being run on the server:

data _null_; 
set engnr_cl.spc_results(where=(pointDate >= "15may2017 00:00"dt) );
file _tomods1 termstr=NL; 

put 'chartID'n '02'x 'plotNum'n best32. '02'x 'plotType'n '02'x 'variableName'n '02'x 'pointDate'n E8601DT26.6 '02'x 'pointValue'n best32. '02'x 'pointOOS'n best32. '02'x 'pointLowerCL'n best32. '02'x 'pointCentralCL'n best32. '02'x 'pointUpperCL'n best32. '02'x 'pointLowerSL'n best32. '02'x 'pointTargetSL'n best32. '02'x 'pointUpperSL'n best32. '02'x 'lotId'n '02'x 'dcop'n '02'x 'eqpId'n '02'x 'processEquip'n '02'x 'partname'n '02'x 'stage'n '02'x 'process'n '02'x 'recipe'n '02'x 'plotSpec'n '02'x 'plotSpecName'n '01'x;

run;

When it runs it returns 144,000 rows (23 columns) approximately but it takes around 6 minutes to get the data back.

When I run almost the same query via Enterprise Guide it takes a few seconds to return the data, but in that case _tomods1 was pointing to a file on disk. Using proc sql on EG also takes a few seconds. If I try this it works just as fast:

c = s.submit("""proc sql;create table work.test as select * from engnr_cl.spc_results where pointdate >= "01may2017 00:00"dt;quit;""")

It doesn't appear to be a problem with the creation of the dataframe, that happens very quickly, it looks like it might be how the data is received in the submit() method, but I'm not sure.

Should it be taking this long to retrieve the data?

Thanks.

Unable to Make Local Connection on Windows

I get the following error:

The application could not find a command to launch a SAS Workspace Server.
SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program java with the following parameters:['java', '-classpath', 'C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94360__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94360__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94360__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94360__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\user_name\AppData\Local\Continuum\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar;C:\Program Files\SASHOME\SASFoundation\9.4\core\sasext', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '64602', '-stdoutport', '64603', '-stderrport', '64604', '-zero', '']

Be sure the path to sspiauth.dll is in your System PATH

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

I've tried adding the path to sspiauth.dll to both my System path variable and the classpath as can be seen above.

out=kwargs as dictionary for sas.sasstat

I want to generate the following syntax using saspy 2.7.1

Proc reg data=sashelp.cars;
Model horsepower = MSRP cylinders;
output out=residual
residual=r_HP;

I am not able to get the output=out option working. See Below:

image

saspy gets fnctl error if pandas is not installed

This issue showed up in sas_kernel (Jupyter and SAS Grid #27). Posting here for tracking.

import saspy

sas = saspy.SASsession(cfgname='iomlinux')
Please enter the IOM user id: pruddle
Traceback (most recent call last):
File "", line 1, in
File "/home//anaconda3/envs/saspy/lib/python3.6/site-packages/saspy/sasbase.py", line 236, in init
self._io = sasioiom.SASsessionIOM(sascfgname=self.sascfg.name, sb=self, **kwargs)
File "/home//anaconda3/envs/saspy/lib/python3.6/site-packages/saspy/sasioiom.py", line 161, in init
self._startsas()
File "/home//anaconda3/envs/saspy/lib/python3.6/site-packages/saspy/sasioiom.py", line 310, in _startsas
fcntl.fcntl(self.stdout, fcntl.F_SETFL, os.O_NONBLOCK)
NameError: name 'fcntl' is not defined

Can't connect

Hello.

I'm really excited about trying out saspy. I'm using a local instance of SAS 9.4 on Windows 10 running in Parallels on a Mac.

Unfortunately, I'm not able to connect. I keep getting this error:
screen shot 2017-10-16 at 10 00 31 pm

As you can see here, I added the required file paths to sascfg.py:
screen shot 2017-10-16 at 10 00 54 pm

I checked, and all the files are in the locations indicated by the file paths.

Finally, I made sure to add "C:\Program Files\SASHome\SASFoundation\9.4\core\sasext" to the system PATH environment variable.

Any suggestions for what I should try next?

Thank you!

pygments dependency not respected in virtualenv

I don't understand the problem here, but saspy won't install in a fresh virtualenv because the pygments package is missing. Despite it being listed in the install_requirements in the setup.py, it does not trigger a dependency installation. In python 3.5 on ubuntu 14.04, pip install saspy fails with:

Collecting saspy
  Using cached saspy-2.1.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-k1_nkvcf/saspy/setup.py", line 24, in <module>
        from saspy import __version__
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/__init__.py", line 16, in <module>
        from saspy.sasbase     import *
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/sasbase.py", line 61, in <module>
        from saspy.sasstat import *
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/sasstat.py", line 17, in <module>
        from saspy.sasproccommons import SASProcCommons
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/sasproccommons.py", line 18, in <module>
        from saspy.sasresults import SASresults
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/sasresults.py", line 17, in <module>
        from saspy.SASLogLexer import SASLogStyle, SASLogLexer
      File "/tmp/pip-build-k1_nkvcf/saspy/saspy/SASLogLexer.py", line 16, in <module>
        from pygments.lexer import RegexLexer
    ImportError: No module named 'pygments'

The problem is fully resolved by installing pygments first via pip and then installing saspy.

Response from remote SAS not working for pure python code - SOCK_NONBLOCK

I have sascfg configured and working in both Notebook standalone as well as Hub. I am using the "ssh" method of connection after setting up passwordless keys etc. Everything works great in "SAS" notebooks via sas_kernel but I am trying pure python notebooks/code and there is no response back.

import saspy
import pandas as pd
sas = saspy.SASsession(cfgname='ssh')
#dir(sas)
stat = sas.sasstat()
#dir(stat)
cars = sas.sasdata("CARS","SASHELP")
#dir(cars)
cars.describe()

Immediately in the output window I see (ID of course changes if Python kernel is restarted)
Using SAS Config named: ssh SAS Connection established. Subprocess id is 21311

After a while I have to keyboard interrupt and the error stack is the following everytime.

`~/.pyenv/versions/3.6.3/lib/python3.6/socket.py in accept(self)
    203         For IP sockets, the address info is a pair (hostaddr, port).
    204         """
--> 205         fd, addr = self._accept()
    206         # If our type has the SOCK_NONBLOCK flag, we shouldn't pass it onto the
    207         # new socket. We do not currently allow passing SOCK_NONBLOCK to`

Is there some os level property that needs to be set?

Idea: Allow custom sascfg.py location

Hi,

As far as I can tell it's not possible to override the location of where the config-file to look in when establishing the initial SAS-connection (if I'm mistaking, please let me know how - I've been unable to find it in the docs), which makes it harder to versionize and deploy saspy across different enviroments, since one usually wouldn't track changes in the module folder but only the code base.

One could just put in all the parameters when constructing the connection, but it seems messy compared to maintaining a config-file. Alternatively one could store the config-file in the version-control system and override the package supplyed config on each pull but that again seems cumbersome compared to just pointing to the config-file in the code.

I'm not confident enough with my Python skills to do a pull-request myself, but I'd love to help out in any way I can.

sasPY vs AIX

Hi,
tried to run sasPY on AIX machine for testing purposes. Received error
about lack of attribute forkpty. Which is basically true, as header defining this function (pty.h) is not present in AIX according to gnuLib documentation. https://www.gnu.org/software/gnulib/manual/html_node/pty_002eh.html

I wonder whether someone ever had an idea of rewriting somehow parts of code using forkpty to achieve same functionality . (maybe other solution?)

It can be a way to have more "other UNIX" friendly solution, as problem may be visible also in HP-UX, Solaris and so far it's the only issue I've noticed with non-Linux Unix systems and sasPY.

bash-4.2$ python3
Python 3.6.1 (default, Jun 24 2017, 19:47:36)
[GCC 4.9.2] on aix6
Type "help", "copyright", "credits" or "license" for more information.
>>> import saspy
>>> sas = saspy.SASsession(cfgname='default')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...] /lib/python3.6/site-packages/saspy/sasbase.py", line 232, in __init__
    self._io = sasiostdio.SASsessionSTDIO(sascfgname=self.sascfg.name, sb=self, **kwargs)
  File "[...]/lib/python3.6/site-packages/saspy/sasiostdio.py", line 163, in __init__
    self._startsas()
  File "[...]/lib/python3.6/site-packages/saspy/sasiostdio.py", line 227, in _startsas
    pidpty = os.forkpty()
AttributeError: module 'os' has no attribute 'forkpty'
>>>

Pawel

Unexpected datatype mappings with sas.sasdata2dataframe method

capture

Regardless of the SAS formatting, e.g. character, numeric and date, the the datatypes for sas.sasdata2dataframe method returns an object.

capture

Of course, one can map the object datatypes to different datatypes as shown. Are there plans to go beyond the object datatype as the default? SAS dates could be mapped to datetime64, etc.

Running saspy off local machine

I have installed saspy on one of our sas grid servers and this is able to run python queries.

I have now tried to install this on my own PC but I am getting the following Java error:

Please enter the IOM user id: fortis-uk\Daviespau
Java Error:
java.lang.NoClassDefFoundError: com/sas/services/connection/ConnectionFactoryException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sas.services.connection.ConnectionFactoryException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main"

Subprocess failed to start. Double check you settings in sascfg.py file.

Attempted to run program C:\ProgramData\Oracle\Java\javapath\java.exe with the following parameters:['C:\ProgramData\Oracle\Java\javapath\java.exe', '-classpath', 'C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '53481', '-stdoutport', '53482', '-stderrport', '53483', '-appname', "'SASAppGrid - Workspace Server'", '-iomhost', 'finsasnode01.fortis-uk.fortis.com', '-iomport', '8591', '-user', 'fortis-uk\Daviespau', '']

If no Java Error above, try running the following command (where saspy is running) manually to see if it's a problem starting Java:
C:\ProgramData\Oracle\Java\javapath\java.exe -classpath "C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94260__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 53481 -stdoutport 53482 -stderrport 53483 -appname 'SASAppGrid - Workspace Server' -iomhost finsasnode01.fortis-uk.fortis.com -iomport 8591 -user fortis-uk\Daviespau

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

Can you please assist.

to_df String Trailing Space

I'm getting trailing spaces when using the to_df method with strings.

Below is an example:


import saspy
sas = saspy.SASsession(cfgname="winlocal")
sas.set_batch(True)
generate_data = sas.submit('DATA test; var = "no_space"; RUN;')
# print(generate_data["LOG"])
sas_dataset = sas.sasdata('test')
sas_df = sas_dataset.to_df()
print(repr(sas_df["var"][0]))
'no_space '

Using sas_clients queue when connecting to SAS Grid

Hello saspy team,

Context:
We are using saspy and sas_kernel to connect to a SAS Grid. I was able to follow the setup instructions - thank you for making it so straight forward! - and now I can connect and submit code to the grid.

When I check the grid jobs, I noticed the LSF job started through saspy is running in the normal queue instead of the sas_clients queue. I think the wrinkle here is that the SASApp Workspace is setup to use the SASApp Grid Server to launch the LSF jobs. Currently there is NO default queue setup there and the queue the SAS clients get is based on an "option set". The option sets available are:

image

Since none of those are Jupyter, we are getting the default queue for the SASApp server context which is currently the "normal" queue.

Question:
Is there any way to specify the Grid Option Set in the sascfg.py configuration to pass through to the IOM server and on down to LSF. If not it would seem that the only way to force that to happen would be to create an app server context for Jupyter and force it to have a default queue of sas_clients. I'm assuming that would work, but we would have to test and ideally would want to avoid that configuration overhead if possible.

Thanks!

Can not establish a connection at another folder

Hello,

I am able to import saspy and establish connection using the example from the GitHub page (saspy_example_github)

image

but when I run the script from another directory I got the following:
image

Can you explain me why this happens?

Allow passing arguments to pd.read_csv when using to_df_CSV

I have encountered issues related to both the type detection and the encoding detection when I use to_df_CSV.

I thought that I could fix this by specifying these in the arguments (in the hope that kwargs would be passed on to read_csv).
This apparently does not happen, I have also verified that in the code.

If you think this is a valuable addition I can make a PR to add this.

Working with Python Unicode and SAS Session WLATIN1

I am using SASPy with Python 3.6 to connect to a SAS session with default encoding set to WLATIN1. Some string values include local characters like "ø", "æ", etc. Thus, for example, when I use the methods submit or sasdata2dataframe these characters are not converted correctly from Python code to SAS code and visa versa.

To fix this, I try:
sas.submit(CODE.encode('utf-8').decode('windows-1252'))

However, this does not fix the problem. In addition, all methods appear to "ignore" Unicode. How should I deal with this encoding problem?

Right now my only option is to write the SAS code to a temporary file that I submit via the %include statement. I also may need to export the SAS data file to CSV and then manually convert it to a pandas DataFrame. This is not optimal! Here is a link to the code that I am currently using: http://www.henriksejersen.com/saspy-tryout-session/

IOM connection to SAS fails with the following error:

None of the requested encryption algorithms are supported by both peers: AES
SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Fix:
Add the following entries to your sascfg.py file. They point to the jar files that contain the client side encryption support:
cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil_904400.1.0.20160824190000_v940m4\sas.rutil.nls.jar"

cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil_904400.1.0.20160824190000_v940m4\sas.rutil.jar"

cpW += ";C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sastpj.rutil_6.1.0.0_SAS_20121211183517\sastpj.rutil.jar"

Where clause not working

Hi,

I am trying to use sasdata2dataframe to query a sas table for some data.

I have added a dictionary with a 'where' clause but no matter what filter I put in, I still seem to get all 5000 observations back in the dataframe. For instance:

results = sas.sasdata2dataframe(table='wip_tbl', libref='fabvw_cl', dsopts={'where':'waferqty > 24'})

In this case the table is in the library "fabvw_cl", the table is called "wip_tbl" and I am looking for all rows where the "wafer quantity" (waferqty) is greater than 24.

I have also tried queries on text columns and datetime columns and they are not working for me either.

Has anyone else had similar problems?

Thanks.

Prompt in SAS magic cell

I read the saspy documentation on how to use SAS prompt. I am wondering if I can have prompt using SAS magic cell:
%% SAS sas ....

Initial composable PROC TABULATE implementation

(I'm dropping this in an issue for response rather working immediately towards a PR, because it might be more appropriate as an external add-on library rather than direct incorporation -- thoughts / reactions very welcome.)

I've finished an initial implementation of the PROC TABULATE procedure, opting for a highly composable syntax inspired somewhat by the query-abstraction tools of SQLAlchemy or pydal (to which I've also contributed a bit in the past). The reason for taking this approach is that our office (institutional research at a state university) very often produces deep-tabulated descriptive statistics, and is therefore a heavy user of the base TABULATE procedure on large datasets -- and while the macro language allows for some basic reuse of fragments and code, I've been looking to establish a higher level of abstraction and systematic composition of table structures.

The best overview I can give is this example notebook which shows off the current working syntax:
https://github.com/jasonphillips/saspy/blob/proc-tabulate/SAS%2BTabulate.ipynb

That branch also contains the working code. In short, I add a tabulate key to datasets which contains functions for generating class / var / statistic variables, and a table function which can then be passed a composition of those elements, generating the full table syntax from the elements and also generating the class / var statements by assembling all the classes and vars used.

Anyhow, I built it by working backwards from "what syntax would I most enjoy as a user?", and its logic is already very solid, although I still need to implement further TABULATE options beyond the essential class / var / table statements. I'm curious to hear reactions!

Windows: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 3-4: truncated \UXXXXXXXX escape

Got a message from someone not able to run local windows. The error was flagged in there sascfg.py on their classpath line. I've reproduced the error (which I hadn't seen before) and am documenting it here. I'll add it to the Troubleshooting doc next.
The problem is having a \u or \U (either way) in a string - like in the classpath in the sascfg.py file:

cpW += ";C:\Users\user\AppData\Roaming\Python\Python36\site-packages\saspy\java\saspyiom.jar"

The error is like in the title of this issue. The fix is to either code \u or \U anywhere you happen to have \u in you strings, or prefix the string with an 'r' (for raw string - don't transcode) as follows (either of these will work):

cpW += ";C:\Users\user\AppData\Roaming\Python\Python36\site-packages\saspy\java\saspyiom.jar"
cpW += r";C:\Users\user\AppData\Roaming\Python\Python36\site-packages\saspy\java\saspyiom.jar"

saspy hangs after creating a SASsession

I am trying to use saspy in our environment, which is a SAS grid.
I have made changes to the config file in _personal.

I then try to use it with the following code:

import saspy
sas = saspy.SASsession(cfgname='iomwin')

The process then hangs. If I interrupt it, it seems to be working on self.sockin.accept()

When I change the path to not contain any jar files it fails with a Java error.
So it seems that it is able to find the jar files and the java environment.

Any help is greatly appreciated.

Missing or misaligned table data

Hi,

I am doing a query on a sas table:

tbl = 'SCRAP'
libref = 'engnr_cl'
where = 'scrap_time >= '"01may2017 00:00"dt'

tempDf = s.sd2df(table=tbl, libref=libref, dsopts={'where': where})

and every row of the SCRAP_TIME column should contain a datetime, however for some reason saspy or pandas is not treating this column as a datetime column - it is treating it as an "object". It's doing the same thing for some other datetime columns also.

When I look at the same time period in Enterprise Guide I can see datetimes in every row.

Here's an excerpt from the log (I cut out some columns as there are a lot of them):

data _null_; 
set engnr_cl.scrap(where=(scrap_time >= "01may2017 00:00"dt) );
file _tomods1; 
put 'AREA'n '09'x 
'LOTID'n '09'x 
'STEP_START_TIME'n E8601DT26.6 '09'x 
'SCRAP_TIME'n E8601DT26.6 '09'x
'STEP_END_TIME'n E8601DT26.6 '09'x 
'Comments'n '09'x
'LOT_TYPE'n '09'x 
'WEEK_NO'n '09'x 
'root_cause_location'n '09'x 
'Elec_Cause'n ;
run;

The log says 59 records were read.

I have tried filling the NaN values in the SCRAP_TIME column with NaT, but it still thinks there are blank strings in some of the cells.

The Comments column contains text and each cell can contain multiple lines of text, probably separated by newline characters (but I'm not sure about that).

I tried the query below with and without the Comments column and it seemed to be okay without it, but the rows looked misaligned with the Comments column included.

s.sd2df('SCRAP', 'ENGNR_CL', {'keep':'LOTID AREA SCRAP_TIME Comments', 'where':'SCRAP_TIME >= "01may2017 00:00"dt'})

image

In the screenshot below, the AREA column should only contain a single word per cell but instead seems to contain text that should have been in the Comments column.

Any idea how I can get around this?

Thanks.

How to share session between saspy and cell magics?

This library is enormously useful for cases when I want to write in Python but switch to SAS for certain heavy lifting segments -- but I'm running into one workflow issue when attempting to combine the object-based saspy methods with the cell magics approach.

My goal is to do something like this, in a series of cells in one notebook:

# start a session
import saspy
import pandas as pd
from IPython.display import HTML

sas = saspy.SASsession(cfgname='ssh')

Later, load something into the SAS session:

sas_dataset = sas.df2sd(something_in_pandas, 'mydata')

Now, instantiate cell magics so that I can submit SAS statements directly:

%load_ext saspy.sas_magic

Do something useful in SAS (hello world example here):

%%SAS

proc print data=WORK.mydata; run;

But the issue is that the cell magics extension, when loaded, creates a new SAS session on the other end, separate from the one created with the direct saspy.SASsession call, which means that my work library and other instantiated data are not available to me in any %SAS cells.

I can of course get around this by using the more explicit syntax:

c = sas.submit("""
  ... sas code here
""")
HTML(c['LST'])

But that isn't quite as elegant for a single notebook trading off tasks between python and SAS. Is there a way to force a shared session between both, or a reason to prevent that?

Ideally, an existing session could simply be passed through into the magics when loaded. This line is where the new session is created:

https://github.com/sassoftware/saspy/blob/master/saspy/sas_magic.py#L36

Although as far as I can tell from API docs, the load_ext call in iPython doesn't allow arguments, so I'm not sure how passing in an already instantiated SAS session would be done in this case.

Can't Establish IOM connection on Windows

I'm can't connect to local SAS kernal in Jupyter on windows. Very similar to this thread: https://github.com/sassoftware/saspy/issues/24. I'm running SAS 9.4 M4.

Here is the error code returned when I try to run a SAS session with 'winlocal'. From what I can tell I have all the saspy configs set correctly as it appears to be making the Java connection. I also have sspiauth.dll set correctly in my System Path environment variable. Not sure what else to try.

The application could not find a command to launch a SAS Workspace Server.
SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program java with the following parameters:['java', '-classpath', 'C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94482__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94482__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94482__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94482__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\rudolpj\AppData\Local\Continuum\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar;C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil_904400.1.0.20160824190000_v940m4\sas.rutil.jar;C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sas.rutil.nls_904400.0.0.20160427190000_v940m4\sas.rutil.nls.jar;C:\Program Files\SASHome\SASVersionedJarRepository\eclipse\plugins\sastpj.rutil_6.1.0.0_SAS_20121211183517\sastpj.rutil.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '50915', '-stdoutport', '50916', '-stderrport', '50917', '-zero', '']

Be sure the path to sspiauth.dll is in your System PATH

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

How to connect using sasPy and SAS running on a grid

Hi folks,

I am trying to test sasPy on the BAC SAS Grid. My SAS client is EG 7.1, using SAS 9.4 and server is a grid in Linux. I used SAS proc iomoperate to obtain the domain names for all of the servers part of our configuration. I edited sascfg.py specifically values for cpW (for the sas *.jar files), and winiomlinux (i.e. since I have a windows client with a Linux server) in order to be able to make a connection via saspy.SASsession(cfgname='winiomlinux'). For the iomhost/iomport I tried the Workspace server, the Pooled workspace server, the SAS Grid manager. Nothing worked. I always got the error message shown below. As you can see below I even tried the actual ip address as opposed to the domain name. That didn't work either. Can you please help?

Thank you.
Please enter the IOM user id: my_user_id
Please enter the password for IOM user : ········

Connection Reset: SAS process has terminated unexpectedly. Pid State= 1
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program C:\Program Files\Java\jre8\bin\java.exe with the following parameters:['C:\Program Files\Java\jre8\bin\java.exe', '-classpath', 'C:\Program Files\SAS94_712\SASDeploymentManager\9.4\products\deploywiz__94410__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SAS94_712\SASDeploymentManager\9.4\products\deploywiz__94410__prt__xx__sp0__1\deploywiz\deploywiz\log4j.jar;C:\Program Files\SAS94_712\SASDeploymentManager\9.4\products\deploywiz__94410__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SAS94_712\SASDeploymentManager\9.4\products\deploywiz__94410__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Anaconda_April2017\Lib\site-packages\saspy\java\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '60244', '-stdoutport', '60245', '-stderrport', '60246', '-iomhost', '158.171.228.72', '-iomport', '16881', '-user', 'my_user_id', '']

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

referencing a library in magic cell

I created a sas session as

sas_session1 = saspy.SASsession(cfgname='winlocal') sas_session1.saslib('Sprd', path="J:\Oea\OAM\Projects\ETF_Registration\Data")

and converted a pandas data frame to sas dataset using
UScategory_sas = sas_session1.df2sd(UScategory, libref='Sprd').

UScategory_sas.head() shows that I have converted the pandas dataframe successfully to sas dataset. But when I am trying to use the dataset in a magic cell, it does not work. I checked the

sas_session1.datasets(libref= 'Sprd')
and I was not able to locate the UScategory_sas dataset .
running a simple SAS code below shows "ERROR: Libref SPRD is not assigned."

%%SAS sas_session1 data UScategory_sas2; set Sprd.UScategory_sas; run;

submit command, however, works well but I would prefer to run the codes in a %%SAS magic cell.

results = sas_session1.submit("proc print data=Sprd.UScategory_2;run;") HTML(results['LST'])

I would appreciate if you could comment why magic cell has a different session although I use %%SAS sas_session1 .
Thanks

image

NoClassDefFoundError: com/sas/services/connection/ZeroConfigWorkspaceServer

Hi I am trying to connect from Windows Client to a Grid running on a Linux server. I read somewhere that the zeroConfig is a for conencting to a windows sas server? but I am going to linux server
I am not sure what in my configuration is having saspy think this is going to a windows SAS?

"Zero-configuration workspace server connections enable you to create a local workspace server without specifying any connection attributes. This feature is specific to Windows environments. "

Here is the command line debug with message.
C:\ProgramData\Anaconda3\Lib\site-packages>java -classpath "C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.svc.connection.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\log4j.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.security.sspi.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.core.jar" pyiom.saspy2j -host localhost -stdinport 57576 -stdoutport 57577 -stderrport 57578 -appname 'SASApp - Workspace Server' -iomhost server.test.com -iomport 8593 -user myid
Exception in thread "main" java.lang.NoClassDefFoundError: com/sas/services/connection/ZeroConfigWorkspaceServer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

SAS_config_names=['uscm_prod','uscm_nonprod']
SAS_config_options = {'lock_down': True}
SAS_output_options = {'output' : 'html5'}

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

cpW = "C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.svc.connection.jar"
cpW += ";C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar"
cpW += ";C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\log4j.jar"
cpW += ";C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.security.sspi.jar"
cpW += ";C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\sas.core.jar"

uscm_prod = {'java' : 'java',
'iomhost' : 'serverprod.test.com',
'iomport' : 8593,
'encoding' : 'latin1',
'classpath' : cpW
}

uscm_nonprod = {'java' : 'java',
'iomhost' : 'server.test.com',
'iomport' : 8593,
'encoding' : 'latin1',
'appserver' : 'SASApp - Workspace Server',
'classpath' : cpW
}

Connect to running SAS process

Hello,
I learn that the same Ipython kernel could be connected by two or more processes.
My question is, Is it possible to connect to a running SAS process such as SAS Display Manager or SAS EG using SASPy?
I mean working in SAS DM and Jupyter which running a same process at the same time.
Thanks.

Dependency on pre-commit

I don't see any real dependency on pre-commit and I was wondering it was possible to remove it as a dependency or at least to move it to an optional dev dependency?

Code corrupted

We had an internal Gerrit process that has unknowingly been syncing stale code to the saspy and sas_kernel repos on occasion, including last night. This means that the code in the repos is not currently up to date and is to be considered 'out of whack'. We have the history showing when this has happened and what commits were overwritten, so we will be able to get the code back 'in whack', though it will take a bit of time to do this and verify that everything is in good shape again.

If you've forked either of these since April 6th, there's the very likely case that the code is not what it should be.

We will update this issue as we resolve the code base.

Connecting to SAS session using saspy without prompting for the password

Hi Team,

Can we pass on the password from a program file instead of getting prompted while connecting to SAS Session using SASPY.

Right now I can think of the below 3 scenarios:
Scenario 1 : We maintain a password file at Jupyter Server owned only by Admins.
Scenario 2: Password Files located at home directory of respective users - /home/
Scenario 3: Reading the password file from local system after you submit the query from Jupyter.

If you would like to suggest any alternatives for these, that will be really helpful.

Regards,
Sudipta

No output without ODS (HTML or Pandas)

This is fantastically cool. I think I have found one issue in sasiostdio.py, but I am afraid I cannot track down the cause yet.

I have a test script that looks like this:

import saspy

sas = saspy.SASsession(cfgname='default')
sas.set_results('text')
sas.set_batch('True')

print(sas)

sas_code = """
data test_data;
  do x = 1 to 10;
    y = x * 2;
    output;
  end;
  run;
proc print data=test_data noobs uniform;
  var x y;
  run;
proc contents data=test_data;
  run;
"""

results_dict = sas.submit(sas_code)

for key in results_dict.keys():
    print(key)
    print(results_dict[key])

When I comment out the sas.set_results line then I get the expected results back in HTML format. This code will execute properly, and the LOG will indicate the proper number of observations had been printed, but the LST will be empty.

The SAS object looks like this:

Access Method         = STDIO
SAS Config name       = default
WORK Path             = /scratch/[directory on my server]/
SAS Version           = 9.04.01M0P06192013
Teach me SAS          = False
Batch                 = True
Results               = text
SAS Session Encoding  = LATIN1
Python Encoding value = LATIN1

I am running SAS on Linux:

NOTE: This session is executing on the Linux 3.10.0-514.2.2.el7.x86_64 (LIN X64) platform.

unexpected behavior with df2sd

I was playing with df2sd and nulls. Below is my test code.
The two strange behaviors are:

  • It seems like only the first row gets into work yet i don't see any errors. (maybe sf holds an error log that i am not viewing?) The cause is the \x00 in second line.
  • It gives me a second line (but not 3rd or 4th) if I replace the \x00 with "". It displayed a "b" for the blank which i found puzzling.

Thanks for all the great features. Love the library!

import pandas as pd
import numpy as np
import saspy
sas = saspy.SASsession(cfgname='winlocal')

df_ST = pd.DataFrame({ 'One': 1,
                       'Letter': 'a',
                       'more': pd.Series(['a', 'b', 'c', 'd'],),
                       'blanks': pd.Series(['happy','\x00', 'days', '\x00'])
                     })
from IPython.display import HTML
# move df_ST to work.test
sf = sas.df2sd(df=df_ST, table='test')
# proc report it
sas_ses = sas.submit("""
proc report data=work.test;
    title 'fun report';
run;
""")
HTML(sas_ses['LST'])

saspy.SASdata.to_df Method Slow

I've tested the to_df method to move data between SAS and Python and it seems extremely slow.

Below is from a notebook notebook which demonstrates the problem


import saspy
import pandas as pd
import time 
import tempfile
sas = saspy.SASsession(cfgname="winlocal")
sas.set_batch(True)

For example I created the following dataset with 1 million rows:

generate_data = sas.submit('DATA test; DO i = 1 TO 1000000; j = i; k = j; l = k; m = "test"; OUTPUT; END; RUN;')
# print(generate_data["LOG"])
sas_dataset = sas.sasdata('test')

I then move the data to Python using the to_df method:

start = time.time()
sas_df = sas_dataset.to_df()
end = time.time()
print(end - start)
859.6239538192749

For comparison I wrote the following function to export the data to CSV and then import the CSV using pandas:

def sas_to_df(sas_data_set):
    
    with tempfile.NamedTemporaryFile(delete=False) as temp_csv:
        temp_csv.close()
        sas_csv = sas_data_set.to_csv(temp_csv.name)
    
        df = pd.read_csv(temp_csv.name)
    
    return df
start = time.time()
csv_df = sas_to_df(sas_dataset)
end = time.time()
print(end - start)
2.186218738555908

problem with fcntl module

Hello,
I installed saspy and changed sascnfg path to sas location (c:...)
after running import saspy in Jupyter, I get the following error. my machine has a windows 7 (64) without admin right.
I would appreciate your comments.
Thanks


import saspy

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-b2c5b3b117a3> in <module>()
----> 1 import saspy

C:\Anaconda3\lib\site-packages\saspy\__init__.py in <module>()
     14 #  limitations under the License.
     15 #
---> 16 from saspy.sasbase import *
     17 from saspy.SASLogLexer import *


here is my sascfg.py changes I made:

default  = {'saspath': 'C:/Program Files/SASHome/SASFoundation/9.4/sas'
            }

ssh      = {'saspath': 'C:/Program Files/SASHome/SASFoundation/9.4/sas',
            'ssh'    : '/usr/bin/ssh',
            'host'   : 'tom64-2'
            }

Import issue

Hi, I've just started with saspy, I've pip installed on both windows 10 bash and windows 10 environment, and I get the same error when I test if I can import saspy in the python shell. This is the error I'm currently getting:

import saspy
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/saspy/init.py", line 16, in
from saspy.sasbase import *
File "/usr/local/lib/python2.7/dist-packages/saspy/sasbase.py", line 218
def init(self, **kwargs) -> 'SASsession':
^
SyntaxError: invalid syntax

I didn't have any issue with the pip install, do I need to set a path to SAS for the library? Any help is appreciated, thank you.

SASPY install

I am trying to install SASPY so our users can use Python on our SAS Grid environment. The problem I am having is following the import of SASPY when I run the command sas = saspy.SASsession() I get the following error:

AttributeError: module 'saspy has no attribute 'sassession'

I'm not sure where this is supposed to be set form the sascf file I'm using?

Trying to work with SASpy1.2 for Python 2.7.12 - ArcGIS 10.5

Hi,
Im trying to work with SASPy 1.2 with Python 2.7.12 that comes shipped with ESRI 10.5 ArcGIS however im facing issues that could be narrowed down to the SASBase.py file in the os.fork() method doesnt work for windows OS, please provide me with steps to get the SASPy working in Windows.

How to query Datasets registered in Manually created SAS Libraries

Hi Team,

My requirement is to access data from a specific SAS Library.

Example: hr = sas.sasdata('air', 'sashelp') This statement works fine as we are querying data from sashelp which is a library internally created with SAS.

I need to access data from a library say XYZ and table ABC. So if I use
hr1 = sas.sasdata('ABC', 'XYZ') this throws error as Table XYZ.ABC does not exist. But I can very well query the same from Enterprise Guide.

How do i replicate the SAS Query:

proc contents data=XYZ.ABC;
run;

Please let me know if any further information is required.

issue to connect in windows and IOM or spi

Hi,
when I'm Trying to connect with
sas = saspy.SASsession(cfgname='winiomwin')
I get this message
The application could not log on to the server "_real_hostname_with_port". The user ID "real_username" or the password is incorrect.

According to troubleshooting guide,
"2. Your credentials were specifed wrong, or you don’t have permission to connect."
How can i check if my user if authorized to connect to Workspace Server? with the same user I normally submit code with SAS Enterprise Guide (port 8561-Logical Metadata Server).

Because in SASEG I'm connected with IWA, I'tried also to set sspi =True in sascfg.py
"3. for Windows Local connection, you don’t have the path to the sspiauth.dll in yout System Path variable."
but I do not have any sspiauth.dll in my system (windows 7 enterprise)

Error when starting IOM Session

I'm trying to start an IOM session with jupyter, the error I get is:

Unable to parse the name value "applicationname=ConnectionService%20904400".

SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program java with the following parameters:['java', '-classpath', 'C:\\Program Files\\SAS PC File Server\\M4\\9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94470__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar;C:\\Program Files\\SAS PC File Server\\M4\\9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94470__prt__xx__sp0__1\\deploywiz\\log4j.jar;C:\\Program Files\\SAS PC File Server\\M4\\9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94470__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar;C:\\Program Files\\SAS PC File Server\\M4\\9.4\\SASDeploymentManager\\9.4\\products\\deploywiz__94470__prt__xx__sp0__1\\deploywiz\\sas.core.jar;C:\\Users\\PTHYAGO\\AppData\\Local\\Continuum\\Anaconda3\\Lib\\site-packages\\saspy\\java\\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '54329', '-stdoutport', '54330', '-stderrport', '54331', '-iomhost', 'sasprod', '-iomport', '8591', '-user', 'denoren', '']

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

When I run the same command on Windows power shell, I get:

java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at pyiom.saspy2j.main(saspy2j.java:119)
Exception in thread "main" java.lang.NullPointerException
        at pyiom.saspy2j.main(saspy2j.java:126)

Any idea how to solve this?

Cannot Install saspy on the Win10

Hello,
I have both SAS 9.4 TS1M2 and pyton 3.6 installed on my PC, and my OS is WIN10.
I follow the instructions in the Installation section of this website, that is
"WIN+R" --> cmd --> C:\Users\汪亚军>pip install
However, it generates the following note and error message, please help me figure out what's wrong,thanks a lot.


Collecting saspy
Using cached saspy-2.1.4.tar.gz
Exception:
Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\pip\compat_init_.py", line 73, in console_to_str
return s.decode(sys.stdout.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 17: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 634, in prepare_file
abstract_dist.prep_for_dist()
File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 439, in run_egg_info
command_desc='python setup.py egg_info')
File "c:\program files\python36\lib\site-packages\pip\utils_init
.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File "c:\program files\python36\lib\site-packages\pip\compat_init_.py", line 75, in console_to_str
return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 17: invalid continuation byte


SASdata.contents() uncovers an error

This sequence generates an error and points a finger at sasiostdio.py:sasdata2dataframe. I'm using 2.1.1.

import saspy
sasconn = saspy.SASsession() # this was with the 4th mtce release of SAS 9.4 
sasconn.read_csv('http://support.sas.com/documentation/onlinedoc/viya/exampledatasets/baseball.csv')
baseball_ds.contents()

dsopts={} fails on sasdata2dataframe when dataset is read with read_csv('http://...')

Really love the feature set you guys are building! Am experimenting with sas.read_csv.

When I call sasdata2dataframe with an existing SAS dataset from SASHELP with dsopts kwargs, no issue. When I call sasdata2dataframe with an existing SAS dataset created with a call to sas.read_csv, there is no issue. Its when the SAS dataset created with sas.read_csv has dsopts kwargs there is an error with sasdata2dataframe. Please see image below.

capture

Unable to hardcoded links as the data set when using sas.sasdata

It appears that the current version only allows for users to pull from pre-existing library's that have been created? Is there a way for users to be able to pull from a data set that does not have a library defined within the metadata? Similar to creating a libname statement in sas code.

For example:
test_lib = '/casd/mpmartin/selectABA/Retention/adhoctest/'
test4 = sas.sasdata('afrf_base_cmp',test_lib)

Gives this error:

Table /casd/mpmartin/selectABA/Retention/adhoctest/.afrf_base_cmp does not exist. This SASdata object will not be useful until the data set is created.

Not sure if there is a work around for this but I did not see anything in the current docs around this issue.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.