BookmarkSubscribeRSS Feed

Custom Steps in SAS Studio - GitHub repository now available!

Started ‎10-25-2022 by
Modified ‎11-03-2022 by
Views 3,555

Introduction

 

A custom step in SAS Studio enables you to create a user interface for users at your site to complete a specific task without having to know or write SAS code.

 

On the surface, custom steps may look like any another feature within SAS Studio, but three key benefits make custom steps a developer favorite.

 

Code Reusability – You can save custom steps to any file system available on your SAS Server or in SAS Content and they are immediately available to all users in SAS Studio.

 

No/Low Code Solution – A point-and-click UI enables any user to create their custom step using the Designer interface. Additionally, SAS Studio has starter templates, so you don't have to build it from scratch.

 

GitHub repository – A SAS Studio custom step repository is now available in GitHub to explore any published advanced data transformation steps; you may also create, publish and share your custom step with the community.

 

 

Creating a custom step

 

Creating new custom steps, or modifying existing custom steps, aka authoring a custom step, is made up of two major parts: defining the UI, which is done via the Designer interface, and defining the generated SAS code, which is done in the Program section of a custom step definition.

 

SAS Studio comes with a few embedded starter templates, so you don’t have to start from scratch. When creating a new custom step, use one of the starter templates and then customize it to your needs.

 

As mentioned earlier, the SAS Studio Custom Steps repository is now available on GitHub to make it easy for SAS users to publish and share their custom steps with other SAS users. The repository already contains several custom steps published by SAS staff, including ones representing advanced data transformations. We encourage SAS users to participate and contribute to the repository.

 

To add the the custom steps from GitHub to your SAS Viya environment, download repository to your local machine and then upload the steps to a SAS Content folder. We’ll describe more details later in this article, but we’ll first walk you through the process of creating a custom step.

 

Defining the UI part

 

Figure 1 - Designer interface for custom stepsFigure 1 - Designer interface for custom steps

 

The Designer interface provides an extensive Control Library used by the step author to display information and capture input from the user. It includes UI elements to select tables in SAS libraries, select files in directories or in SAS Content folders, select columns from a table, and many more.

 

Make the list of displayed UI elements dynamic by using dependencies. Dependencies enable the step author to specify the state of the control based on the values of other controls. For example, the selection of a check box control could result in the visibility of a drop-down list control. If the check box control is not selected, the drop-down list control remains hidden.

 

On top of that, the author can define Prompt Hierarchies to create a hierarchy of dynamic controls. Use a hierarchy to indicate the value of one dynamic control affects the available values in a subsequent dynamic control.

 

Below is an example of how you would use this. Assume you have a lookup table listing car brands and car models each brand manufactures. You would provide a UI to your users to select a brand first, by displaying distinct values from the Make column in your lookup table, and once they have selected a brand only show the Model made by that brand. This is also known as Cascading Prompts.

 

Figure 2 - An example of using Cascading PromptsFigure 2 - An example of using Cascading Prompts

 

Defining the code generator part

 

The code generated by your custom step is specified in the Program section of the custom step definition. Inside that Program section you can reference SAS macro variables representing values specified by the user in the UI at runtime. This allows you to create very simple code generators that put values in a “fixed” template as shown in this example.

 

Figure 3 - Program tab showing code generatorFigure 3 - Program tab showing code generator

 

Of course, you can make the code generation more dynamic by defining SAS macros that generate different code based on selections provided by the user. And because SAS Viya has proc python, your custom step could generate Python code as well.

 

In either case, the user makes selections in the point-and-click UI of the custom step and runs it, no need for the user to know how to write SAS code.

 

Running the custom step

 

Two modes are available for use with custom steps: standalone and flow. Using the step in standalone mode means that the user is presented with a new tab in SAS Studio containing the UI of the custom step. The user fills in the required fields and clicks the run button. Results, either output tables or reports generated by the SAS code, will be shown in the SAS Studio UI.

 

Figure 4 - Custom step in standalone mode, showing resultsFigure 4 - Custom step in standalone mode, showing results

 

Flow mode allows you to perform a sequence of operations on data using a graphical flow builder. SAS Studio provides an out-of-the-box library with Steps that perform operations on data, and custom steps are also listed in that library. Here is a flow where the custom step was used in combination with standard steps, like Filter Rows.

 

Figure 5 - Custom Step used in a SAS Studio flowFigure 5 - Custom Step used in a SAS Studio flow

 

You’ll notice when a custom step is used in a flow, the input and output table do not show up in the UI of the custom step itself, but are defined by separate table nodes. The user connects the table nodes to the input and output port(s) of the custom step. This approach allows you to take advantage of the standard transformations before and after the custom step.

 

Sharing custom steps

 

Custom steps can be saved in a folder in SAS Content. If a user has read-access to the folder, custom steps stored there will be listed inside the Shared tab in the Steps pane. You may also download custom steps residing in a SAS Content folder to a file on your local machine. This allows easy distribution to others for use in a different SAS Viya deployment. Similarly, you can upload a custom step file to a SAS Content folder.

 

Announcement - SAS Studio Custom Steps repository now available on GitHub

 

SAS has created a SAS Studio Custom Steps repository on GitHub to make it easy for SAS users to share their custom steps with other SAS users. Several SAS employees have already shared their custom steps and we encourage SAS users to participate and contribute. Details describing how to download and how to contribute are documented in the repository itself.

 

We have downloaded all those custom step files to our local machine from GitHub. Next, we used the Upload Files option in the Explorer pane in SAS Studio to upload them to a SAS Content Folder in a SAS Viya deployment. Here is the result shown in the Shared tab of the Steps pane in SAS Studio.

 

Figure 6 - Steps pane with custom steps downloaded from GitHub repositoryFigure 6 - Steps pane with custom steps downloaded from GitHub repository

 

Wrapping things up

 

SAS Studio Custom Steps is a great way to promote code reusability. If a specific data transformation step is missing, custom steps in SAS Studio give you the ability to create and share steps with users across the organization. Enjoy creating your own SAS Studio custom step.

 

Learn more

 

 

About the author

 

Wilbram Hazejager is a principal product manager. He has been involved for many years in SAS’ data management products in various roles, including R&D architecture, working closely with customers, and authoring several papers on SAS data management products. He holds a Master of Science degree in Applied Mathematics from the Eindhoven University of Technology in the Netherlands. 

Comments

Excellent initiative, thanks a lot @Wilbram-SAS for this explanation and sharing.

In particular, the "Data Ingestion Auto-Pilot"  - a refactored proc import  in itself - looks terrific and hugely versatile ! 👍

 

https://github.com/sassoftware/sas-studio-custom-steps/tree/main/Data%20Ingestion%20Auto%20Pilot%20D...

@ronan , happy you like it. Credits for the "Data Ingestion Auto-Pilot" contribution should go to @stephanweigandt !

 

Btw. https://github.com/sassoftware/sas-studio-custom-steps/blob/main/CUSTOM_STEPS_LIST.md lists all the entries and the name of the initial contributor. 

Version history
Last update:
‎11-03-2022 03:07 PM
Updated by:

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags