Sample 40747: Conditionally highlighting category values in SAS® Web Report Studio
Overview
Beginning with SAS Web Report Studio 4.31_M2, you can create conditional highlighting rules that are based on character categories. If you want to create rules based on numeric categories, or if you are using an earlier version of SAS Web Report Studio, this sample explains how you can use the Display as hyperlink feature with a CASE expression in order to conditionally highlight category values. Two examples are included:
- a simple example that highlights fixed values.
- a more advanced example that highlights nonspecific values.
Note: The Display as hyperlink feature is available only for relational data.
Before you begin
This sample explains how to edit the expression for a data item to include HTML tags. When you enter the tagging in this way, the highlighting is not preserved when you use the SAS® Add-In for Microsoft Office to open the report directly using Microsoft Office. It is also not preserved when you open the report in SAS® Enterprise Guide®. Instead, you see the HTML tags. In addition, the highlighting might not be preserved when you export from SAS Web Report Studio. The exact behavior in SAS Web Report Studio depends on which version you are using. For more information, see SAS Note 50643.
About the sample data
The information map used in this sample is based on the Exercise data set, which is one of the sample data sets installed with SAS® Enterprise Guide®.
To create the Exercise information map, you can submit the PROC INFOMAPS code on the Full Code tab in this sample. The steps in the sample refer to this information map.
Conditionally highlight fixed values
The goal of this example is to highlight whether the subject stretched before exercising. The two values for the Prestretch variable are "No stretch" and "Stretch." "No stretch" should appear in red text and "Stretch" should appear in green text.
- In SAS Information Map Studio, open the Exercise information map.
- Right-click on the Prestretch data item and select Properties.
- On the Definition tab, click the Edit button under Expression Settings.
- In the Expression Text box enter an expression similar to the following.
case <<Exercise.PreStretch>>
when "No stretch" then "<font color='red'>No stretch</font>"
when "Stretch" then "<font color='green'>Stretch</font>"
else <<Exercise.PreStretch>>
end
|
- Click Validate Expression to verify that the syntax is correct.
- Click OK to save the changes and return to the Data Item Properties dialog box.
- Click the Classifications, Aggregations, Formats tab.
- Make sure the Format is set to Default.
- Beneath the Format name list, select the Display as hyperlink option.
- Click OK to close the Data Item Properties dialog box.
- Click Close twice to close all dialog boxes, then save the information map.
- Select Tools ► Run a Test Query and make sure you are getting the expected results.
Tip: If the test query returns an empty column for Prestretch, then increase the length of the data item.
The following steps explain how to see the results in SAS Web Report Studio:
- Log into SAS Web Report Studio as a user who can create new reports.
- Select File ► New ► Report.
- Select Data ► Select Data.
- In the Select Data Source dialog box, navigate to the Exercise information map, click OK, and then select all data items.
- Insert a list table into the layout.
- Click View to view the results, which should be similar to the following display.

Conditionally highlight nonspecific values
The goal of this example is to highlight the value of the Prestretch variable in red if the value of AnkleWeights is "Weights" and the Energy value is greater than 105. Otherwise, the value of Prestretch is unchanged. In this example, the value of Prestretch within the HTML tags is nonspecific rather than fixed.
- In SAS Information Map Studio, open the Exercise information map.
- Right-click on the Prestretch data item and select Properties.
- On the Definition tab, click the Edit button under Expression Settings.
- In the Expression Text box enter an expression similar to the following.
case
when <<Exercise.AnkleWeights>> = "Weights" and <<Exercise.Energy>> > 105
then "<font color='red'>"!! <<Exercise.PreStretch>> !!"</font>"
else <<Exercise.PreStretch>>
end
|
- Click Validate Expression to verify that the syntax is correct.
- Click OK to save the changes and return to the Data Item Properties dialog box.
- Click the Classifications, Aggregations, Formats tab.
- Make sure the Format is set to Default.
- Beneath the Format name list, select the Display as hyperlink option.
- Click OK to close the Data Item Properties dialog box.
- Click Close twice to close all dialog boxes, then save the information map.
- Select Tools ► Run a Test Query and make sure you are getting the expected results.
Tip: If the test query returns an empty column for Prestretch, then increase the length of the data item.
The following steps explain how to see the results in SAS Web Report Studio:
- Log into SAS Web Report Studio as a user who can create new reports.
- Select File ► New ► Report.
- Select Data ► Select Data.
- In the Select Data Source dialog box, navigate to the Exercise information map, click OK, and then select all data items.
- Insert a list table into the layout.
- For this example, select Data ► Summarization Options, and select Show every row (Detail data).
- Click View to view the results, which should be similar to the following display. Notice that two different values of Prestretch are highlighted.

Additional Documentation
For more information about SAS Web Report Studio, see the SAS Web Report Studio documentation page.
For more information about SAS Information Map Studio, see the SAS Information Map Studio documentation page.
For more information about SAS Management Console, see the SAS Management Console documentation page.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Before submitting this code, these tasks must be done:
- The EXERCISE table and its library (in this sample, EGSAMPS) must be registered in metadata.
Note: For information about registering libraries and tables, see Establishing Connectivity to a Library of SAS Data Sets.
- The location of the information map (specified by mpath) and the PROC INFOMAPS statement must be modified to use the correct values for your environment.
- After you initially create the information map, remove the comment tag from the DELETE statement for subsequent submissions.
%let mpath=/Shared Data/your-map-folder;
proc infomaps metauser="your-userID"
metapass="your-password"
metaserver="your-metadata-server.com"
metaport=8561
metarepository=Foundation
mappath="&mpath";
* delete infomap "Exercise";
new infomap "Exercise";
insert datasource
sasserver="SASApp"
table="egsamps"."Exercise" _all_;
save;
* list _all_;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Beginning with SAS Web Report Studio 4.31_M2, you can create conditional highlighting rules that are based on character categories. If you want to create rules based on numeric categories, or if you are using an earlier version of SAS Web Report Studio, this sample explains an alternative method.
Date Modified: | 2012-03-23 15:13:14 |
Date Created: | 2010-08-31 15:13:32 |
Operating System and Release Information
SAS System | SAS Information Map Studio | Microsoft® Windows® for 64-Bit Itanium-based Systems | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows XP 64-bit Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Datacenter Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Enterprise Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Standard Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2008 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2008 for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows XP Professional | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Enterprise 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Enterprise x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Home Premium 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Home Premium x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Professional 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Professional x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Ultimate 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Ultimate x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows Vista | 4.2_M2 | | 9.2 TS2M3 | |
Windows Vista for x64 | 4.2_M2 | | 9.2 TS2M3 | |
SAS System | SAS Web Report Studio | z/OS | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft® Windows® for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Datacenter Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Enterprise Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 Standard Edition | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2003 for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2008 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows Server 2008 for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Microsoft Windows XP Professional | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Enterprise 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Enterprise x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Home Premium 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Home Premium x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Professional 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Professional x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Ultimate 32 bit | 4.2_M2 | | 9.2 TS2M3 | |
Windows 7 Ultimate x64 | 4.2_M2 | | 9.2 TS2M3 | |
Windows Vista | 4.2_M2 | | 9.2 TS2M3 | |
Windows Vista for x64 | 4.2_M2 | | 9.2 TS2M3 | |
64-bit Enabled AIX | 4.2_M2 | | 9.2 TS2M3 | |
64-bit Enabled Solaris | 4.2_M2 | | 9.2 TS2M3 | |
HP-UX IPF | 4.2_M2 | | 9.2 TS2M3 | |
Linux for x64 | 4.2_M2 | | 9.2 TS2M3 | |
Solaris for x64 | 4.2_M2 | | 9.2 TS2M3 | |