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 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.