Sample 38397: Ensuring consistent colors in graphs in SAS® Web Report Studio reports
Overview
When creating graphs in SAS Web Report Studio, you might want to assign a fixed color for certain values in their data. This task can sometimes be difficult when all the values of the data are not included in each group value.
For example, the following pie charts do not contain the same pie slice colors for flavors. SAS Web Report Studio assigns the colors based on the values in the pie chart.
Note: This report has a filter applied on the GRP data item.
This sample uses an information map that was created using the data set called ICECREAM. The data set can be created by using the code on the Full Code tab.
Prepare the data
In order to make sure that each pie chart contains the same legend value and colors, you first create a dummy data set that contains all of the values, and then you combine that data set with the original one.
Note: The rank variable is very small compared to the original value so that it does not show up in the pie chart.
data dummy;
input @1 flavor $10. @12 rank 5.4 @18 grp $1.;
datalines;
Strawberry .0001 B
Chocolate .0001 B
Vanilla .0001 B
Coffee .0001 B
Strawberry .0001 A
Chocolate .0001 A
Vanilla .0001 A
Coffee .0001 A
Strawberry .0001 C
Chocolate .0001 C
Vanilla .0001 C
Coffee .0001 C
;
/* Combine the data sets so that there is a value for every grp */
data test.newicecream;
set test.icecream dummy;
run;
end
|
Use the new data in a report
Use the Data Library Manager plug-in to SAS® Management Console to register the NEWICECREAM data set. Then, create an information map based on the new data set, and use that information map in your report. Here is how the colors now appear.
Tip: Make sure that the Combine minimal values into a slice labeled "Other" is not checked on the Pie tab of the Properties dialog box for your graph object.
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, edit the LIBNAME statement to use your site-specific physical location.
/* Create the IceCream data set */
LIBNAME test BASE "c:\data";
data test.icecream;
input @1 flavor $10. @12 rank 1. @14 grp $1.;
datalines;
Strawberry 2 B
Chocolate 1 B
Vanilla 3 B
Strawberry 2 A
Vanilla 1 A
Coffee 1 C
Vanilla 3 C
Chocolate 2 C
;
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.
When creating graphs in SAS Web Report Studio, you might want to assign a fixed color for certain values in their data. This task can sometimes be difficult when all the values of the data are not included in each group value. This sample shows you how to maintain pattern colors.
Date Modified: | 2010-02-01 14:19:35 |
Date Created: | 2010-01-14 10:04:22 |
Operating System and Release Information
SAS System | SAS Web Report Studio | Microsoft Windows Server 2003 Enterprise Edition | 4.2 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 4.2 | | 9.2 TS2M0 | |
Microsoft® Windows® for x64 | 4.2 | | 9.2 TS2M0 | |
64-bit Enabled Solaris | 4.2 | | 9.2 TS2M0 | |
Windows Vista | 4.2 | | 9.2 TS2M0 | |
64-bit Enabled AIX | 4.2 | | 9.2 TS2M0 | |
HP-UX IPF | 4.2 | | 9.2 TS2M0 | |
Microsoft Windows XP Professional | 4.2 | | 9.2 TS2M0 | |
Microsoft Windows Server 2003 Standard Edition | 4.2 | | 9.2 TS2M0 | |
Linux for x64 | 4.2 | | 9.2 TS2M0 | |
Solaris for x64 | 4.2 | | 9.2 TS2M0 | |