Nesting techniques with Viya SAS Studio Flows

  • SAS Viya
  • Enterprise Guide
  • SAS Studio

By Steve Huggins

Nesting Programs in SAS 9

In SAS Enterprise Guide (EG) it is often useful to include an external SAS program as part of an Enterprise Guide process flow. This means that when the flow is executed the code held within the external SAS program is executed as part of the flow.

This provides several advantages. A standard set of code can be used by multiple process flows, projects, and users. This is often used to serve the role of an autoexec setting up standard parameters and promoting consistency across teams.

Since the SAS program is held externally (to the projects) any amendments can be made to the single file and will be propagated wherever it is referenced. The SAS program can also be made secure so that only specific users are able to update it.

Another way this functionality can be used is to string lots of programs together into a flow effectively using EG as process orchestration tool.

The new world of SAS Viya

With many SAS users moving to SAS Viya and switching to SAS Studio in place of SAS EG, where does this leave us with our nested programs? Well, the good news is that we can still do this, and in much the same way, but there is more to boot as we will see later.

SAS Studio flows are the natural evolution of EG Process Flows and indeed when you import an EG project into Viya the flows are converted to Studio flows. So how can we include nested program in a SAS Studio flow.

Here’s how to nest a SAS program in a SAS Studio flow.

If you have your SAS program already saved, either on server storage or within the content storage you can add a reference to your flow by simply dragging the program from the explorer into the flow.

Clicking on the program node and selecting node tab at the bottom of the window shows the properties of the program including the location of the file being referenced:

As with Enterprise Guide there is an option to embed the file within the flow itself disassociating it from the external file and generating a standalone copy within the flow.

An alternative method to add a program reference is to add a new SAS program (this which will add a blank program node which is embedded by default), click on the node tab and opt to save it as an external file, there is also an option here to simply replace the node with an existing external file reference.

So it is easy to develop a program within a flow and then save it externally (possibly to share with others).

So overall, nesting external SAS programs in SAS Studio is very similar to Enterprise Guide, but wait, there is more! You can also nest flows within SAS Studio flows.

Firstly, you will need to have an existing flow, this time it must be stored within the SAS content storage. Again, you have two options here to add it to your current flow, the first is to simple drag one flow into the other.

An alternative method is to right-click on the flow you want to add and select add to flow, this will add it to the flow you are working on:

Unlike SAS programs you are not able to link multiple process flows together, luckily you can control their order of execution using swim lanes (a subject for another day).

Pulling together all of this allows you to create complex flows that are made from a combination of other flows, nested and embedded SAS programs, and all the other SAS Studio features available. All of this can then be organised using swim lanes to ensure the right run order.

Conclusion

To summarize, nesting programs in SAS Enterprise Guide and SAS Studio (SAS Viya) offers numerous advantages, including code reusability, standardization, and streamlined process orchestration. This approach facilitates collaboration among teams, enhances workflow efficiency, and promotes consistent results across projects. Embracing this practice is a key step in maximizing productivity and maintaining top-notch data analytics endeavors within the SAS ecosystem.
If you need support in upskilling yourself or your team in SAS check out our training courses below or get in touch with us to discuss your specific needs.

SAS Training Courses
Back to Insights

Talk to us about how we can help