Code Monkey home page Code Monkey logo

sas_kernel's Introduction

SAS Kernel for Jupyter

Publish Python Package

Overview

The SAS Kernel for Jupyter Notebooks is capable of running SAS programs from within the Jupyter interface. The SAS kernel allows a user to leverage all of the SAS products they have licensed.

After installing the SAS kernel, you can use a notebook and a SAS installation to write, document, and submit SAS programming statements. The Jupyter notebook interface allows sharing of results through JSON and the SAS kernel is no exception, you can share code and results in a static form through the Jupyter notebook.

Documentation

Here is the link to the current documentation https://sassoftware.github.io/sas_kernel/

Prerequisites

  • Python3 (this is now the default since Python2 went end of life in January 2020)
  • Jupyter version 4 or higher
  • SAS 9.4 or higher -- This includes SAS Viya. The SAS kernel is compatible with any version of SAS released since July 2013.
  • SASPy -- The SAS kernel has a dependency on SASPy. The package will be installed automatically but it must be configured to access your available SAS server. SASPy must be configured before the SAS kernel can work successfully.

Installation

This will install the SAS Kernel for jupyter as well as the Jupyter lab extensions (jupyterlab v3+ is required) to make you a more productive programmer within Jupyter. Here are details about the extensions.

pip install SAS-kernel['jlab_ext']

The common methods to install are

  1. pip -- PIP is the most common way to install the latest stable version of the code.

    pip install sas_kernel
  2. conda -- A conda package is also available if you prefer to use conda as your package manger

    conda install -c anaconda sas_kernel
  3. From source -- If you need to install from the source branch before a new version has been built and pushed you can install from source like this:

    pip install git+https://[email protected]/sassoftware/sas_kernel.git@main

    Note that the default branch is now main to match the GitHub convention. You can modify the about URL if you're installing from a fork or a non-default branch.

To verify that the sas_kernel is installed

jupyter kernelspec list

You should see output similar to code below:

Available kernels:
    python3    /home/sas/anaconda3/lib/python3.5/site-packages/ipykernel/resources
    sas        /home/sas/.local/share/jupyter/kernels/sas

NOTE: You will not be able to execute SAS code through Jupyter until you have configured SASPy.

Getting Started

Here is a basic example of programming with SAS and Jupyter Notebook: Getting Started

Improving Usability

For the Jupyter Lab extensions

There is a seperate repository where the extensions are developed and maintained. See that repo for details

For the Legacy Jupyter Notebook

There are a few NBExtensions that have been created to make working with Jupyter notebooks more productive. These are largely the result of pain points from my use of SAS Kernel for programming tasks. The extensions can be found here. The list includes:

  • SAS Log -- which show the SAS log for the last executed cell or the entire log since the last (re)start of the notebook
  • themes -- this allows you to change the color scheme for your code to match the traditional SAS color scheme

NOTE: These extensions are for Jupyter Notebook they are not compatable with Jupyter Lab. Jupyter Lab extensions are in development and will be released shortly.

Installing the SAS Extensions

Details for installing the extensions for SAS can be found here.

Jupyter Magics for the sas_kernel

There are magics that have been written specifically for the sas_kernel to get more details see the README.

NBGrader

nbgrader is a system for assigning and grading notebooks and extends jupyter. NBgrader is compatible with the SAS kernel. The work was merged in September 2020. It will be widely available with the next release of NBGrader (0.62), until then you can install from source.

FAQ

  • Is there a SAS Magic that I can access from a python kernel?

    Yes! There are actually several cell magics available from SAS. They are %%SAS, %%IML, and %%OPTMODEL. To load these magics in your notebook, execute the following command %load_ext saspy.sas_magic. You can check that the magics have are successfully activated by looking at the results of %lsmagic and looking in the cell magic section. If you use multiple SAS Cell magics in the same notebook they will share a SAS session (have the same WORK libname and MACROS). There is currently no sharing of SAS Sessions between different notebooks.

  • Do I need to buy SAS to use this kernel?

    The SAS Kernel is simply a gateway for Jupyter notebooks to talk to SAS, as such, if SAS is not installed this kernel won't be helpful. For information on purchasing SAS click here.

  • How does Jupyter communicate with SAS?

    Behind a Jupyter notebook is a python session, that python session submits code to SAS and receives responses through various pathways (depending on the SASPy configuration). Jupyter can communicate with any SAS host (Windows, Linux, Unix, MVS) that has been released since July 2013 to present.

  • How can I see my SAS log, I only see the listing output?

    SAS is different from many other programming languages in that it has two useful information streams, the log (which details the technical details of what happened and how long it took) and the lst (which includes the tables and graphics from the analysis). The SAS Kernel attempts to show you what I think you want. Here are the rules:

    LOG LST DISPLAYED NOTES
    Yes No LOG This happens when you run DATA Step or a PROC with the noprint option
    Yes Yes LST ---
    Yes (with ERROR message(s)) Yes ERROR messages with context from the log, then the listing output ---
    Yes (with ERROR message(s)) No LOG ---

    If you want to see the log but it was not displayed you can use SASLog NBExtension which will show the log for the last executed cell or the entire log since the last (re)start of the notebook.

  • Will this leave a bunch of SAS sessions hanging around?

    A SAS session is started for each notebook you have open i.e. 5 notebooks open = 5 SAS sessions. Those sessions will remain active for the life of the notebook. If you shutdown your notebook, the SAS session will also terminate. In JupyterHub, there are configuration options to shutdown inactive sessions and the SAS kernel complies with those directives.

  • I restarted my SAS Kernel and now my WORK library is now empty. What happened?

    When you restart the kernel in a notebook you are terminating the current SAS session and starting a new one. All of the temporary artifacts, data sets in the WORK library, assigned libnames, filename, WORK macros, and so on are destroyed.

Contributing

The Contributor Agreement details how contributions can be made.

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.

Add new section for github actions

sas_kernel's People

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

sas_kernel's Issues

sas_kernel should not require sas to be installed (use SAS Studio server instead)

This package would be tremendously more useful if it would allow me to run SAS code in the same way I do from SAS Studio. This would just be the python client for whatever rest APIs that the JavaScript is utilizing.

With this feature, plus the python-swat project, many types of productive workflows would be possible directly from jupyter.

Perserving SAS html look & feel in Jupyter

I have Jupyter notebook working with SAS, the functionality is great for sequential presentation of material. I'm wondering if it is possible to maintain the SAS professional output look & feel in Jupyter? Currently SAS HTML table output is being justified across the page in Jupyter and is visually less attractive. Graphics (e.g., sgplot) is coming across fine. Thanks for thoughts and feedback on this visual issue.

Error connecting to SAS Kernel for some users

Hi Tom,

We have some couple of users who are unable to connect to SAS Kernel from Jupyterhub environment. We recently upgrade the saspy which exploits the Grid connection.

For some of the users, the connection goes pretty well but for some we are receiving error as :
Please enter the IOM user id: jhays202
Please enter the password for IOM user jhays202: ········
The application could not log on to the server ":8592". The load balancing object spawner timed out.
SAS process has terminated unexpectedly. Pid State= (14552, 64000)
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program /usr/bin/java with the following parameters:['/usr/bin/java', '-classpath', '/app/install/jupyter/anaconda3/lib/python3.5/site-packages/saspy/java/sas.svc.connection.jar:/app/install/jupyter/anaconda3/lib/python3.5/site-packages/saspy/java/log4j.jar:/app/install/jupyter/anaconda3/lib/python3.5/site-packages/saspy/java/sas.security.sspi.jar:/app/install/jupyter/anaconda3/lib/python3.5/site-packages/saspy/java/sas.core.jar:/app/install/jupyter/anaconda3/lib/python3.5/site-packages/saspy/java/saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '42111', '-stdoutport', '60884', '-stderrport', '39715', '-iomhost', 'ndwsgrd-ch2-a3p.sys.comcast.net', '-iomport', '8592', '-user', 'jhays202', '']

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.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
Restarting SAS session on your behalf
in shutdown function
Restarting kernel...
Done!
Out[2]:
'No SAS process attached. SAS process has terminated unexpectedly.'

However this specific user can pretty well access the SAS environment through EG and run queries.

Can you please help us on figuring out this issue.

Feature Request - Python objects ported to SAS

An extremely helpful new feature would be the ability to export pandas dataframe into a SAS dataset, which when combined with SAS magics, we could use a single Python notebook to execute models in both SAS and python.

kernel.json not updated when switching Python

On Windows 10, sas_kernel information is kept in \AppData\Roaming\jupyter\kernels\sas\kernel.json

I had Anaconda at one time and moved away later to plain Python. Trying to open a session using sas_kernel failed despite pip uninstall sas_kernel and pip install sas_kernel. Inspection of the console messages showed that Jupyter was trying to start the sas kernel with Anaconda Python which was removed. Editing the json and replacing the first argument with the correct path to current Python solved the problem.

Change from

{"argv": ["c:\program files\Anaconda3\python.exe", "-m", "sas_kernel", "-f", "{connection_file}"], "codemirror_mode": "sas", "display_name": "SAS", "language": "sas", "name": "sas"}

to

{"argv": ["c:\program files\python36\python.exe", "-m", "sas_kernel", "-f", "{connection_file}"], "codemirror_mode": "sas", "display_name": "SAS", "language": "sas", "name": "sas"}

During debugging, SASpy continued to work (Python notebook using import saspy and %%SAS magic works), but trying to start a SAS notebook via sas_kernel was failing because it was using the wrong Python.exe.

Just wondering if pip uninstall sas_kernel and pip install sas_kernel should update kernel.json as well.

Magic to store passwords at a cell scope

Overview

In a meeting I had about notebooks, they question came up about passwords in code. Many SAS/Access libnames require the user to enter their username and password which is a security issue in the notebook.
I propose a jupyter magic for the sas_kernel that will prompt for passwords and then remove them at the end of the cell.
This would provide a secure way to deal with passwords because:

  1. The passwords would not be stored in the notebook json
  2. The passwords would not be written to the SAS log
  3. The macro variables that store the passwords would be destroyed at the end of the cell submission so there is no chance to intercept them.

Syntax

Here is the proposed syntax and behavior. Comments welcome

A line magic that will prompt when the cell is executed for values

Example 1 - I want to prompt for my password to a database

%macvar pw
libname db oracle user=jared pw=&pw;
.... more code

<end of cell>

The string on the line magic 'pw' will be a macro variable that is created. Its value will be submitted to the SAS system without logging and the macro variable will be destroyed at the end of the cell. Your libname will still be valid and available in the subsequent cells

Example 2 - Prompt for multiple variables

%macvar pw1 pw2
libname db oracle user=scott pw=&pw1;
libname td terdata user=foo pw=&pw2;

.... more code

<end of cell>

This would result in two prompts (presumably for different passwords)

Open Issues

  1. Would you want to do this for non password type of strings? (Note there is a %let syntax in SAS so it doesn't save you much
  2. Do you have a better name than macvar for the line magic?
  3. Do you see any security holes in this strategy?

Dead SAS kernel

Hello! I launch Jupyter Notebook from Anaconda Navigator, open a SAS notebook. The kernel connects, then dies, and cannot restart. I can type code In: but it does not execute.

ssh connectivity for sas and jupyter hub

Hi Jared,

We would like to install sas kernel on JupyterHub server on which sas is not installed using ssh.

Please provide us the instructions. Thank you for all your help.

Thanks,
Amuktha

SAS Kernel in a terminal

Is there a way to start the SAS kernel in a terminal? I'm wondering if there is a way to run the kernel interactively like someone might with ipython. For example, I might start the SAS kernel in a terminal and then start submitting SAS commands. Is that possible?

Instructions for NBextentions

I had trouble with the instructions listed here for NBextensions:

jupyter nbextension install showSASLog/main.js

when I followed the instructions under the forked repo (https://github.com/jld23/sas_kernel.git) under user jdl23 it worked for me:

jupyter nbextension install showSASLog

All working now - excellent usability feature!

Feature Request - Suppress log messages

Some blocks of SAS code can produce verbose log messages, for example large data steps. It would be great to have a way to suppress the output of these log messages - especially in the case when they contain no error messages. Thinking just a kernel magic that would prevent output rendering.

Java Error log4j

Hi!

I'm using Anaconda and trying to use the SAS_kernel with the Jupyter notebook on Windows 10, and SAS 9.4 I have followed all the instructions configuring the config file and added the required folder to the system PATH variable.

However, I am still getting 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.LoginException: The application could not log on to the server "localhost:0". Integrated Windows authentication failed.
at com.sas.services.connection.ClusterEnvelope.getConnection(ClusterEnvelope.java:121)
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:187)
Caused by: org.omg.CORBA.NO_PERMISSION: Access denied. vmcid: 0x0 minor code: 5 completed: No
at com.sas.iom.orb.brg.Engine.parseErrorXML(Engine.java:2208)
at com.sas.iom.orb.brg.Engine.checkForErrorPacket(Engine.java:2029)
at com.sas.iom.orb.brg.Engine.readPacket(Engine.java:5866)
at com.sas.iom.orb.brg.Engine.flowSendAuth(Engine.java:4318)
at com.sas.iom.orb.brg.Engine.flow(Engine.java:714)
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
Caused by: com.sas.iom.SASIOMDefs.GenericError: Unexpected error in function AcceptSecurityContext. Error -2146893044 (The logon attempt failed ).
at com.sas.iom.orb.brg.Engine.parseErrorXML(Engine.java:2109)
... 13 more

We failed in getConnection
The application could not log on to the server "localhost:0". Integrated Windows authentication failed.
Subprocess failed to start. 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__94470__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\jinzha\AppData\Local\Continuum\anaconda3\Lib\site-packages\saspy\java\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '51558', '-stdoutport', '51559', '-stderrport', '51560', '-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__94470__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\jinzha\AppData\Local\Continuum\anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 51558 -stdoutport 51559 -stderrport 51560 -zero -lrecl 1048576

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.
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.
Restarting SAS session on your behalf
in shutdown function
Restarting kernel...
Done!`

After running the suggest code manually, I get the following:

(base) C:\>java -classpath "C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHOME\SASDeploymentManager\9.4\products\deploywiz__94470__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Users\jinzha\AppData\Local\Continuum\anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 50847 -stdoutport 50848 -stderrport 50849 -zero -lrecl 1048576 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:162) Exception in thread "main" java.lang.NullPointerException at pyiom.saspy2j.main(saspy2j.java:171)


Many thanks in advance for any advice and pointers.

404 on sas.js

Should sas.js be available? I am getting this error in my notebook logging:

[W 19:58:02.821 NotebookApp] 404 GET /guest/Demo_SAS_kernel/notebook/static/components/codemirror/mode/sas/sas.js?v=20160708195006 (127.0.0.1) 11.72ms referer=http://anaconda-enterprise.trl:8888/guest/Demo_SAS_kernel/notebook/notebooks/sas_kernel-master/notebook/SAS%20SQL%20Example.ipynb

showSASLog.yaml is not in a valid format?

I did a manual install through pip, all went fine but there seems to be an issue in the yaml file for the extention ShowSASLog.
During startup the Notebook already complains about an 'Unrecognized JSON config file version, assuming version 1'.

I searched for the file on my filesystem (find ~ -name 'showSASLog.yaml') and it found 2 versions:

(py34env)[userid ~]$ vi /home/ONT/userid/py34env/lib/python3.4/site-packages/sas_kernel/showSASLog/showSASLog.yaml
(py34env)[userid ~]$ vi /home/ONT/userid/.local/share/jupyter/nbextensions/showSASLog/showSASLog.yaml

Opening the files shows the following output:

Type: IPython Notebook Extension
Name: ShowSASLog
Description: >
  Show the SAS log from either the
last executed cell in the notebook
OR
the complete log for the notebook
Icon: sasLogJoint.PNG
Link: readme.md
Main: main.js
Compatibility: 4.x

I've changed the description to 1 line (removing the weird indentation and > sign) and everything works fine.
I do get a lot of 404 errors /WARNS though in the Notebook logging (can these be ignored)?

(py34env)[userid@server ~]$ [W 11:23:18.367 NotebookApp] Unrecognized JSON config file version, assuming version 1
[I 11:23:18.396 NotebookApp] The port 8888 is already in use, trying another port.
[W 11:23:45.074 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20160916112318 (::1) 6.89ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[W 11:23:45.251 NotebookApp] 404 GET /static/components/codemirror/mode/sas/sas.js?v=20160916112318 (::1) 1.51ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/home/ONT/userid/py34env/lib/python3.4/site-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
    handler(stream, idents, msg)
  File "/home/ONT/userid/py34env/lib/python3.4/site-packages/ipykernel/kernelbase.py", line 391, in execute_request
    user_expressions, allow_stdin)
  File "/home/ONT/userid/py34env/lib/python3.4/site-packages/metakernel/_metakernel.py", line 351, in do_execute
    retval = self.do_execute_direct(code)
  File "/home/ONT/userid/py34env/lib/python3.4/site-packages/sas_kernel/kernel.py", line 162, in do_execute_direct
    full_log = highlight(self.mva._log, SASLogLexer(),
AttributeError: 'SASsession' object has no attribute '_log'
[W 11:24:23.943 NotebookApp] 404 GET /notebooks/SASLog.html (::1): No such file or directory: SASLog.html
[W 11:24:23.945 NotebookApp] 404 GET /notebooks/SASLog.html (::1) 1.66ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[W 11:24:24.099 NotebookApp] 404 GET /notebooks/SASLog.html (::1): No such file or directory: SASLog.html
[W 11:24:24.101 NotebookApp] 404 GET /notebooks/SASLog.html (::1) 2.39ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[W 11:24:48.709 NotebookApp] 404 GET /notebooks/SASLog.html (::1): No such file or directory: SASLog.html
[W 11:24:48.711 NotebookApp] 404 GET /notebooks/SASLog.html (::1) 1.82ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[W 11:24:48.830 NotebookApp] 404 GET /favicon.ico (::1) 1.49ms referer=None
[W 11:24:48.866 NotebookApp] 404 GET /favicon.ico (::1) 1.44ms referer=None
[I 11:25:08.507 NotebookApp] Saving file at /Untitled.ipynb
[W 11:26:34.562 NotebookApp] 404 GET /nbextensions/theme/theme_default.css?v=20160916112318 (::1) 1.79ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[W 11:26:43.732 NotebookApp] 404 GET /nbextensions/theme/theme_default.css?v=20160916112318 (::1) 1.64ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[I 11:27:44.496 NotebookApp] Saving file at /Untitled.ipynb
[W 11:29:29.191 NotebookApp] 404 GET /nbextensions/theme/theme_default.css?v=20160916112318 (::1) 1.72ms referer=http://localhost:8890/notebooks/Untitled.ipynb?kernel_name=sas
[I 11:29:44.502 NotebookApp] Saving file at /Untitled.ipynb
[I 11:30:29.633 NotebookApp] Kernel shutdown: 457ce4af-c5e3-4268-b245-5e20542e0ec9

sas_kernel in hydrogen

Hi, I am trying to use the SAS kernel in hydrogen for the atom text editor and I continually get the following error message. The kernel still works, the error pop ups are just annoying. What causes them? Is is something related to code completion?

[IPKernelApp] ERROR | Exception in message handler: Traceback (most recent call last): File "C:\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 267, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "C:\anaconda\lib\site-packages\tornado\gen.py", line 1133, in run value = future.result() File "C:\anaconda\lib\site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "C:\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 572, in complete_request matches = yield gen.maybe_future(self.do_complete(code, cursor_pos)) File "C:\anaconda\lib\site-packages\metakernel_metakernel.py", line 508, in do_complete matches.extend(self.get_completions(info)) File "C:\anaconda\lib\site-packages\sas_kernel\kernel.py", line 213, in get_completions method = procer.group(0).split(' ')[-1].upper() + mykey.encode() TypeError: can only concatenate str (not "bytes") to str

Code corrupted

We had an internal garret 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.

Kernel dies on startup

WARNING:root:kernel cce320d2-1637-4333-8968-3228553fbd58 restarted
Traceback (most recent call last):
File "C:\Anaconda3\lib\runpy.py", line 184, in run_module_as_main
"main", mod_spec)
File "C:\Anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Anaconda3\lib\site-packages\sas_kernel__main
.py", line 19, in
from .kernel import SASKernel
File "C:\Anaconda3\lib\site-packages\sas_kernel\kernel.py", line 27, in
from saspy.SASLogLexer import SASLogStyle, SASLogLexer
File "C:\Anaconda3\lib\site-packages\saspy__init__.py", line 16, in
from saspy.sasbase import *
File "C:\Anaconda3\lib\site-packages\saspy\sasbase.py", line 16, in
import fcntl
ImportError: No module named 'fcntl'
[W 08:06:36.998 NotebookApp] KernelRestarter: restart failed
[W 08:06:36.998 NotebookApp] Kernel cce320d2-1637-4333-8968-3228553fbd58 died, r
emoving from map.
ERROR:root:kernel cce320d2-1637-4333-8968-3228553fbd58 restarted failed!
[W 08:06:37.015 NotebookApp] Kernel deleted before session
[W 08:06:37.015 NotebookApp] 410 DELETE /api/sessions/fa2dab59-065e-404d-b491-c0
d70578d5b1 (127.0.0.1) 0.00ms referer=http://localhost:8888/notebooks/Untitled4.
ipynb?kernel_name=sas
[I 08:08:18.255 NotebookApp] Saving file at /Untitled4.ipynb

Jupyter notebook created in University Edition appears off in github viewer

Edit 20170710 - 10 PM Refreshed: This is my GitHub hosted Jupyter Notebook

The MSRP column contains HTML that doesn't belong, it skips every other observation, and the table loses its color formatting.

I tried changing the line endings to CR/LF instead of just LF, but this made no difference.

As displayed by the GitHub render (the table looks weird, this shows the issue):

bad

What it should look like, as displayed by Jupyter editor window via University Edition:

good

The problem exists for both Chrome & Microsoft Edge, on Windows 10 64bit.

Windows install instructions are outdated

I'm unable to get a successfull installation of sas_kernel on windows 10 with anaconda 3.7.
The documentation appears to be outdated in a number of areas.

The defaults for the install of Anaconda on windows 10 do not place it in C:\ProgramData\Anaconda...

The installation options regarding PATH environment variable are no longer the same as those shown in the screen shot and different default values are checked and recommended.

Can someone validate, from start to finish, a complete install with the current version of Anaconda for windows 10 and document the steps?

kernel error, but saspy works

The sas_kernel installed successfully, but when I tried to run the jupyter notebook, the console says:

No module named sas_kernel.__main__; 'sas_kernel' is a package and cannot be directly executed

I've verified that the saspy module works.

Code block isn't being rendered in Jupyter notebook

Same setup as #40 . This post was originally part of #41 but I think they are separate issues so I split.

This notebok is not rendering correctly in Jupyter (launched within SAS University Edition).

When working in the notebook, the code under "Check for dupes" as well as "Check for MSRP outliers" doesn't display in the browser. However, the output shows when it is run. The code, does however show when rendered with nbviewer. Will post a screenshot soon.

Might be a problem with the CodeMirror sas.js? I'll work on debugging.

%%IML Magic error

I was trying out the %%IML magic and noticed the following behavior:

I can get this to work:

%%SAS
proc iml;
print "----------  SAS/IML Results  -----------------";
x = 1:3;
m = {1 2 3, 4 5 6, 7 8 9};
q = m * t(x);
print q;
quit;

I cannot get this to work:

%%IML
proc iml;
print "----------  SAS/IML Results  -----------------";
x = 1:3;
m = {1 2 3, 4 5 6, 7 8 9};
q = m * t(x);
print q;
quit;

I cannot get this to work:

%%IML
print "----------  SAS/IML Results  -----------------";
x = 1:3;
m = {1 2 3, 4 5 6, 7 8 9};
q = m * t(x);
print q;

Each of the ones I cannot get to work give me an error like this:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-22-495f44a56e01> in <module>()
----> 1 get_ipython().run_cell_magic('IML', '', 'print "----------  SAS/IML Results  -----------------";\nx = 1:3;\nm = {1 2 3, 4 5 6, 7 8 9};\nq = m * t(x);\nprint q;')

/root/miniconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2118             magic_arg_s = self.var_expand(line, stack_depth)
   2119             with self.builtin_trap:
-> 2120                 result = fn(magic_arg_s, cell)
   2121             return result
   2122 

TypeError: IML() takes 1 positional argument but 3 were given

Unable to write to template store with proc template

Hello!

I am unable to use "proc template" using Jupyter notebooks. The error message is:
Error: Template "XXX" was unable to write to template store!

Maybe the notebook doesn't have write-privileges to SAS template?

Is there a solution for this?

SAS NBextensions for Jupyter Lab

New to the SAS kernel for Juypter - after a lengthy discussion with Jared Dean at Global Forum 2019 I'm finally up and running.

I installed the SAS NBextension for the SAS log with the following statements successfully. My admin said to use --user since it was just for me:
jupyter nbextension install --py sas_kernel.showSASLog --user
jupyter nbextension enable sas_kernel.showSASLog --user --py

The extensions worked in a Jupyter notebook (yay, full log!) but not in Jupyter Lab. We apparently have users of each. I am not sure if this is supposed to work in Jupyter Lab or not. If yes, then I'm open to suggestion on how to install, and if not, I'm curious if it could be added.

More generally, is the level of support the same for both or is one preferred?

Thanks,
Bruce

ERROR: Could not find a version that satisfies the requirement sas-kernel

The full error is as follows and occurs after 5 connection timeouts:

Retrying (Retry(total=4, connect =None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError<<pip._vendor.requests.packages.urlib3.connection.VerifiedHTTPSConnection object at 0x00000000040412E8>, 'Connection to pypi.python.org timed out. '>': /simple/sas-kernel/

Could not find a version that satisfies the requirement sas-kernel (from versions: )
No matching distribution found for sas-kernel

Don't really know what to do about this, hoping someone can help me resolve the issues. Thanks!

Will it work with SAS 9.4 on Windows?

I have SAS 9.4 and Anaconda Jupyter both installed on Windows 10 (64K).
The sas_kernel was successfully installed also but being used in Jupyter can't connect to SAS.
Are there any way to make this connection working on Windows?

No residual panels for PROC MIXED in Jupter Notebook

ODS graphics are turned on, and other visualizations render correctly, but when I run 'proc mixed ... plots=residualpanel' (or plots=all) in the jupyter notebook (or in jupyter lab) it does not visualize the residual plots after the model output.

SAS Studio

Is anyone working on a kernel for SAS Studio? I'd like to do that.

Windows support?

Question:

Given that SASpy has Windows support, what is holding this sas_kernel to linux? Personally, I love linux, but my current employer runs SAS Server (9.4) on Windows, so I don't have the option. Is Windows support on the roadmap, or is there a technical obstacle that simply makes it untenable?

Thanks.

<tab> touch completion not work with SAS code

Hi,
when we try to use completion function to ask SAS code sugestion, it doesn't work correctly.
=> With SAS PROC, you haven't suggestion on options.
PROC SORT DA => Jupyter NB doesn't suggest DATA option.
=> With Data step, the suggestion only is you writes a correct statement before.
DATA T ;
SE => Jupyter NB doesn't suggest statement. It suggest only if you write SET completly.
I attach a doc with my tests and associated kernal error.
Regards,
pascal
Jupyter_Notebook_SAS-Kernel-UI-problem.docx

"The system cannot find the file specified"

Getting the following error in JN:

`The OS Error was:
The system cannot find the file specified

SAS Connection failed. No connection established. 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__94518__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;H:\anaconda\lib\site-packages\saspy\java\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '52792', '-stdoutport', '52793', '-stderrport', '52794', '-zero', '-lrecl', '1048576', '']

If no OS Error above, try running the following command (where saspy is running) manually to see what is wrong:
java -classpath "C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\sas.core.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94518__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar;H:\anaconda\lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 52792 -stdoutport 52793 -stderrport 52794 -zero -lrecl 1048576 `

No SAS process attached. SAS process has terminated unexpectedly.
Invalid response from SAS on inital submission. printing the SASLOG as diagnostic`

config file is correct in saspy.
paths are correct in windows.

In python:
import saspy
sas = saspy.SASsession(cfgname='winlocal')
print(sas.saslog())

Keeps saying "connecting to kernel" forever.

LOG from anaconda prompt:
[IPKernelApp] ERROR | Exception in message handler: Traceback (most recent call last): File "H:\anaconda\envs\a\lib\site-packages\ipykernel\kernelbase.py", line 268, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "H:\anaconda\envs\a\lib\site-packages\tornado\gen.py", line 735, in run value = future.result() File "H:\anaconda\envs\a\lib\site-packages\tornado\gen.py", line 209, in wrapper yielded = next(result) File "H:\anaconda\envs\a\lib\site-packages\ipykernel\kernelbase.py", line 543, in execute_request self.do_execute( File "H:\anaconda\envs\a\lib\site-packages\metakernel\_metakernel.py", line 395, in do_execute retval = self.do_execute_direct(code) File "H:\anaconda\envs\a\lib\site-packages\sas_kernel\kernel.py", line 148, in do_execute_direct self._get_lst_len() File "H:\anaconda\envs\a\lib\site-packages\sas_kernel\kernel.py", line 73, in _get_lst_len res = self.mva.submit(code) AttributeError: 'NoneType' object has no attribute 'submit'

Works on all my other computers...

%include confused with magic

I got an error with a %include statement on the first line of a cell.

Error in calling magic 'include' on line:

Easy work around was to add code (%put hi;) before the %include statement and then it worked.

SAS in Linux/Jupyter Hub Environment

Tom,

Been talking with SAS tech support about trying to get access to SAS in our Linux Jupyter Hub environment. SAS got back with:

    This is Daniel with SAS Technical Support. I am sorry to hear that you are experiencing this issue.
    I recommend opening up an issue on GitHub at https://github.com/sassoftware/sas_kernel/issues ._

I am on our corporate site where we have SAS Enterprise Guilde running. Our Juypter Hub environment is a web based Linux environment and I was told we could access our SAS servers and use our existing SAS license. Tried setting things up but got the messages below (just a snippet from the beginning with some information 'x'd out) when just trying to run a basic data step. So far, anyone trying to provide assistance has only had Windows suggestions.

Can you suggest some ideas? If you need me to run something or provide more information let me know. I'm sure this is not 'configured', but don't have documentation on what we need to do.

Thank you,
Robert

SAS Connection failed. No connection established. Double check your settings in sascfg_personal.py file.

Attempted to run program /opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_u8 with the following parameters:['/opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_u8', '-nodms', '-stdio', '-terminal', '-nosyntaxcheck', '-pagesize', 'MAX', '']

Try running the following command (where saspy is running) manually to see if you can get more information on what went wrong:
/opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_u8 -nodms -stdio -terminal -nosyntaxcheck -pagesize MAX

No SAS process attached. SAS process has terminated unexpectedly.
Invalid response from SAS on inital submission. printing the SASLOG as diagnostic
[IPKernelApp] WARNING | WARNING: attempted to send message from fork
{'header': {'version': '5.3', 'date': datetime.datetime(2020, 6, 19, 16, 32, 37, 919280, tzinfo=datetime.timezone.utc), 'session': 'xxxxxxxx', 'username': 'xxxxxxxx', 'msg_type': 'stream', 'msg_id': 'xxxxxxx'}, 'msg_id': 'xxxxxxx', 'msg_type': 'stream', 'parent_header': {'msg_id': 'xxxxxxx', 'username': 'username', 'session': 'xxxxxxx', 'msg_type': 'execute_request', 'version': '5.2', 'date': datetime.datetime(2020, 6, 19, 16, 32, 37, 904880, tzinfo=datetime.timezone.utc)}, 'content': {'name': 'stdout', 'text': 'The OS Error was:\nNo such file or directory\n'}, 'metadata': {}}
[IPKernelApp] WARNING | WARNING: attempted to send message from fork

SAS Connection failed on Windows

I'm having issues getting the sas_kernel to work on Windows. I think the issue is related to the configuration file and the Java path but I'm not sure. I don't have java on my path but I tried pointing the configuration file to the SASPrivateJavaRuntimeEnvironment. That causes the kernel to die. When I leave java as the default the kernel doesn't die but I get the following error:

The OS Error was:
The system cannot find the file specified

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__94435__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\log4j.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar;C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\sas.core.jar;C:\\Users\\msterling\\AppData\\Local\\Continuum\\Anaconda3\\envs\\py35\\Lib\\site-packages\\saspy\\java\\saspyiom.jar;C:\\Program Files\\SASHome\\SASFoundation\\9.4\\core\\sasext', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '53545', '-stdoutport', '53546', '-stderrport', '53547', '-zero', '']

Here's what I think is the relevant portion of my sascfg.py file:

# build out a local classpath variable to use below for Windows clients
cpW  =  "C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpW += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94435__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpW += ";C:\\Users\\msterling\\AppData\\Local\\Continuum\\Anaconda3\\envs\\py35\\Lib\\site-packages\\saspy\\java\\saspyiom.jar"
cpW += ";C:\\Program Files\\SASHome\\SASFoundation\\9.4\\core\\sasext"


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

If Python was installed with elevated privs, the package needs them too

While troubleshooting an install issue (rare), pip wouldn't install sas_kernel cleanly. The last gasp looked like the following:

PermissionError: [Errno 13] Permission denied: 'C:\ProgramData\Anaconda3\Lib\site-packages\ipykernel\codeutil.py'

A note or other friendly reminder in the install section of the doc to use elevated privs (if python was installed with elevated privs) might be worthwhile.

Enabling inline for SAS outputs in notebook

I downloaded the notebook as PDF and I do not see the SAS outputs in the file. It shows the following in the PDF output "<IPython.core.display.HTML object>" instead of the actual output and graphs. Is there a way to enable inline magics options as the same way we do in Python notebook, so that the plots can also be include when we download the notebook as PDF.

SAS_Hello_Word.pdf

Foreg: %matplotlib inline
After I execute the above command using Python Shell, I can see graph when I download the notebook as PDF.

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.