BookmarkSubscribeRSS Feed

SAS Visual Analytics: A look at the new Expression Editor (Part 2)

Started ‎03-07-2024 by
Modified ‎03-07-2024 by
Views 202

In Part 1 of this series, I focused on the point-and-click instructions for building expressions. In Part 2, this article, I will demonstrate the coding features.

 

The new Expression Editor was first introduced in Stable 2023.06 (June 2023) and included in the LTS 2023.10 (November 2023) release. There are some noticeable changes to previous versions and I wanted to go through some tips and tricks for using the new editor.

 

I know I used the quote from Paul Cezanne, "It’s so fine and yet so terrible to stand in front of a blank canvas" to relate to those who dislike the daunting task of putting something into a blank window. But there are those that enjoy the blank slate and jump right in. I like the Vincent van Gogh quote, "Just slap anything on when you see a blank canvas staring you in the face like some imbecile." But also Stephen Sondheim’s, "White. A blank page or canvas. So many possibilities." from the musical Sunday in the Park with George.

 

This is what the new Expression Editor can offer: the flexibility to code using SAS syntax, structure and document using your preferred style. Here are some of the features available in the new Expression Editor:

 

  • suggestion lists for data items, operators, functions
  • inline help for operators and functions
  • add comments
  • reformat your code (Available Stable 2024.01 (January 2024))

 

Let’s take a look at the same expressions that I showed you how to build using the point and click options in Part 1 of this series, but this time, using code.

 

 

Subtraction Expression

 

To build the subtraction expression using the point and click method, it took roughly eight steps. Let’s take a look if we just start typing. (Hint: it’s less than eight and I was over generous with the numbering.) Here the expression we will build. The text highlighted in yellow is what I manually typed.

 TP_01_SimpleSubtractionExpression.png

 

First, I added a comment line and then started typing the name of the data item. As soon as I started typing the name of the data item, you can see the drop-down list of suggestions. I see the data item I want at the bottom, so I used my mouse to click on Unit Yield (target). You could also have arrowed down and press enter to have the data item added to the expression.

 

TP_02_Subtraction01.png

 

Next, I typed the subtraction operator and I started typing the name of the next data item I wanted to add to the expression. You can either use your mouse to click on the suggested data item or your can use your arrows and press enter.

 

TP_03_Subtraction02.png

 

Done in four steps! Coding a simple expression is very fast and straight forward if you know the name of your data items!

 

TP_04_Subtraction03.png

 

 

IF... Else WITH In Condition Expression

 

This next expression, If... Else, is extremely customizable and one of the few with no auto complete available. The SAS syntax, which you can see below, is straight forward and similar to other programming languages; therefore, quite easy to type freehand.

 

And one of the extremely nice things about this expression editor, is that even if you start typing you can always use the point-and-click functionality. There is no suggested list for actual data values, so you can use the Edit functionality that will open the expression builder to see a list of data values so you don’t have to worry about getting the case correct when typing.

 

TP_05_IfElseWithInCondition.png

 

First, I type If and parenthesis then the data item name Product. I select the data item Product from the suggested list. Remember, the text highlighted in yellow is what I manually typed.

 

TP_06_IfElse01.png

 

Next, I start typing for the function In and select it from the suggested list.

 

TP_07_IfElse02.png

 

Finally, I type the rest of the expression. There is no suggested list of data item values when typing like there is with the point-and-click wizard.

 

TP_08_IfElse03.png

 

And available starting in Stable 2024.01 (January 2024) release is the ability to reformat your code for greater readability. You can use the right-click menu or the key combination Shift + Alt + F.

 

TP_09_ReformatCode01.png

 

TP_10_ReformatCode02.png

 

Typing the If... Else expression took four steps as opposed to the seven steps when using the point-and-click method. Here’s a demo of coding the If... Else expression.

 

 

 

Ratio with Sum numerator and AggregateTable denominator Expression

 

Like in the previous post, this last expression I want to build comes from the article: SAS Visual Analytics Report Example: Percent of Total – For All, For Rows, and For Columns.

 

The need to find a column’s percent of total has been popular recently, so let’s take a look how we would build this using the new expression editor. Feel free to read the entire article, but here are the expressions we will need to build using the new expression editor.

 

TP_12_Column_Expression_Example.png

 

And here is my screenshot of the solution using the previous expression editor.

 

TP_13_Previous_Column_Expression.png

 

Here is a screenshot of the solution using the new expression editor.

 

TP_14_New_Column_Expression.png

 

Since this one is straight typing and using the suggested auto complete, here’s the demonstration.

 

 

 

Conclusion

 

I hope that you now feel comfortable to dive right into the new Expression Editor and start typing. Here’s a summary of some of the features that will make building expression using code easier:

 

  • suggestion lists for data items, operators, functions
  • inline help for operators and functions
  • add comments
  • reformat your code (Available Stable 2024.01 (January 2024))

 

 

Find more articles from SAS Global Enablement and Learning here.

Version history
Last update:
‎03-07-2024 12:39 PM
Updated by:
Contributors

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