While Jupyter Notebooks have been around for a long time and SAS has been supporting them for a number of years, it hasn't been possible to submit your SAS Global Forum paper as a Jupyter Notebook - until now!
We're really excited that, starting with SAS Global Forum 2021, those presenting will have the ability to submit their paper as a Jupyter notebook. The notebook will be hosted as an asset in the proceedings and hosted on Github as an interactive item that people can engage with in more interesting ways than the humble PDF.
There is lots of information contained within the README of the Jupyter notebook template, but this article is designed for those who would like to explore submitting their paper as a Jupyter notebook but might not be familiar with Jupyter, Git/Github, and Python. This article describes how to install Git, the latest version of Python (3.9 at the time of writing) and Jupyter, and how to get started with using the SAS Global Forum 2021 Jupyter Notebook template.
Git is the most popular version control system in the world. You'll have likely seen references to it in your familiar SAS client applications like SAS Enterprise Guide and SAS Studio.
Github is a code hosting site for the Git projects that allows people to share their projects and collaborate. SAS Global Forum has been using Github as a way for people to share SAS programs and other supporting materials for the SAS Global Forum papers since 2018.
With SAS Global Forum 2021, we are using Github to host the Jupyter Notebook template. The easiest way to get started with Git, and to download and upload our paper and the template, is to run the Github Desktop App.
Python is a high-level programming language that's increasingly popular. Its easy to learn and easy to read. One of it's most powerful features is that its supports packages and modules which makes it really easy to extend the core functionality of Python with exciting things. One of those things is Jupyter Notebooks. Jupyter is actually just a Python module.
In order to be able to run Python modules, it won't surprise you that we need to install Python. Jupyter requires Python 3+. At the time of writing, the latest version of Python is Python 3.9.1.
After a couple of minutes, the installation should complete successfully:
python --version
. Python should output the version (3.9.x) and then exit.
Since we've got our machine configured for Git and Github and we have installed Python, we're ready to get into the exciting part: downloading the template and installing the dependencies.
We've included a file in the Jupyter notebook template folder (requirements.txt
) that contains all of the dependencies needed for getting the template up and running.
If you've worked with a source control management system before you'll know that its power lies in the way that we can create multiple different versions of files by branching.
We're going to create a branch for our paper so that we can work on it, and publish it to Github, without affecting other people.
When the command has completed successfully, you should see something like this:
Enter the following commands into the command prompt to create a python virtual environment1 called env and then "enable" the newly created virtual environment. The first command may take a few seconds to execute and the second command will result in a `(env)` being prepended to the path in the command prompt window.
python -m venv env
.\env\Scripts\activate
pip install -r requirements.txt
Within the folder for your paper there is a file called `sascfg_personal.py`. This file is what is used by the [SAS Kernel]() to connect from the Notebook to your SAS installation. This could be Base SAS running on the same Windows machine that you are running the Notebook on or it could be a remote SAS9 or Viya environment on either Windows or Linux.
If you open the file you will see that there are lots of instructions for ensuring that you pick the correct configuration depending on your environment. If you have any issues make sure you checkout the documentation , blogs , and papers before creating an issue .
In the example below I am connecting from my Windows 10 machine to a SAS9 instance running on Linux using the included winiomlinux configuration. I have added the `encoding` option to match the encoding of my SAS installation:
When I run the cells of my notebook (we're going to get to this in the next section, I promise) either by clicking Shift + Enter, or clicking the double right arrow >>, I am prompted for the configuration I want to use as well as my SAS username and password.
Finally, we're here. We've installed Git and downloaded the template from Github. We've created a new branch for our paper and copied the template to our new paper folder so that we can start writing. And we've installed Python and all of the dependencies for running the template.
.\env\Scripts\activate
jupyter notebook
I hope that you found this step-by-step guide useful. Please don't hesitate to add any questions you might have in the comments section below. I am very excited to see all the incredible Jupyter contributions at SAS Global Forum 2021 and I hope to see you at the conference, virtually, of course!
1 Python virtual environments are a way that we can install libraries and scripts in an isolated way. If you need to install specific versions of a package to run an application you can do this without affecting the system-wide installed version. In general, its could practice to create a virtual environment for each of your Python projects.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Introducing your SAS Global Forum 2021 Conference Chair, Dina Duhon. Her goal? Provide the best content to SAS users in the most consumable way -- given that we're virtual for 2021. Read her interview on the SAS Users blog.