Working with SAS

With Anaconda Enterprise, you can connect to a remote SAS server process using the official sas_kernel and saspy. This allows you to merge SAS and Python/R workflows in a single interface, and to share your SAS-based work with your colleagues within the Enterprise platform.

Note

SAS is currently available in interactive development mode session only, not in deployments.

sas_kernel is distributed under the Apache 2.0 Licence, and requires SAS version 9.4, or later. SAS is (c) SAS Institute, Inc.

Anaconda Enterprise and sas_kernel

Anaconda connects to a remote SAS server application over a secure SSH connection.

../../_images/ae5-sas-kernel.png

After you configure and establish the connection with the provided SAS kernel, SAS commands are sent to the remote server, and results appear in your notebook.

Note

Each open notebook starts a new SAS session on the server, which stays alive while the notebook is being used. This may affect your SAS license utilization.

Configuration

The file sascfg_personal.py in the project root directory provides the configuration for the SAS kernel to run.

Normally your system administrator will provide the values to be entered here.

The connection information is stored in a block like this:

default = {
    'saspath' : '/opt/sas9.4/install/SASHome/SASFoundation/9.4/bin/sas_u8',
    'ssh'     : '/usr/bin/ssh',
    'host'    : 'username@55.55.55.55',
    'options' : ["-fullstimer"]
}

'saspath' must match the exact full path of the SAS binary on the remote system.

'host' must be a connection string that SSH can understand. Note that it includes both a login username and an IP or hostname. A successful connection requires that both are correct. The IP or hostname may have an optional suffix of a colon and a port number, so both username@55.55.55.55 and username@55.55.55.55:2022 are possible values.

Establishing a Connection

The SAS server machine must allow SSH with password-less login.

Before starting, you will need a secure key (.pem) file installed on the SAS server machine. This will normally be done for you by your organization, but if you have username/password access to the machine, you can make your own as described below.

Whenever you start a new editing session, you must perform the following steps before creating or running a notebook with a SAS kernel:

  • Upload your .pem file to your editing session. In a JupyterLab or Jupyter notebook, click the left Files tab, then at the top of the pane click the upload button and navigate to the file on your system.

  • From the New/Launcher pane, open a terminal and run these commands:

    chmod 0400 <myfile.pem>
    ssh-add <myfile.pem>
    ssh <connection-string> -o StrictHostKeyChecking=no echo OK
    

    Replace <connection-string> with the host entry in sascfg_prsonal.py and <myfile.pem> with the name of your key file.

Now you can start the notebooks with the SAS kernel from the launcher pane, or switch the kernel of any notebook that is already open.

Installing a .pem File

You can create your own .pem file within Anaconda Enterprise 5, or any local machine with openSSH installed. Run this command:

ssh-keygen

Give your key file a name, typically with the extension .pem. You may give your key file a password or leave the password prompt empty.

The ssh-keygen command creates two files.

One file has the exact name you specified. Upload this file into your SAS kernel editing session.

The other file ends in .pub, and must be known to the SAS server. You can view this file in the terminal with the cat command:

cat <myfile.pem.pub>

Log in to the SSH server using your username and password. Edit the file ~/.ssh/authorized_keys and append the contents of your .pem.pub file there. You can edit the file with any console text editor on your system, such as nano or vi.