Running SAS in Quarto. Part 1

Quarto is a powerful web publishing system based on Pandoc. Working with jupyter kernels expands the number of languages that Quarto can work with. In this example we'll add SAS capability to Quarto.

Setup

First install the saspy and the SAS kernel packages.

1pip install saspy
2pip install sas_kernel

Once installed the sas kernel should be listed when running jupyter kernelspec list:

1sas      ...
2python3  ...

Configure saspy

Before the kernel can be used, two configuration files need to be created:

  • sascfg_personal.py contains details on how to connect to a SAS instance
  • _authinfo contains authentication details

Details on the configuration files are available at https://sassoftware.github.io/saspy/configuration.html.
I'm using SAS on demand and additional information on editing these two files is available at https://support.sas.com/ondemand/saspy.html.

sascfg_personal.py

Below is an example of a sascfg_personal.py (for a PC configuration). Here we are specifying the connection to the SAS On Demand for Academics (oda) service, US Home Region 2. The sasacfg_personal.py can be placed in the .config/saspy/ subfolder under the home folder.

 1SAS_config_names=['oda']
 2oda = {'java' : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath\\java.exe',
 3#US Home Region 1
 4#'iomhost' : ['odaws01-usw2.oda.sas.com','odaws02-usw2.oda.sas.com','odaws03-usw2.oda.sas.com','odaws04-usw2.oda.sas.com'],
 5#US Home Region 2
 6'iomhost' : ['odaws01-usw2-2.oda.sas.com','odaws02-usw2-2.oda.sas.com'],
 7#European Home Region 1
 8#'iomhost' : ['odaws01-euw1.oda.sas.com','odaws02-euw1.oda.sas.com'],
 9#Asia Pacific Home Region 1
10#'iomhost' : ['odaws01-apse1.oda.sas.com','odaws02-apse1.oda.sas.com'],
11#Asia Pacific Home Region 2
12#'iomhost' : ['odaws01-apse1-2.oda.sas.com','odaws02-apse1-2.oda.sas.com'],
13'iomport' : 8591,
14'authkey' : 'oda',
15'encoding' : 'utf-8'
16}

_authinfo

The _authinfo file is located in the home folder and, for SAS On Demand for Academics, looks like this:

1oda user <username> password <password>

where and are the credentials to connect to oda.

testing SAS in Quarto

Now that the SAS kernel has been installed and configured, we should be able to execute SAS code in a Quarto document by specifying the kernel in the yaml:

 1---
 2title: "Quarto Demo with SAS"
 3format: html
 4jupyter: sas
 5self-contained: true
 6---
 7
 8### Jupyter SAS kernel
 9
10```{sas}
11proc candisc data=sashelp.iris out=outcan distance anova;
12   class Species;
13   var SepalLength SepalWidth PetalLength PetalWidth;
14run;
15```