When I'm about to make a major purchase, I appreciate being able to compare products features at a glance, side by side. I am sure you have seen these ubiquitous comparison tables with check marks showing which features are characteristic of different products and which are not.
Related blog post: How to compare SAS data tables for common/uncommon columns
These data visualizations, sometimes called comparison matrixes, are also commonly known as checklist tables or checklist table charts. Such charts are extremely useful, persuasive visuals as they allow us to quickly identify differences as well as commonalities between comparable products or solutions and quickly decide which one of them is more desirable or suitable for our needs.
For example, here is such a table that I created in MS Word:
SAS code to create checklist table chart
Thanks to SAS’ ability to use Unicode characters in formatted data, it’s very easy to create such a checklist table in SAS. Just imagine that each cell with visible check mark is assigned value of 1 and each cell with no check mark is assigned value of 0. That is exactly the data table that lies behind this data visualization. To print this data table with proper formatting, we will format number 1 to a more visually appealing check mark, and 0 to a “silent” blank. Here is the SAS code to accomplish this:
data CHECKLIST; length FEATURE $10; input FEATURE $1-10 A B C; label FEATURE = 'Feature' A = 'Product A' B = 'Product B' c = 'Product C'; datalines; Feature 1 1 1 1 Feature 2 1 0 1 Feature 3 0 1 1 Feature N 1 0 1 ; proc format; value chmark 1 = '(*ESC*){unicode "2714"x}' other = ' '; value chcolor 1 = green; run; ods html path='c:\temp' file='checklist1.html' style=HTMLBlue; proc print data=CHECKLIST label noobs; var FEATURE / style={fontweight=bold}; var A B C / style={color=chcolor. just=center fontweight=bold}; format A B C chmark.; run; ods html close; |
If you run this SAS code, your output will look much as the one above created in MS Word:
Key elements of the SAS code that produce this checklist table are user-defined formats in the PROC FORMAT. You format the values of 1 to a Unicode 2714 corresponding to a checkmark character ✔ in a user-defined format chmark. Also, the value of 1 is formatted to green color in the chcolor user-defined format. The syntax for using Unicode symbols in user-defined formats is this:
value chmark
1 = '(*ESC*){unicode "2714"x}'
NOTE: ESC here must be upper-case; x at the end stands for “hexadecimal.”
Unicode characters for checklist tables
Unicode or Unicode Transformation Format (UTF) is an international encoding standard by which each letter, digit or symbol is assigned a unique numeric value that applies across different platforms and programs. The Unicode standard is supported by many operating systems and all modern browsers.
It is implemented in HTML, XML, Java, JavaScript, E-mail, ASP, PHP, etc. The most commonly used Unicode encodings standards are UTF-8 and UTF-16. HTML 5 supports both UTF-8 and UTF-16.
You can use this HTML Unicode (UTF-8) Reference to look up and choose symbols you can embed in your report using SAS user-defined formats. They are grouped by categories to make it easier to find the ones you needed.
Here is just a small random sample of the Unicode symbols and their hexadecimal representations that can be used to spice up your checklist tables to get their different flavors:
You can also apply colors to all these symbols the way we did it in the SAS code example above.
Different flavors of checklist tables
By just changing user-defined formats for the symbol shapes and colors we can get quite a variety of different checklist tables.
For example, we can format 0 to ✘ instead of blank and also make it red ✘ to explicitly visualize feature exclusion from product (in addition to explicit inclusion). All we need to do is to modify our PROC FORMAT to look like this:
proc format; value chmark 1 = '(*ESC*){unicode "2714"x}' 0 = '(*ESC*){unicode "2718"x}'; value chcolor 1 = green 0 = red; run; |
SAS output comparison matrix will look a bit more dramatic and persuasive:
Or, if you’d like, you can use the following format definition:
proc format; value chmark 1 = '(*ESC*){unicode "2611"x}' 0 = '(*ESC*){unicode "2612"x}'; value chcolor 1 = green 0 = red; run; |
producing the following SAS-generated ballot-like table checklist:
Here is another one:
proc format; value chmark 1 = '(*ESC*){unicode "1F5F9"x}' 0 = '(*ESC*){unicode "20E0"x}'; value chcolor 1 = green 0 = red; run; |
producing the following variation of the checklist table:
As you can see, the possibilities are endless.
Your thoughts?
Do you find these comparison matrixes or checklist tables useful? Do you envision SAS producing them for your presentation, documentation, data story or marketing materials? What Unicode symbols do you like? Can you come up with some creative usages of symbols and colors? For example, table cells background colors...
Related blog post: How to compare SAS data tables for common/uncommon columns
8 Comments
This blog is very helpful and provides lots of good information for us to start using checkmarks in our report. This blog saved us a lot of time researching the format definition. Great work Leonid and thanks for the nice summary of information.
Thank you for such a great feedback, Tingting! I am so glad it turned out to be so helpful.
Great stuff, Leonid!
Thank you, Robert. I hope you will put it to good use.
Good coverage on this! I'll bet your post on this topic gets more traffic than mine. People are more likely to search for "SAS checklist" than "SAS harvey balls." Or maybe even "SAS sneetches".
Thanks Chris. Same simple SAS format-based coding technique, - totally different functionality from the data consumer perspective.
Leonid,
This blog post is a great example of something that would be difficult or impossible using many other types of software, but is easy with SAS. The solution is advanced and yet simple enough that a beginner could follow it. I confess that I have never needed to insert check marks in my output, but now that I have your simple example to follow, I will be looking for chances to do it. Sweet!
Susan
Thank you, Susan! We usually do not need something until we know it exists 🙂