BookmarkSubscribeRSS Feed

Automated Custom Step Development: py-sas-studio-custom-steps

Started yesterday by
Modified yesterday by
Views 74

It’s here!  To tell you the truth, it has been around for a while, but with release 1.0.0, py-sas-studio-custom-steps helps you programmatically create, modify and enhance SAS Studio Custom Steps, freeing up time and improving developer productivity.

 

SAS Studio Custom Steps are low-code components designed for analytical and data engineering operations on the SAS Viya platform. They offer a user interface for receiving parameters which are then executed in an associated SAS program. Custom Steps provide easy access to common operations, boost code reusability, and help establish best practices in programming.

 

With py-sas-studio-custom-steps, an open-source contribution developed as a personal project, you now have a Python interface to work with custom steps that enhances your custom step development through automation and consistency.  Offered as a Python package installable from PyPi, the default third-party package repository for Python, py-sas-studio-custom-steps contains a CustomStep class with a host of convenient methods.

 

Note that this is not a SAS product.  It deals with a JSON representation of a SAS Studio custom step, which is saved as a .step file in serialised format.  If you’re reading this sometime in the future (after this post was first published, that is, 🙂 ), note that future changes to custom step representation might require a change to this package.

 

Let’s quickly walk through an example.  Install py-sas-studio-custom-steps through the standard pip install method.  You can also use uv or other package managers that work with PyPi if you like.

 

(view in My Videos)

 

pip install py-sas-studio-custom-steps
# or 
uv pip install py-sas-studio-custom-steps

 

That was fast.  Next, let’s look at a simple method.  What if you want a new custom step? A new, empty custom step.  Import the package and then instantiate a CustomStep object.  This represents a custom step as a Python object, to which you can add a SAS program and a UI definition.

 

Searching for how to add a starter page? Simply make use of built-in methods to add a starter page and an About page.

 

from py_sas_studio_custom_steps import CustomStep
cs = CustomStep()
cs.add_starter_page()
cs.add_about_page()

 

(view in My Videos)

 

Notice the additional bonus here.  Not only were you able to do the above, but you were able to do this in SAS Studio, making use of Python integration within SAS Studio! The benefit from this interface is that now you have code sitting in your Viya environment which can be governed and automated as part of your DataOps pipelines.

 

Let’s go further.  Most custom steps are representation of repeatable code that already exists in SAS programs and macros.  Custom step developers typically (though, of course, not always) start with a SAS program and then write a user interface (UI) for the same.  Using the CustomStep class, you can easily attach existing SAS programs to be associated with the custom step object, as follows.

 

(view in My Videos)

 

Even further, what if you want to improve on an existing custom?  The `load_step_file()` method helps you by loading the contents of an existing custom step file to the step object.

 

(view in My Videos)

 

Note that we can load a step file either from the file system or a GitHub URL. Very useful in cases when the custom step is part of a repository such as https://github.com/sassoftware/sas-studio-custom-steps  

 

Now for some fun.  Really, really smart or really, really lazy people, depending on your point of view, might wish to create their own custom step with AI assistance.  Following the custom step instructions to optionally install the google-genai Python package, you have access to methods that use the Google Gemini Flash 3.5 model to assist in AI-generated code.

 

Before we go further, the usual caveats when taking assistance from AI:

  • Use at your own risk and use after human review. AI-generated code can easily provide misleading and inaccurate results, with impactful consequences if applied without understanding and common sense. 
  • The Python package has no direct control over the output from LLM.  The prompt used in the package, while calling the LLM, can be found here. Feel free to modify this should you feel the need to.
  • The LLM here was used only to serve as an example, and maybe in some way reflects the author’s preference 😉 .  This is not meant to be an endorsement of any particular Large Language Model (LLM) as the LLM of choice for generating SAS code.  My honest answer, if you were to ever ask me the best choice, would be to give my own name, or show you a mirror 😉 .
    • YOUR choice of LLM should be driven by factors unique to YOUR development environment, like your organisation’s policy, costs, your preference (if it matters ;)),  access to the service etc.

 

Enough caveating. Trusting you are big little boys and girls, let’s look at an example.

 

(view in My Videos)

 

We have touched upon most of the basic functions around creating a custom step, attaching code, and saving your output, all through a Python program, which implies you can automate most tasks in custom step development.  In addition to automation, consider these other two use cases.

 

  1. Quality Control and code review: Imagine being given a nice, gift-wrapped package and having to take the pain of unwrapping it to examine the contents.  Methods such as extract_sas_program and extract_ui make it easy to examine individual components forming part of a custom step for review and testing purposes.  With the increased use of agentic workflows, this package also helps an agent with the right tools to query relevant metadata from a custom step as part of an automated versioning or promotion process.

 

  1. “Ready-To-Run” steps:  You never know your customers (or end users). Some customers may expect ready-to-run custom steps with all parameters plugged in.  This package facilitates the automated creation of predefined parameters in UIs with modification offered as an option. For example, if we have a custom step A which expects user parameters such as an input table name, column names etc., using this package we can create several “clones” of that custom step through code, insert opinionated table names and arguments, and save them as ready-to-run steps.  If the target users wish to, they may edit those parameters.

 

This was meant to be a quick introduction to py-sas-studio-custom-steps and it’s highly likely you might come up with more ideas and uses as you practice using this package. Get in touch here.

Contributors
Version history
Last update:
yesterday
Updated by:

Viya Copilot Motion Graphic.gif

Ready to see what SAS Viya Copilot can do?

Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.

Get Started →

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started