SAS Notebooks in VS Code: A developer’s guide
You are probably acquainted with Jupyter Notebooks. The ability to combine code cells with their logs and results, along with brand cells for easy documentation, makes them extremely useful.
When you start Sas Viya workbench and select Visual Studio Code as your favorite editor, you can use a powerful new tool: SAS notebooks.
SAS notebooks are interactive notebooks for SAS coders that include the following three types of cells:
- MarDown: Write your note, click Run and MarDown will give.
- Sas: Write the SAS code with full syntactic emphasis, suggestions and autocomple.
- Sql: Write your Proc SQL code without the need for the wrapper around Proc, allowing you to focus on the essential things.
Well, let’s see how we can create a new SAS notebook. Just right click on Explorer and give a name a name a name. Then use the file alignment .Sasnb – eg, example.sasnb.
When you open the SAS notebook, it should look like this, depending on the nature of your chosen topic:
- Click Codification Button to add a code cell to your notebook.
- Click Note Button to add a marks cell to your notebook.
- Allocate The button allows you to execute all the cells inside the notebooks.
- Clean all exit The button allows you to reset the production of all cells.
- This small overflowing menu hides additional customization opportunities for the appearance and feeling of your notebooks and provides the opportunity to export the notebook as a .sas OR .html File is an option called Notebook line numbers which I have activated for further pictures.
Let’s explore
Let’s take a more detailed look at different types of cells to give you a taste of what is possible.
The first is the brand cell. Simply write using the marks syntax, and you will immediately see the pronounced syntax:
- You can run an individual cell by clicking scoot button or using the keyboard shortcut Ctrl + Enter.
The direction of the mardown cell makes it in place. To get back to editing mode, simply click twice on the cell:
Next is the SAS code cell:
- Hovering over a keyword SAS brings the functions of aid.
- When running a cell, you get a sign of control and the overall time of your code.
- And under the cell, you can see SAS score or register.
Now let’s create an SQL code cell. To make it, add a new code cell as before. You will notice that the lower right corner still says Sas. If you click on it and the dialog shows Ms sqlDon’t worry – you are still running SQL Proc. This is a well -known behavior in the VS code itself, not an issue with SAS:
- Remember while saying Ms sqlmean Sql Or even better Proc Sql. All the excellent data step functions you are accustomed to have are available.
- Just as with Sas Code Cell, we get a sign of control and an indicator of execution.
- And finally, we see the result of our question below the cell itself.
cONcluSiON
SAS notebooks are a great way to program in SAS and combine it with documentation, making it easier to repeat and increase your productivity. Using the export functionality mentioned at the beginning of the article, you can turn your notebook into SAS code files to easily share with others, or export it as an HTML file so that everyone can see the excellent results you produced.