SAS University Edition: Help Center

Can I run SAS code in a Python 3 notebook?

Yes! If you want to run SAS code from a Python 3 notebook, use the %%SAS Jupyter magic that enables you to submit the contents of the cell to your SAS session. The cell magic executes the contents of the cell and returns any results.

  1. Enter the %%SAS Jupyter magic at the beginning of your SAS program.

  2. To run the program and add a new code cell below the program, select the cell in the notebook and click Run Cell and Select Below button on the toolbar. The output is automatically displayed below your code. If the code has no errors, the results are displayed. If the code has errors, the log is displayed. You can collapse and expand the output by clicking in the left margin of the output cell.

    Note You can also run a program by using one of the Run options from the Cell menu.

    Code cell with SAS code