Condtional Highlighting

A recent question by a user lead led me to experiment with what is often referred to as conditional highlighting. The user wanted to display a bar chart of response by year, where each bar is colored by year, and show a cross hatch pattern on the bars where the sample size is < 30.

We can show the conditional highlighting using the fill patterns included in SAS 9.3. Here is the data where we have computed two additional columns (Group and Value2) based on sample size.

Data:

Now, In the simple case, not using Drug as group, the principles of effective graphics would suggest it is not necessary to use color for each bar by year. So we can use groups to indicate where the sample size is < 30.

Most styles do not have fill patterns included in the graph data elements. Only Journal2 and Journal3 have these enabled by default. However, you can certainly derive your own style and enable fill patterns as shown below.

But what if we have a cluster grouped bar chart with "Drug" as the group variable? How do we add the conditional highlighting? Let us start with the basic cluster grouped bar chart of Response by Year and Drug. See graph below.

Now, we want to add a layer on top of this using the cross hatched fill pattern based on sample size. To do this, we compute another column "Value2" which has the same values as "Value" when the sample size is < 30. For sample size >= 30, the "Value2" is missing. We will overlay a bar chart on top of the previous, using Value2 as the response. Bars will only be drawn where the data is not missing.

We turn on the display of fill patterns and turn off the fill colors as follows.

Note, in the above code, the third BarChart statement is used only to allow us to generate a separate legend entry. The bar width of this bar chart is set to zero. We can add a data skin to enhance the visual appearance.