Introduction to SASPy: Using SAS in Python

Slide Note
Embed
Share

Learn about SASPy, a Python API to the SAS system that allows for seamless interaction between SAS and Python environments. Explore how to start a SAS session, exchange data between SAS datasets and Pandas data frames, and utilize various useful methods. Discover the benefits of incorporating SASPy in your workflow to overcome memory issues, retain SAS language familiarity, and enhance expandability with Python.


Uploaded on Jul 17, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. WHARTON RESEARCH DATASERVICES Use SAS in Python: SASPy Introduction (1) Eunji Oh, PhD June 2020

  2. Agenda SASPY INTRODUCTION / HOW TO USE 1 SASPy Introduction 2 SASPy Configuration 2 Wharton Research Data Services

  3. What is SASPy? Python APIs to the SAS system Start a SAS session on the same host as Python Exchange data between SAS data sets and Pandas data frames Useful SAS and Pandas methods are available: describe(), head(), sort(), where() and etc. Documentation: https://sassoftware.github.io/saspy/ 3 Wharton Research Data Services

  4. Why SASPy? Typical Workflow with both SAS and non-SAS data Create / Export SAS Dataset Software/Kernel change Import Software/kernel change Import Create / Export Output data (ex - csv) 4 Wharton Research Data Services

  5. Why SASPy? New workflow using SASPy Create / Export SAS Dataset Software/Kernel change Import Convert Software/kernel change Import Convert Create / Export Output data (ex - csv) 5 Wharton Research Data Services

  6. Why SASPy? Run SAS code within a Python program Without changing kernel or software Conveniently transferring data as well as macro variables Overcome the famous memory issue of Python No need to read huge data into memory Bypass Python s memory problem by connecting to a SAS session running in the background in your Python program Keep using familiar SAS language No need to translate your old SAS codes into Python code Utilize Python s great expandability 6 Wharton Research Data Services

  7. SASPy environment requirements Requirements for your local environment Python3.4 or higher SAS 9.4 or higher Optional: Jupyter Notebook for Jupyter Magic Requirements for WRDS cloud environment Access to WRDS Cloud: WRDS Jupyter Lab Optional: Your own virtual environment to install custom python packages 7 Wharton Research Data Services

  8. How to setup SASPy From Local Computer 1. Install from (anaconda) command prompt pip install saspy conda install saspy 2. Add the path below to SYSTEM PATH environment variable (Windows only, path may vary by individual) C:\Program Files\SASHome\SASFoundation\9.4\core\sasext 3. Run Python and Import SASPy import saspy 4. Configure SASPy (Windows) from saspy import autocfg autocfg.main() #sascfg_personal.py file will be generated 8 Wharton Research Data Services

  9. How to use SASPy - WRDS Jupyter Lab 1. Access WRDS Jupyter Lab (Login with WRDS ID and Password) Manual: https://wrds- www.wharton.upenn.edu/pages/support/programming- wrds/programming-python/jupyterhub-wrds/ Jupyter Lab: https://wrds-jupyter.Wharton.upenn.edu/ 2. Open a notebook with Python3 kernel Either default Python 3 kernel or your own virtual environment kernel 3. Simply import the pre-installed SASPy 9 Wharton Research Data Services

  10. Summary SASPy could be useful for SAS users learning Python SASPy helps easily integrating SAS code in Python code Next video: Useful SASPy functions 10 Wharton Research Data Services

Related


More Related Content