BookmarkSubscribeRSS Feed

SAS Studio Custom Steps - Coding Made Easier Using the Column Selector Control

Started ‎06-27-2023 by
Modified ‎06-27-2023 by
Views 553

As of SAS Studio version 2022.12, there is a new generated macro variable in town!

 

Code development and maintenance is much simpler when using the Column Selector control as it now generates a macro variable that lists the columns selected, separated by a space.

 

When code is generated for a custom step, whether it’s used as stand-alone or in a flow, macro variable(s) are generated for each control in a step. The ID of each control is used to name the SAS macro variables that can be used in the SAS code for your custom step.

 

Prior to SAS Studio 2022.12

This custom step has been opened in a tab in the SAS Studio workspace, also referred to as stand-alone.

GR_1_ColumnSelectorControlOldMacros.png

 

The Column selector control, the prompt labelled “Select columns to print”, enables users to select single or multiple columns when executing the custom step. In this case, the user has selected 4 columns to be printed. The generated macro variables for these values are named varList_1_name, varList_2_name, varList_3_name, varList_4_name.

 

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

One strategy when selecting multiple columns involves iterative processing using the macro language %DO statement to list all of the columns selected, separated by a space, for example,

GR_2_ColumnSelectorControlOldMacroPrint.png

  

 

From SAS Studio 2022.12 and onwards

From SAS Studio version 2022.12, you can use the new macro variable generated that simply lists all of the columns selected, separated by a space.

GR_3_ColumnSelectorControlNewMacro.png

 

The macro variables generated previously (varList_n_name) are still generated so existing custom steps are not impacted but having one macro variable that lists the values makes coding much simpler to develop and maintain!

GR_4_ColumnSelectorControlNewMacroPrint.png

 

Summary

If you have SAS Studio 2022.12 and onwards, use the generated macro variable that lists the columns selected in the Column Selector control for easier code development and maintenance!

 

From this: To this:

 

 

Happy Coding!

 

Check these articles for more information on custom steps:

Viya 2020.1.5 (April 2021) – Introducing Custom Steps in SAS Studio Flow

SAS Viya: Stand-Alone Custom Steps

 

Version history
Last update:
‎06-27-2023 06:35 AM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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