BookmarkSubscribeRSS Feed

Leveraging Unicode in SAS Visual Analytics Reports

Started ‎10-06-2021 by
Modified ‎10-06-2021 by
Views 4,805

How can I add shapes or symbols to tabular visualizations to indicate trends, create a traffic light, or simply highlight an item of interest? I hear this question relatively often, and the answer can sometimes be very simple.

 

You might be thinking that there might be something in display rules that does exactly this, and you are right. This feature exists as gauge-based display rules in SAS Visual Analytics, which is available for List Table objects, but it’s limited to just a few different symbols, such as bullet, icon, slider, and thermometer:

Figure 01 - Gauge display rule windowFigure 01 - Gauge display rule window

 

What if you want to use a different symbol? The answer is Unicode.

 

Unicode is a standard that maps every character and symbol for most of the writing systems in the world to a code. We are talking about more than 144 thousand characters, covering a long list of alphabets, but there are also math, currency, transport, and other symbols, geometric shapes, emojis, game symbols such as playing cards, domino tiles, etc. The standard is evolving continuously, and new code points are added on every new release. By the time this article was written, Unicode 14.0 was the latest version and this version alone included 838 new characters/symbols. The visual representation of the Unicode character/symbol is called a glyph. Unicode does not define how glyphs are rendered, neither specify their style, size, or shape. The software and/or hardware-rendering engine is responsible for their appearance. Most of the glyphs are black & white, but there are a few colored ones too, and chances are high that you will find something there that suits your needs. You can find a list of all supported characters in the Unicode web site.

 

Here are a few examples of Unicode symbols:

∑ ± ∫ ≢ ∞

¥ ₿ £

➮ ⮊ ⮉ ⮃

▲ ● ■

🃁  🃓  🂽

🁺 🂃 🂎

♞ ♜ ♘ ♔ ♟

🚗 🚁 🚜

🚹 🚺 🚻 🚼

🚶 👫 🚸

😃 😐 😦

🥇 🥈 🥉 🏆

🔴 🔵 🔶 🔻

 

The way you add a Unicode character to your application may vary. For example, in a Microsoft Word document, you would type the character code, press ALT, and then press X, but other Microsoft programs such as PowerPoint, cannot convert Unicode codes to characters using this method, so you would need to use Windows Character Map to enter the characters via copy & paste. There are also online resources like https://unicode-table.com/ that provides search and copy & paste capabilities.

 

But how can you use Unicode when designing reports in SAS Visual Analytics? Well, it turns out that you can leverage Unicode anywhere you can have characters. For example, you can add Unicode characters directly in text objects, object’s titles, expression builders that you use to create calculated character items, etc.

 

Figure 02 - Examples of Unicode in VA reportFigure 02 - Examples of Unicode in VA report

 

 

Using Unicode in expressions is the most exciting in my opinion. This means that you can create a calculation that returns the symbol that you want depending on the rules that you define, such as up and down arrows, to indicate trends or classify as good or bad, and add them to your List Table, as showed above.

 

This is an example of expression for the Unicode arrows:

Figure 03 - Example of expression for Unicode arrowsFigure 03 - Example of expression for Unicode arrows

 

SAS Visual Analytics interface is one of those that don’t allow for adding Unicode characters using the ALT-X method as described earlier. You need to copy & paste the character from a resource. I personally like the web site https://unicode-table.com/ because of its search capabilities and the additional information it provides.

 

In this example, the Unicode values were extracted from the links below (just select the symbol, then use the copy button and paste it into the SAS Visual Analytics expression builder):

Upwards Arrow with Equilateral Arrowhead: U+1F815 - Unicode Character Table (unicode-table.com)

Downwards Arrow with Equilateral Arrowhead: U+1F817 - Unicode Character Table (unicode-table.com)

 

If the symbols you are using are black & white, like the arrows used in this example, you can still apply display rules to change their colors as needed, and obtain the results seen in the List Table above:

Figure 04 - Display rule to apply color to Unicode arrowFigure 04 - Display rule to apply color to Unicode arrow

 

If the symbols are already colored, the expression is all you need:

Figure 05 - Example of colored Unicode in VAFigure 05 - Example of colored Unicode in VA

 

🔴 - Large Red Circle Emoji: U+1F534 - Unicode Character Table (unicode-table.com)

🟢 - Large Green Circle Emoji: U+1F7E2 - Unicode Character Table (unicode-table.com)

 

Because those expressions return characters, you can only use this calculated item in roles that accept categories. In Crosstabs it would have to be added in rows or columns roles:

 

Figure 06 - Example Unicode in crosstabFigure 06 - Example Unicode in crosstab

 

Pretty nice, right? Now the downside of it: not necessarily every Unicode character/symbol you find will be displayed as expected.

 

In some cases, a “notdef” glyph may be rendered to indicate a missing glyph. Those cases are normally represented as an empty box, a question mark inside a box, etc. I’m not an expert in Unicode, but my understanding is that this happens when the Unicode version supported by the software or the hardware-rendering engine does not yet support that character. Take the roller skate symbol from this page for example:

Roller Skate Emoji: U+1F6FC - Unicode Character Table (unicode-table.com)

Figure 07 - Roller skate UnicodeFigure 07 - Roller skate Unicode

 

If you try to add it to your SAS Visual Analytics report via Chrome or Edge browsers, you get this: 🛼

 

But if you use Firefox or open that same report in the SAS Visual Analytics app for iOS, you see the roller skate glyph. Firefox will render the Twitter-style glyph and the iOS mobile app will render the Apple-style glyph, as indicated on that web page. The opposite might happen too: as a report designer, you may be able to add a symbol into your report, but mobile users may not be able to see it as expected. The arrows used in the beginning of this article is an example of that – they don’t render in the SAS Visual Analytics app for iOS.

 

The red and green circles used in the calculated item Good/Bad explored earlier work just fine in all SAS Visual Analytics supported browsers, but they will be rendered in black & white in SAS Visual Analytics app for iOS. In this particular case, you can easily fix that by assigning display rules like we did before for the arrows, so applying display rules becomes a best practice whenever colors are important, even if your glyph is colored. That easy fix, unfortunately, does not work for the previous crosstab example, because display rules are only applicable for measures.

 

There is no doubt that leveraging Unicode characters/symbols in SAS Visual Analytics reports brings some new and interesting possibilities, but knowing that what gets displayed is affected by a combination of factors that you cannot control, you, as a report designer, must guarantee the report consumers’ experience is preserved, by making sure the glyphs are properly rendered in all browsers and platforms they may be using to view the report.

Version history
Last update:
‎10-06-2021 10:28 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