Everything is better with friends: Executing SAS code in Python scripts with SASPy

Isaiah Lankham1 and Matthew Slaughter2
1University of California Office of the President, 2Kaiser Permanente Center for Health Research


SASPy is a module developed by SAS Institute for the Python programming language, providing an alternative interface to the SAS system. With SASPy, SAS procedures can be executed in Python scripts using Python syntax, and data can be transferred between SAS datasets and their Python DateFrame equivalent. This allows SAS programmers to take advantage of the flexibility of Python for flow control, and Python programmers can incorporate SAS analytics into their scripts.

In this hands-on workshop, we use the Jupyter Notebook interface for SAS University Edition to complete common data-analysis tasks using both normal SAS code and SASPy within a Python script. We also highlight important tradeoffs for each approach, emphasizing the value of being a polyglot programmer.

As background, Python is an open-source language originally developed for teaching programming in the 1990s. Highly praised for its straightforward syntax, Python initially became popular as a "glue" language and is now widely used in many problem domains, from data science to web development. Many popular websites are Python applications, including YouTube and Instagram.

This workshop is aimed at users of all skill levels, including those with no prior experience using Python or Jupyter Notebook, and assumes only basic familiarity with SAS syntax. Attendees wishing to follow along using their own computer should pre-install the latest version of SAS University Edition, which includes everything needed to try out SASPy.