SAS Graphics for Java ®
Examples Using SAS AppDev Studio and the Output Delivery System ®
Wendy Bohnenkamp Jackie Iverson
™
The correct bibliographic citation for this manual is as follows: Bohnenkamp, Wendy, and Jackie Iverson. 2007. SAS® Graphics for Java: Examples Using SAS® AppDev Studio™ and the Output Delivery System. Cary, NC: SAS Institute Inc. SAS® Graphics for Java: Examples Using SAS® AppDev Studio™ and the Output Delivery System Copyright © 2007, SAS Institute Inc., Cary, NC, USA ISBN 978-1-59047-693-2 All rights reserved. Produced in the United States of America. For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. For a Web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication. U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. 1st printing, May 2007 SAS® Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hardcopy books, visit the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228. ® SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.
Contents Acknowledgments Introduction
ix
xi
Part 1
SAS AppDevStudio
1
Chapter 1
Getting Started with SAS AppDev Studio
3
1.1 Tag Libraries for SAS AppDev Studio 3 1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project 8 1.3 Your Data 10 1.3.1 Tips and Information 11
Chapter 2
SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 13 2.1 SAS AppDev Studio 2 Tags 15 2.1.1 sasads:Bar 15 2.1.2 sasads:Combination 16 2.1.3 sasads:Pie 16 2.1.4 sasads:Scatter 17 2.1.5 sasads:SegmentedBar 17 2.2 SAS AppDev Studio 3 Tags 18 2.2.1 sas:BarChart 18 2.2.2 sas:BarLineChart 19 2.2.3 sas:LineChart 20 2.2.4 sas:LinePlot 21 2.2.5 sas:PieChart 22 2.2.6 sas:RadarChart 23 2.2.7 sas:ScatterPlot 24 2.3 Common Attributes 25
iv Contents
Chapter 3
SAS AppDev Studio 3 Graph Model Tags 39 3.1 3.2 3.3 3.4 3.5 3.6 3.7
Chapter 4
BarChartModel 40 BarLineChartModel 50 LineChartModel 64 LinePlotModel 67 PieChartModel 74 RadarChartModel 87 ScatterPlotModel 92 3.7.1 Baselines 97
Nested Tags for Graph Models
99
4.1 Axis Models 100 4.1.1 Response Axis Baseline Models 107 4.1.2 Corresponding Graph Models 108 4.1.3 Column and Row Axis Models 110 4.2 Legends 111 4.2.1 Corresponding Graph Models 113 4.3 Line Style Tags 113 4.3.1 Corresponding Graph Models 116 4.4 Text Style Tags 116 4.4.1 Corresponding Graph Models 117 4.5 AxisWallModel 118 4.6 BackgroundFillStyle 119 4.6.1 Corresponding Graph Models 122 4.7 DataElementStyle 123 4.8 DataTipModel 123 4.9 SubgroupLabelModel 124
Chapter 5
Supporting Tags
125
5.1 Fill Tags 126 5.2 Line Tags 130 5.2.1 AxisLineStyle, GridLineStyle, StrokeLineStyle, FrameLineStyle, and OutlineLineStyle 5.2.2 BasicStroke 133
Contents v
5.3 Text Tags 133 5.3.1 Font 133 5.3.2 LabelTextStyle and ValueTextStyle 134 5.3.3 TextStyle 136 5.3.4 ShadowStyle 136 5.4 Tick Mark Tags 136 5.5 Miscellaneous Tags 137 5.5.1 DiscreteFillColor 137 5.5.2 MarkerStyle 137 5.5.3 ReferenceLineModel 140
Part 2 Chapter 6
Output Delivery System
Important Concepts for Getting Started with ODS and Java 145 6.1 6.2 6.3 6.4 6.5
Chapter 7
143
Java Scriptlet Code 146 General JSP Structure 146 General JSP Requirements 148 Connecting and Data Extraction 148 A Few Last Notes about Data 151
Creating Graphs
153
7.1 Types of Bar Charts 154 7.1.1 Horizontal Bar Charts 154 7.1.2 Vertical Bar Charts 155 7.2 Types of Pie Charts 156 7.2.1 Pie Charts 157 7.2.2 Donut Charts 158 7.2.3 Star Charts 159 7.3 Contour Plots 159 7.4 Types of Maps 160 7.4.1 Block Maps 160 7.4.2 Choropleth Maps 161 7.4.3 Prism Maps 162 7.4.4 Surface Maps 163 7.5 Types of Plots 163 7.5.1 Bubble Plots 164 7.5.2 Plots 165
vi Contents
7.6 Three-Dimensional Graphs 166 7.6.1 Scatter Plots 166 7.6.2 Surface Plots 167
Chapter 8
Parameters for Colors 169 8.1 ODS Parameters 170 8.1.1 Non-supported parameters 181 8.2 GOPTIONS 182 8.2.1 Non-supported options 186 8.3 PROC GCHART 186 8.3.1 Summary 192 8.3.2 Non-supported parameters 193 8.4 PROC GCONTOUR 193 8.4.1 Summary 197 8.5 PROC GMAP 197 8.5.1 Summary 199 8.6 PROC GPLOT 199 8.6.1 Summary 204 8.7 PROC G3D 204 8.7.1 Summary 205 8.7.2 Non-supported parameters 205
Chapter 9
Parameters for Text
207
9.1 ODS Parameters 208 9.1.1 Non-supported parameters 213 9.2 GOPTIONS 214 9.2.1 Non-supported parameters 217 9.3 PROC GCHART 217 9.3.1 Summary 225 9.3.2 Non-supported parameters 226 9.4 PROC GCONTOUR 227 9.4.1 Summary 231 9.5 PROC GMAP 232 9.5.1 Summary 234 9.6 PROC GPLOT 234 9.6.1 Summary 238
Contents vii
9.7 PROC G3D 239 9.7.1 Summary 240
Chapter 10 Other Parameters
241
10.1 PROC GCHART 242 10.1.1 Summary 264 10.1.2 Non-supported parameters 10.2 PROC GCONTOUR 268 10.2.1 Non-supported parameters 10.3 PROC GMAP 273 10.3.1 Summary 277 10.3.2 Non-supported parameters 10.4 PROC GPLOT 278 10.4.1 Summary 289 10.4.2 Non-supported parameters 10.5 PROC G3D 290 10.5.1 Summary 298 10.5.2 Non-supported parameters
Part 3
Putting It Together
Chapter 11 Final Reports
267 272
278
289
298
299
301
11.1 Report 1: Using SAS AppDev Studio 3 Tags 301 11.2 Report 2: Using ODS 307 11.3 Conclusions 310
Appendix A
SAS/GRAPH Samples and WORK Data Sets
References
315
Index
317
313
viii
Acknowledgments Thanks to Aimee for inspiration, Andrew for support, Jackie for courage, Mom for believing, and the readers for their interest. Wendy Bohnenkamp
Until I started this, I never knew just how much time and effort go into writing a book. This is hard work, and I first have to say thank you to Wendy for putting up with me as a writing partner. Without her knowledge, skill, and drive, this book would never have been finished. Next, I need to thank my family for their encouragement and support. And finally, I have to say thanks to the people who buy this book. If the examples in this book make their job easier, then it will have been worth the effort. Jackie Iverson
x
Introduction The idea for this book started glimmering every time we would lament to each other about the lack of good examples. The conversation always ended with “someone should write a book.” This book is intended to be that source for examples. We walk you though the basics and ® help to get you familiar with things that may be new to you or new to SAS 9. The book can be used by programmers at all experience levels. This book covers only the graph objects in SAS AppDev Studio, and it is assumed that you already know how to use SAS AppDev Studio to create and deploy a JavaServer Page (JSP) or servlet application. A basic level of SAS ODS programming knowledge is also needed to understand the example code in Part 2. ®
SAS 9 and SAS AppDev Studio 3 were released while we were writing this book. All ® examples have been tested on SAS 9. SAS AppDev Studio contains both the older version of graph custom tags as well as the new versions. Therefore we briefly cover version 2 tags, but concentrate more on the version 3 tags. There are many parameters and attributes to cover, so the intent is to provide a reference tool to help you build your own graphs. We’ve focused on what we feel are the two main ® ways programmers are using SAS 9 to create graphs using Java. There are four main sections to this book. The first is what you are reading now. Just a “Hi how are you?” and a “Here’s the intent of this book.” The second section covers webAF and SAS AppDev Studio. It includes a brief how-to section on using webAF as an Interactive Development Environment (IDE) and briefly discusses SAS AppDev Studio 2 tags and their options. Then it covers the tags and the nesting properties of SAS AppDev Studio 3 tags. The third section is intended for SAS programmers who want to do some reporting but who are not that familiar with custom tags. This section covers using Output Delivery System (ODS) statements and the Java Device Driver to create graphs. Then we wrap everything up in the fourth section to include reference and appendix materials. This book is not intended to give you all the answers to all the questions about SAS graphs. It is also not a “best practice” type of cookbook. We are merely trying to put together a reference volume that enables you to see what you can and cannot do to make your graphs more visually appealing. For instance, when you are combining ODS and JSP files, you get a very diverse environment. We have decided to simplify our examples by putting everything in a single JSP instead of using servlets, macros, stored processes, etc. We wanted to focus on the attributes, parameters, and options that make graphs convey what you really want them to convey.
xii Introduction
Because we are focusing on the look of the graph, we chose data that helped to illustrate the specific graph attribute. This produced graphs that may not represent a real world situation. So don’t get hung up on trying to analyze the graph; just look at what it is trying to show. Appendix A contains data layouts of the SAS samples and WORK data sets that were used to produce the graphs. Most of the time we used data sets from the SAS/GRAPH samples library to make it easy for you to reproduce the graph. Part 3, “Putting It Together,” explains where to find the sample data sets. If we had to create or modify the data to get a particular attribute to show more clearly, we included the SAS code in Appendix A. Each sample that produces output has been tested in our local development environment. We have tried to provide you with information on what works and what may not. We included things that did not work for us, because in your environment or in future updates they could. If you see an option or parameter that you like, give it a try. SAS offers many opportunities for creativity. We hope to give you a jump start on the path to great graphs. Ready to tackle those SAS graphs?
P a r t
1
SAS AppDev Studio Chapter 1 Getting Started with SAS AppDev Studio 3 Chapter 2 SAS AppDev Studio Custom Tags and Attributes for Basic Graphics 13 Chapter 3 SAS AppDev Studio 3 Graph Model Tags 39 Chapter 4 Nested Tags for Graph Models 99 Chapter 5 Supporting Tags 125
2 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
1
Getting Started with SAS AppDev Studio 1.1 Tag Libraries for SAS AppDev Studio 3 1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project 8 1.3 Your Data 10 1.3.1 Tips and Information 11
1.1 Tag Libraries for SAS AppDev Studio In this section we are going to look at creating graphs in a JavaServer Page (JSP) using the SAS Custom Tag Library. This tag library comes with the SAS AppDev Studio product, which includes webAF as the development environment tool. You can use webAF or another Java Interactive Development Environment (IDE), such as Eclipse, to utilize the tag libraries and API components that come with SAS AppDev Studio.
4 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
SAS AppDev Studio 2.x and SAS AppDev Studio 3 use separate tag libraries. SAS AppDev Studio 3 introduced some major enhancements to the graphics components. We’ll look at the most commonly used graphs in each version. The easiest way to add graphs to your JSP or servlet project in SAS AppDev Studio is to use the Component Palette. The graph components are on the Graphics tab. You can change the palette by clicking the down arrow on the toolbar title bar.
We will be working with graphs on the SAS JSP/Servlet (Version 3) and SAS JSP/Servlet (Version 2) palettes. The version 2 tag library is part of SAS AppDev Studio 3. When you create a new SAS AppDev Studio 3 project, you can choose to include the version 2 tag library so that these tags are available in the component palette. When you upgrade an existing webAF 2 project to use webAF 3 components, your old SAS AppDev Studio 2 tags (which have a sasads prefix) will still be in your project and will not be automatically updated to SAS AppDev Studio 3 tags (with a sas prefix). In other words, if you have a sasads:Bar chart in your project, it will not automatically be converted to a sas:BarChart if you move to webAF 3. Here is an overview and comparison of the graphs available in both versions. Remember that sasads tags are from SAS AppDev Studio 2, whereas sas tags are from the more recent SAS AppDev Studio 3. sasads:Bar
sas:BarChart
Chapter 1: Getting Started with SAS AppDev Studio 5
Here is a direct comparison of the default bar charts. Notice that the default for sasads:Bar is a three-dimensional chart, whereas the sas:BarChart is two-dimensional. Both have several options that can enhance the appearance. sasads:SegmentedBar
sasads:Combination
sas:BarLineChart
The sasads:SegmentedBar tag really does not have an equivalent in SAS AppDev Studio 3. However, you can mimic this graph by using the various model attributes with the sas:BarChart tag.
The sasads:Combination tag can be used in several different ways to perform similarly to a sas:BarLineChart, sas:LineChart, or sas:ScatterChart tag.
This sas:BarLineChart tag has no direct partner in SAS AppDev Studio 2 tags.
6 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
sas:LineChart
sasads:Pie
In SAS AppDev Studio 3, line charts can be created using the sas:LineChart tag. In SAS AppDev Studio 2, you might consider using the sasads:Combination tag.
sas:PieChart
As with the bar charts, sasads:Pie defaults to a three-dimensional chart, and sas:PieChart is two-dimensional. Both charts have loads of options to create a number of different looks. Additionally, the sas:PieChart tag can create a donut and subgroup data into concentric rings.
Chapter 1: Getting Started with SAS AppDev Studio 7
sasads:Scatter
sas:ScatterPlot
SAS AppDev Studio 2 includes the sasads:Scatter tag. The equivalent tag in SAS AppDev Studio 3 is sas:ScatterPlot.
sas:LinePlot
The sas:LinePlot tag could be compared to the previously shown SAS AppDev Studio 2 sasads:Combination tag.
8 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
sas:RadarChart
The sas:RadarChart tag is a brand-new graph type for SAS AppDev Studio 3.
1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project There are a couple of things you need to consider before you can add graphs to your project. One is how to connect to the data. In your development environment, everything is local and easy to get to, but in normal production environments that usually isn’t the case. You need to plan your strategy for accessing your SAS server. Is security an issue? How many people will be accessing this application? How many people at the same time might need to grab the same data? All these questions should be discussed with both the Web server and SAS server administrators. These administrative roles may be filled by the same person or by people from different groups. Either way, you must plan and coordinate with them. There are so many variables and combinations of system setup that we can’t cover all of them in this book. For this book, we’ve taken a simple approach and used a basic Java Database Connectivity (JDBC) connection for SAS AppDev Studio 3 tags and SAS/CONNECT for all others. If you need something more elaborate for your environment, review the SAS documentation for SAS Integration Technologies. This resource will help you make decisions on setting up security, pooling, connection types, etc. Now that you have the connection, the next step is to create data models. Data models allow you to shape the data for graphing. For instance, you might need to sort the data alphabetically or by increasing values. Data models can also specify the columns, subset the data, and perform other functions.
Chapter 1: Getting Started with SAS AppDev Studio 9
In SAS AppDev Studio 2, one common method is to use a sasads:DataSet tag. This allows us to use the connection, specify the data, and shape it. Here’s an example: <sasads:DataSet connection="bbuConnection" dataSet="samples.grains" id="dsBar" scope="session" displayedColumns="country amount" />
In this example, we use the bbuConnection object to connect to our SAS server. Then the dataSet attribute is used to define the data set we want to use. Here we are using the Grains data set from the Samples library. Then, to help shape the data, we use the displayedColumns attribute. This allows us to specify only the columns we will be needing for the graph. When using the SAS AppDev Studio 3 tags, we need to use different types of models. These may seem more complicated than simply using the sasads:DataSet tag, but they are more flexible. For sas:BarChart you use a com.sas.graphics.components.barchart.BarChartTableDataModel. Here’s an example:
<jsp:useBean id="barChartTableDataModel1" scope="session" class="com.sas.graphics.components.barchart.BarChartTableDataModel"> <jsp:setProperty name="barChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% barChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("COUNTRY")); barChartTableDataModel1.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); %>
This snippet of code shows the configuration of a data model. It references a JDBCTableModelAdapter and sets properties for the data model, such as the category and response variables to use. See Chapter 11, “Final Reports,” for a complete example with SAS AppDev Studio 3 tags.
10 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
1.3 Your Data When you are using SAS data sets in SAS graphs, there are specific terms used to describe the types of variables. For instance, you may think in terms of an X axis and Y axis. However, because we are looking at statistical or computed variable data, most of the time each variable has a role. On the X axis you may actually be charting data by a category variable. Below are some terms that may help you along the way. Category variable A variable that determines the number and arrangement of bars, slices, lines, etc. Response variable The variable you are trying to understand, explain, or model. Midpoint The value associated with a bar on a bar or block chart or the slice on a pie chart. This is the category variable. Chart variable The data column to be charted. This variable can be character or numeric. Chart statistic Most commonly, the sum of a numeric variable or the frequency (count) of a character variable. Other common statistics are percentages and means. The statistics available vary by type of graph. Midpoint axis The axis that shows the categories of data. Response axis The axis that shows the range of values for the chart statistic. Contiguous variables Variables that contain a range of numeric values that are represented on the chart. For example, dollars or quantities are contiguous variables.
Chapter 1: Getting Started with SAS AppDev Studio 11
Discrete variables Variables that contain a finite number of specific values that are represented on the chart. For example, years, geographical areas, and company divisions are discrete variables. X Used in plots (vertical) to identify the variable on the horizontal axis. Y Used in plots (vertical) to identify the variable on the vertical axis. Z Used in plots (vertical) to identify the depth variable. For more information on terminology and graphing basics, see the SAS OnlineDoc documentation.
1.3.1 Tips and Information Here are a few tips on how to organize your data for maximum performance.
Usually, you should presummarize large data sets to improve performance.
When there are too many values to represent in a pie chart, the smaller values are automatically grouped into one slice labeled “Other.” By creating your own “Other” grouping, you can prevent a smaller, but important, category from being hidden.
When you are accessing SAS data, the system often puts a lock on the data set you are using. For this reason, be sure to close all connection to the data once you are done. Or consider making your connection read-only and investigate how to set up workspace pooling or connection sharing techniques.
If you have a large number of different categories, you might want to subset or group the data to control the number of bars or pie slices shown in the chart. Depending on the size of your chart, it is easy to get so many bars that you cannot read the labels.
In short, the saying “Garbage in, garbage out” is so true. You need to be careful of how your data is constructed and formatted before you base critical decisions on your output.
12 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
2
SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 2.1 SAS AppDev Studio 2 Tags 15 2.1.1 sasads:Bar 15 2.1.2 sasads:Combination 16 2.1.3 sasads:Pie 16 2.1.4 sasads:Scatter 17 2.1.5 sasads:SegmentedBar 17 2.2 SAS AppDev Studio 3 Tags 18 2.2.1 sas:BarChart 18 2.2.2 sas:BarLineChart 19 2.2.3 sas:LineChart 20 2.2.4 sas:LinePlot 21 2.2.5 sas:PieChart 22 2.2.6 sas:RadarChart 23 2.2.7 sas:ScatterPlot 24 2.3 Common Attributes 25
14 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
SAS AppDev Studio gives the user a number of graphing custom tags to use with JSP pages. The tags available in SAS AppDev Studio 2 have been updated in SAS AppDev Studio 3. Although SAS AppDev Studio 2 tags are easier to use because they are not nested, they are limited in what they can and cannot display. You might be tempted at first to run with the SAS AppDev Studio 2 tags, but once you get the hang of SAS AppDev Studio 3 tags, we think you’ll jump right in with both feet. In general, the standard convention for SAS AppDev Studio 3 tags looks like this: <sas:BarChart id="bbuSASBarChart" model="barChartTableDataModel1" scope="session" >
However, if there are no nested tags, you could use the following convention. The difference is that the tag is closed using a single backslash at the end of the invocation of the tag. <sas:BarChart id="bbuSASBarChart" model="barChartTableDataModel1" scope="session" />
Be very careful not to use both conventions at the same time. If you accidently use /> and then have nested tags, the compiler won’t recognize the nested tags as being part of that tag group. If you need to nest tags, use the following convention and insert the nested tags where shown. <sas:BarChart id="bbuSASBarChart" model="barChartTableDataModel1" scope="session" >
Each graph tag has three required attributes. The id attribute gives the object a name. Each object in your scope must have a unique identifier or name. The model attribute specifies the data model. The scope attribute defines the limit of the object’s availability, such as session, request, page, or application. <sas:BarChart id="bbuSASBarChart" model="barChartTableDataModel1" scope="session" >
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 15
2.1 SAS AppDev Studio 2 Tags The following graph examples illustrate the basics of the different graphing custom tags available from SAS AppDev Studio 2. These older tags are still available with SAS AppDev Studio 3. However, as stated before, you might want to convert to the newer SAS AppDev Studio 3 tags. The main difference in syntax between the two is the prefix used for the tags. The prefix “sasads:” denotes AppDev Studio 2 tags, whereas “sas:” denotes SAS AppDev Studio 3 tags.
2.1.1 sasads:Bar To create a bar chart using the SAS AppDev Studio 2 tags, use the sasads:Bar tag.
<sasads:Bar id="bbuBar" model="dsBar" scope="session" />
16 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
2.1.2 sasads:Combination A combination of a bar and line chart can be created using the sasads:Combination tag. Because combination charts handle many different variables, the tag requires a few more attributes by default to produce a readable graph. These attributes are categoryVariableName, responseVariableName, and subGroupVariableName.
<sasads:Combination id="bbuCombination" model="dsBar" scope="session" categoryVariableName="year" responseVariableName="amount" subGroupVariableName="country" />
2.1.3 sasads:Pie The sasads:Pie tag creates a pie chart.
<sasads:Pie id="bbuPie" model="dsBar" scope="session" />
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 17
2.1.4 sasads:Scatter You can create a scatter chart using the sasads:Scatter tag.
<sasads:Scatter id="bbuScatter" model="dsBar" scope="session" />
2.1.5 sasads:SegmentedBar You can create a stacked bar chart using the sasads:SegmentedBar tag. As with the combination chart, there are more variables to define with a segmented bar chart. The attributes used to define these variables are categoryVariableName, responseVariableName, and subGroupVariableName.
<sasads:SegmentedBar id="bbuSegmentedBar" model="dsBar" scope="session" categoryVariableName="year" responseVariableName="amount" subGroupVariableName="country" />
18 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
2.2 SAS AppDev Studio 3 Tags In SAS AppDev Studio 2, you only need a DataSetInterface or sasads:DataSet tag to define your data. However, with SAS AppDev Studio 3, each chart type can be built using its own data model. Therefore, in each example of a basic graph we have included the code that builds the table data model for each graph type. For instance, with the sas:BarChart tag the corresponding table data model is the com.sas.graphics.components.barchart.BarChartTableDataModel class. Using this code allows you to customize your data more than you can by using the sasads:DataSet tag.
2.2.1 sas:BarChart The sas:BarChart tag creates a basic bar chart. By customizing the table data model, you can also transform the basic bar chart into a stacked bar chart to represent different subgroups of data.
<jsp:useBean id="barChartTableDataModel1" scope="session" class="com.sas.graphics.components.barchart.BarChartTableDataModel"> <jsp:setProperty name="barChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% barChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("COUNTRY")); barChartTableDataModel1.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); %> <sas:BarChart id="bbuSASBarChart" model="barChartTableDataModel1" scope="session" >
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 19
2.2.2 sas:BarLineChart The sas:BarLineChart tag can create bar charts that have a corresponding line chart attached. This enables you to see two different types of data per category.
<jsp:useBean id="barLineChartTableDataModel1" scope="session" class="com.sas.graphics.components.barlinechart. BarLineChartTableDataModel"> <jsp:setProperty name="barLineChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% barLineChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("TEACHER")); barLineChartTableDataModel1.setLineResponseVariable( new com.sas.graphics.components.AnalysisVariable("AGE", com.sas.graphics.components.GraphConstants.STATISTIC_MEAN)); barLineChartTableDataModel1.setBarResponseVariable( new com.sas.graphics.components.AnalysisVariable("HEART", com.sas.graphics.components.GraphConstants.STATISTIC_MEAN)); %> <sas:BarLineChart id="bbuSASBarLineChart" model="barLineChartTableDataModel1" scope="session" >
20 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
2.2.3 sas:LineChart The sas:LineChart tag creates a line chart. A line chart shows the relationship of one variable to another. Typically these variables have only one corresponding value on the vertical axis. This type of chart is best suited to business-oriented graphs that plot values against other discrete categorical values.
<jsp:useBean id="lineChartTableDataModel1" scope="session" class="com.sas.graphics.components.linechart. LineChartTableDataModel"> <jsp:setProperty name="lineChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% lineChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("COUNTRY")); lineChartTableDataModel1.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); %> <sas:LineChart id="bbuSASLineChart" model="lineChartTableDataModel1" scope="session" >
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 21
2.2.4 sas:LinePlot You can create a line plot using the sas:LinePlot tag. A line plot is typically used to plot x and y variables, one of which may have contiguous values. In this example, the population (POPDEN) is a contiguous value, and the territories (IDNAME) are discrete values.
<jsp:useBean id="linePlotTableDataModel1" scope="session" class="com.sas.graphics.components.lineplot.LinePlotTableDataModel"> <jsp:setProperty name="linePlotTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% linePlotTableDataModel1.setXVariable( new com.sas.graphics.components.PlotVariable("IDNAME")); linePlotTableDataModel1.setYVariable( new com.sas.graphics.components.PlotVariable("POPDEN")); %> <sas:LinePlot id="bbuSASLinePlot" model="linePlotTableDataModel1" scope="session" >
22 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
2.2.5 sas:PieChart The newer sas:PieChart tags can create three-dimensional pie charts, ringed pie charts, and donut charts. Section 3.5 explains how to use attributes to create the various types of pie charts.
<jsp:useBean id="pieChartTableDataModel1" scope="session" class="com.sas.graphics.components.piechart.PieChartTableDataModel"> <jsp:setProperty name="pieChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% pieChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("COUNTRY")); pieChartTableDataModel1.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); %> <sas:PieChart id="bbuSASPieChart" model="pieChartTableDataModel1" scope="session" >
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 23
2.2.6 sas:RadarChart The sas:RadarChart tag is new to SAS AppDev Studio. The spokes that radiate from the center of the chart can be used to show the frequency of data measures. These charts are often used in quality control and market research.
<jsp:useBean id="radarChartTableDataModel1" scope="session" class="com.sas.graphics.components.radarchart. RadarChartTableDataModel"> <jsp:setProperty name="radarChartTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% radarChartTableDataModel1.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("COUNTRY")); radarChartTableDataModel1.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); %> <sas:RadarChart id="bbuSASRadarChart" model="radarChartTableDataModel1" scope="session" >
24 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
2.2.7 sas:ScatterPlot You can create a scatter plot using the sas:ScatterPlot tag. Scatter plots show a relationship between one variable and another. They can be very helpful in revealing trends in the data.
<jsp:useBean id="scatterPlotTableDataModel1" scope="session" class="com.sas.graphics.components.scatterplot. ScatterPlotTableDataModel"> <jsp:setProperty name="scatterPlotTableDataModel1" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% scatterPlotTableDataModel1.setXVariable( new com.sas.graphics.components.PlotVariable("IDNAME")); scatterPlotTableDataModel1.setYVariable( new com.sas.graphics.components.PlotVariable("POPDEN")); %> <sas:ScatterPlot id="bbuSASScatterPlot" model="scatterPlotTableDataModel1" scope="session">
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 25
2.3 Common Attributes The following are common attributes that affect the look and feel of SAS AppDev Studio 3 graph tags. These attributes can be applied to any of the base level graph tags. For each attribute we review the code that creates the output as well as the HTML that is generated. This way if you are familiar with HTML it will give you some idea of how the output is constructed.
alignment To adjust the alignment of a chart within the page you can use the alignment attribute. Valid values: Top Bottom Middle Left Right
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="session" alignment="RIGHT" >
This attribute is applied to the HTML image tag, so it does little to adjust the alignment on a page by itself. You can insert this tag into a HTML table to position the graph on the page.
26 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
alternateText The alternateText attribute enables you to define text that is displayed when the user hovers over graph areas where data points do not exist, such as the axis areas and labels. In the HTML source, this text is defined by the alt attribute applied to the
HTML tag. Valid values: <String>
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" alternateText="Alternate Text when Hovering" >
Once this code is rendered, the compiled HTML code looks similar to this:
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 27
appliedColorSchemeName To apply a predefined color scheme to your graph, you can use the appliedColorSchemeName attribute. This attribute is applied as a preprocessing event to create the image. Therefore no HTML tags are generated to apply the color scheme. Valid values: Autumn Carnival Grayscale Magellan Ocean Picnic Terra Woodland
Bright Commerce Industry Neon Pastel Pine Wheat
<sas:PieChart id="bbuSASPieChart" model="pieChartTDM1" scope="request" appliedColorSchemeName="Carnival" >
28 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
appliedGraphStyleName The appliedGraphStyleName attribute is very similar to the appliedColorSchemeName attribute. This attribute also applies predefined textures and modifies the look and feel of the graph with more than just colors. Valid values: Analysis Banker Convention Education Gears Money RSVP Sketch Torn
Astronomy Blockprint Curve Electronics Magnify Monochrome Science Statistical Watercolor
<sas:BarLineChart id="bbuSASBarLineChart" model="barLineChartTDM1" scope="request" appliedGraphStyleName="Watercolor" >
Have fun with these. You can find examples of the predefined graph styles at http://support.sas.com/rnd/gendoc/bi/api/Components/com/sas/graphics/components/docfiles/style-Grid.html.
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 29
borderWidth To put a border around your graphics area you can use the borderWidth attribute. This attribute enables you to apply a border and control the thickness. Valid values:
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" borderWidth="5" >
When this tag is rendered, the border is actually applied to the HTML tag that produces the graph. Here is an example:
30 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
epilog You can add text to the graph area at the bottom by using the epilog attribute of the graph tag. Valid values: <String>
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" epilog="Epilog Text" >
The epilog is actually created after the image has been created. This is added as straight HTML text on your page.
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 31
Epilog Text <map name="bbuSASBarChart"> <area shape="polygon" alt="COUNTRY: Australia AMOUNT: 31167" coords="86,241,86,241,169,241,169,253,86,253,86,253"> <area shape="polygon" alt="COUNTRY: Canada AMOUNT: 71894" coords="189,227,189,227,272,227,272,253,189,253,189,253"> <area shape="polygon" alt="COUNTRY: US AMOUNT: 514046" coords="291,76,291,76,374,76,374,253,291,253,291,253">
Notice where the “Epilog Text” string is posted on the page after the image but before the map. The map was automatically generated by the graph tag. In this example, it provides hover text that shows the country name and amount.
galleryImageVisible The galleryImageVisible attribute enables you to control whether your graphs are resizable on the page. In Microsoft Internet Explorer there is a setting under Tools Î Internet Options Î Advanced Î Multimedia called “Enable Automatic Image Resizing.” This option, when checked, resizes images that may be too large to fit in the browser window area. The galleryImageVisible attribute sets this option on or off using a True or False value. Set to False, the graph image cannot be resized regardless of the user’s Internet Explorer browser settings. Valid values: Boolean (True/False)
32 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
height The graph’s height can be set using the height attribute. This attribute applies a height attribute to the HTML tag once it is rendered. Valid values:
<sas:LineChart id="bbuSASLineChart" model="lineChartTDM1" scope="request" height="450" >
Be aware that the radar chart does not resize the image, but rather allots the space to use for the graph area. Therefore the radar chart is the same size, but the height attribute may create more white space around the perimeter.
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 33
horizontalSpace You can use the horizontalSpace attribute to provide padding or white space on the sides of the image. Valid values: <sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" horizontalSpace="200" >
When the tag renders the image, it applies an hspace attribute to the HTML tag, similar to this:
image The image attribute allows you to set the source of the chart you are trying to display. Although this attribute sounds fairly straightforward, we have not found any practical uses for it.
34 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
prolog Similar to the epilog attribute, the prolog attribute applies text to the outside of the graph area. The difference is that the prolog is applied before the graph is resolved. Valid values: <String>
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" prolog="Prolog text" >
The resulting HTML code looks similar to this: Prolog text <map name="bbuSASBarChart"> <area shape="polygon" alt="COUNTRY: Australia AMOUNT: 31167" coords="86,241,86,241,169,241,169,253,86,253,86,253">
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 35
<area shape="polygon" alt="COUNTRY: Canada AMOUNT: 71894" coords="189,227,189,227,272,227,272,253,189,253,189,253"> <area shape="polygon" alt="COUNTRY: US AMOUNT: 514046" coords="291,76,291,76,374,76,374,253,291,253,291,253">
Notice that the string “Prolog Text” is applied to the HTML stream before the image and map areas.
render To disable or delay the display of a specific graph, you can use the render attribute. This takes a Boolean value (True or False). The default value is True. If it is set to False, the graph does not display with that particular invocation of the graph tag. However, if you reference the graph tag later in the HTML file, you can display the graph at that time by changing the render value to True. Valid values: Boolean (True/False) <sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" render="FALSE" >
This tag can be valuable in lots of applications. For example, you might want to display or not display the graph based on some passed parameter. Therefore you could do something like the following: <sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" render="<%=isRendered%>" >
This code takes a parameter pulled from the session or request (isRendered) and applies that passed string directly to the tag. You should be careful when doing this to make sure the value is indeed a string representing a Boolean value (True or False).
36 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
verticalSpace The verticalSpace attribute is similar to the horizontalSpace attribute. The difference is that white space is applied to the top and bottom (vertical spaces) of the graph area. Valid values: <sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" verticalSpace="200" >
This padding is accomplished when the tag renders the image. It applies a vspace attribute to the HTML tag, similar to this:
width To adjust the width of the graphics area, you can use the width attribute with the graphics tag. Valid values:
<sas:BarChart id="bbuSASBarChart" model="barChartTDM1" scope="request" width="450" >
Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 37
Here is the resulting HTML source:
Note that the width is applied directly to the HTML tag. This can cause you some problems. For instance, take one of the plots with longer labels. The labels will unfortunately be shortened automatically. This might not be the desired affect, as shown below.
38 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
3
SAS AppDev Studio 3 Graph Model Tags 3.1 BarChartModel 40 3.2 BarLineChartModel 50 3.3 LineChartModel 64 3.4 LinePlotModel 67 3.5 PieChartModel 74 3.6 RadarChartModel 87 3.7 ScatterPlotModel 92 3.7.1 Baselines 97
This chapter covers graph model tags. Graph model tags are used to control the data elements in the graph. This type of tag is nested inside the top-level graph tag. In the JSP, the nested tags look like this: <sas:BarChart > <sas:BarChartModel >
40 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
We have discussed the attributes of the top-level tag (in this case sas:BarChart). Now we want to discuss the attributes of the graph model. In these examples, we still show the output and the code, but there is no HTML source to review, because the nested tag works on the output before it is delivered to the screen. At the beginning of each graph model tag, we show you the tags in context. Then for each attribute we only show the nested tag portion.
3.1 BarChartModel The sas:BarChartModel tag is used within the sas:BarChart tag. Here is an example of the appropriate nesting syntax: <sas:BarChart > <sas:BarChartModel >
antialiasedGraphics The antialiasedGraphics attribute of the BarChartModel tag smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:BarChartModel antialiasedGraphics="true" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 41
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:BarChartModel antialiasedText="true" >
barShape You can change the shape used to represent the bar using the barShape attribute. Currently only two shapes are available: a rectangle (which is the default) and a cylinder. This attribute can be changed only when the dimension attribute of the graph is set to 3D. Valid values: Rectangle Cylinder Requirements: dimension=“3D” <sas:BarChartModel barShape="Cylinder" dimension="3d">
42 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
barWidth You can use the barWidth attribute to set the display property of the bars in the bar chart. If the graph becomes too crowded, the applet automatically resizes the bars to accommodate them. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
<sas:BarChartModel barWidth="100pt">
barWidthSpace To set the width of the white space around each bar, you can use the barWidthSpace attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 43
<sas:BarChartModel barWidthSpace="100pt">
dimension To set the aspect to 3D, you can use the dimension attribute. The default is 2D. The example shows the attribute set to 3D. Valid values: 2D 3D
<sas:BarChartModel dimension="3d">
insideBarLabelContent The insideBarLabelContent attribute enables you to set the type of information to be displayed inside the bar. Valid values: Automatic None Category Response Sum Mean Percent Subpercent
<sas:BarChart id="insideBarLabelContent_SASBarChart" model="barChartTDM1" scope="session
44 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
appliedColorSchemeName="Carnival"> <sas:BarChartModel insideBarLabelContent="Percent">
Note: The reason we have used the appliedColorSchemeName attribute here is that the default text color for the label content was too dark on an already dark bar (blue). We changed to a lighter color scheme so that the text would show up better.
missingPolicy The missingPolicy attribute sets the behavior of the graph for displaying missing values. There are three values: Automatic, True, and False. The Automatic setting displays all missing values for classification variables except those for category variables. The True setting displays all missing values, whereas the False setting does not display any missing values for classification variables. The first graph shown has the attribute set to True, whereas the second one is set to False. Valid values: Automatic True False
<sas:BarChartModel missingPolicy="true" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 45
orientation To switch back and forth from a horizontal to a vertical bar chart, you can use the orientation attribute. The first graph shown has a value of Horizontal, whereas the second one is Vertical.
Valid Values: Horizontal Vertical <sas:BarChartModel orientation="Horizontal" >
46 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
outsideBarLabelContent Similar to the insideBarLabelContent attribute, the outsideBarLabelContent attribute enables you to set data to be displayed just outside of each bar. This example uses the value Percent. Valid values: Automatic None Category Response Sum Mean Percent
<sas:BarChartModel outsideBarLabelContent="Percent">
response2AxisLowerThreshold To set a low threshold value on the response2 axis, use the response2AxisLowerThreshold attribute. This attribute enables you to earmark those values that may negatively exceed an expected amount below the baseline.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 47
Valid values: <sas:BarChartModel response2AxisLowerThreshold="-10.0" >
response2AxisUpperThreshold You can also set an upper threshold to the response2 axis by using the response2AxisUpperThreshold attribute. The upper threshold must be greater than the baseline value.
Valid values: <sas:BarChartModel response2AxisUpperThreshold="12.0" >
responseAxisLowerThreshold To set a low threshold value on the response axis, use the responseAxisLowerThreshold attribute. This attribute enables you to earmark those values that may negatively exceed an expected amount below the baseline.
48 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Valid values: <sas:BarChartModel responseAxisLowerThreshold="-15.0" >
responseAxisUpperThreshold You can also set a upper threshold to the response axis by using the responseAxisUpperThreshold attribute. The upper threshold must be greater than the baseline value.
Valid values: <sas:BarChartModel responseAxisUpperThreshold="6.0" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 49
stackBarPolicy The stackBarPolicy attribute enables you to define whether or not the data elements are stacked or sit side-by-side on the bar chart. There are three valid values: Automatic, True, and False. The Automatic setting by default stacks a subgrouped chart but not a multiple response chart. The True setting stacks responses or subgroups, whereas the False setting does not stack either. However, if both multiple responses and subgroups are defined, the resulting graph produces stacked subgroups, but does not stack multiple responses.
Value set to Automatic
Value set to True
Valid values: Automatic True False
Value set to False
50 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Note: Only bars associated with the same response axis will stack. Those graphs using barResponseVariable and barResponse2Variable attributes will not stack. You can, however, define multiple response variables on a single axis using two AnalysisVariableList objects with the barResponseVariable and barResponse2Variable attributes. <sas:BarChartModel stackBarPolicy="True" >
3.2 BarLineChartModel The sas:BarLineChartModel tag can be nested only within a sas:BarLineChart tag to help define the look and feel of a combination bar and line chart. Here is how the syntax might look at the appropriate nested level: <sas:BarLineChart > <sas:BarLineChartModel >
antialiasedGraphics The antialiasedGraphics attribute of the BarLineChartModel smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:BarLineChartModel antialiasedGraphics="True">
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False)
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 51
<sas:BarLineChartModel antialiasedText="True">
barShape You can change the shape used to represent the bar using the barShape attribute. Currently only two shapes are available: a rectangle (which is the default) and a cylinder. These shapes are displayed only when the dimension attribute of the graph is set to 3D. This example shows the barShape attribute with a setting of Cylinder. Valid values: Rectangle Cylinder Requirements: dimension=“3D”
<sas:BarLineChartModel barShape="Cylinder" dimension="3d">
52 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
barWidth You can use the barWidth attribute to set the display property of the bars in the bar chart. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in Requirements: growBarWidthEnabled=“true”
<sas:BarLineChartModel barWidth="100pt" growBarWidthEnabled="true">
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 53
barWidthSpace To set the width of the white space around each bar, you can use the barWidthSpace attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
<sas:BarLineChartModel barWidthSpace="100pt">
54 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
dimension To set the aspect to 3D, you can use the dimension attribute. The default is 2D. The example shows a threedimensional graph. Valid values: 2D 3D
<sas:BarLineChartModel dimension="3d">
Note: The dimension attribute reverts back to 2D if the number of bars cannot be easily displayed using the defined width of the chart.
fillAreaEnabled The fillAreaEnabled attribute enables you to fill the area between the line and the axis. The default value is False. The bar line chart shown has the value set to True. Valid values: Boolean (True/False)
<sas:BarLineChartModel fillAreaEnabled="True">
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 55
Note: When the fillAreaEnabled attribute is set to False, the line appears in front of the bars, as shown in the previous example.
insideBarLabelContent The insideBarLabelContent attribute enables you to set up the type of information to be displayed inside the bar. This example shows the insideBarLabelContent attribute set to Percent. Valid values: Automatic None Category Response Sum Mean Percent Subpercent
<sas:BarLineChart id="insideBarLabelContent_SASBarLineChart" model="blcTDMFitness3" scope="session" appliedColorSchemeName="Carnival"> <sas:BarLineChartModel insideBarLabelContent="Percent">
Note: The reason we have used the appliedColorSchemeName attribute here is that the default text color for the label content was too dark on an already dark bar (blue). We changed to a lighter color scheme so that the text would show up better.
56 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
markerEnabled The markerEnabled attribute controls whether markers are displayed or not. The default value is True, to show the markers. The attribute in this example is set to False. Valid values: Boolean (True/False)
<sas:BarLineChartModel markerEnabled="False">
missingPolicy The missingPolicy attribute sets the behavior of the graph for displaying missing values. There are three values: Automatic, True, and False. The Automatic setting displays all missing values for classification variables except those for category variables. The True setting displays all missing values, whereas the False setting does not display any missing values for classification variables. The following graph shows this attribute set to True.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 57
Valid values: Automatic True False <sas:BarLineChartModel missingPolicy="true">
outsideBarLabelContent Similar to the insideBarLabelContent attribute, the outsideBarLabelContent attribute enables you to set data to be displayed just outside of each bar. The outsideBarLabelContent attribute is set to Percent in this example. Valid values: Automatic None Category Response Sum Mean Percent
<sas:BarLineChartModel outsideBarLabelContent="Percent" >
58 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
outsideMarkerLabelContent The outsideMarkerLabelContent attribute sets the data information to be displayed above the markers. The value of the outsideMarkerLabelContent attribute in this example is Percent. Valid values: Automatic None Category Response Sum Mean Percent <sas:BarLineChart id="outsideMarkerLabelContent_SASBarLineChart" model="blcTDMFitness3" scope="session" appliedColorSchemeName="Carnival"> <sas:BarLineChartModel outsideMarkerLabelContent="Percent" >
response2AxisLowerThreshold To set a low threshold value on the response2 axis, use the response2AxisLowerThreshold attribute. This attribute enables you to earmark those values that may negatively exceed an expected amount below the baseline.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 59
Valid values: <sas:BarLineChartModel response2AxisLowerThreshold="-10.0" >
response2AxisUpperThreshold You can also set an upper threshold to the response2 axis by using the response2AxisUpperThreshold attribute. The upper threshold must be greater than the baseline value.
Valid values: <sas:BarLineChartModel response2AxisUpperThreshold="12.0" >
60 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
responseAxisLowerThreshold To set a low threshold value on the response axis, use the responseAxisLowerThreshold attribute. This attribute enables you to earmark those values that may negatively exceed an expected amount below the baseline.
Valid values: <sas:BarLineChartModel responseAxisLowerThreshold="-15.0" >
responseAxisUpperThreshold You can also set a upper threshold to the response axis by using the responseAxisUpperThreshold attribute. The upper threshold must be greater than the baseline value.
Valid values:
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 61
<sas:BarLineChartModel responseAxisUpperThreshold="6.0">
stackBarPolicy The stackBarPolicy attribute enables you to define whether or not the data elements are stacked or sit side-by-side on the bar chart. There are three valid values: Automatic, True, and False. The Automatic setting by default stacks a subgrouped chart but not a multiple response chart. The True setting stacks responses or subgroups, whereas the False setting does not stack either. However, if both multiple responses and subgroups are defined, the resulting graph produces stacked subgroups, but does not stack multiple responses.
Note: For clarity we have removed the Line Response references.
62 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Note: Only bars associated with the same response axis will stack. Those graphs using barResponseVariable and barResponse2Variable attributes will not stack. You can, however, define multiple response variables on a single axis using two AnalysisVariableList objects with the barResponseVariable and barResponse2Variable attributes. Valid values: Automatic True False <sas:BarLineChartModel stackBarPolicy="True">
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 63
stackLinePolicy Like the stackBarPolicy attribute, the stackLinePolicy attribute determines whether to display the output as stacks or not. Although defined in the Help files and online, this attribute was not fully functional at the time of this writing.
zeroHeightBarsVisible The zeroHeightBarsVisible attribute sets the display to show or hide those bars with a zero height. The default value is False. The first example illustrates the value set to True. The second example shows it set to False.
Valid values: Boolean (True/False) <sas:BarLineChartModel zeroHeightBarsVisible="true" >
64 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
3.3 LineChartModel The sas:LineChartModel tag can be nested only within a sas:LineChart tag to help define the look and feel of a line chart. Here is how the syntax might look at the appropriate nested level: <sas:LineChart > <sas:LineChartModel >
antialiasedGraphics The antialiasedGraphics attribute of the LineChartModel tag smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:LineChartModel antialiasedGraphics="true" >
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:LineChartModel antialiasedText="true" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 65
fillAreaEnabled The fillAreaEnabled attribute enables you to fill the area between the line and the axis. The default value is False. In this example, we have set this to True. Valid values: Boolean (True/False)
<sas:LineChartModel fillAreaEnabled="True">
markerEnabled The markerEnabled attribute controls whether markers are displayed or not. The default value is True, to show the markers. Here we have set it to False. Valid values: Boolean (True/False)
<sas:LineChartModel markerEnabled="False">
66 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
missingPolicy The missingPolicy attribute sets the behavior of the graph for displaying missing values. There are three values: Automatic, True, and False. The Automatic setting displays all missing values for classification variables except those for category variables. The True setting displays all missing values, whereas the False setting does not display any missing values for classification variables. This example shows the attribute set to True. Valid values: Automatic True False
<sas:LineChartModel missingPolicy="true" >
outsideMarkerLabelContent The outsideMarkerLabelContent attribute sets the data information to be displayed above the markers. The value of the outsideMarkerLabelContent attribute in this example is Percent. Valid values: Automatic None Category Response Sum Mean Percent
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 67
<sas:LineChartModel outsideMarkerLabelContent="Percent">
stackLinePolicy Like the stackBarPolicy attribute, the stackLinePolicy attribute determines whether to display the output as stacks or not. (This attribute did not function with the tested release.)
3.3.1 Response Axis Thresholds To set a low threshold value on the response2 axis, use the response2AxisLowerThreshold attribute. This allows you to earmark those values that may negatively exceed an expected amount below the baseline. You can also set a upper threshold to the response2 axis by using the response2AxisUpperThreshold attribute. The upper threshold must be greater than the baseline value. To set a low threshold value on the response axis, use the responseAxisLowerThreshold attribute. This attribute allows you to earmark those values that may negatively exceed an expected amount below the baseline. You can also set a upper threshold to the response axis by using the responseAxisUpperThreshold attribute. The upper threshold must be greater than the baseline value. (None of these attributes functioned with the tested release.)
3.4 LinePlotModel The sas:LinePlotModel tag can be nested only within a sas:LinePlot tag to help define the look and feel of a line plot. Here is how the syntax might look at the appropriate nested level: <sas:LinePlot > <sas:LinePlotModel >
68 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
antialiasedGraphics The antialiasedGraphics attribute of the LinePlotModel smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:LinePlotModel antialiasedGraphics="true" >
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:LinePlotModel antialiasedText="true" >
bottomMarkerLabelContent The bottomMarkerLabelContent attribute enables you to set the type of content to display below the markers. There are four valid values: Automatic, which displays the bottomMarkerVariable if it is defined in the tableDataModel; None, which displays nothing; X, which displays the data along the x axis; and Y, which displays the data along the y or y2 axis.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 69
Set to X.
Set to Y.
Valid values: Automatic None X Y
<sas:LinePlotModel bottomMarkerLabelContent="X" >
fillAreaEnabled The fillAreaEnabled attribute enables you to fill the area between the line and the axis. The default value is False. This example shows the value set to True. Valid values: Boolean (True/False)
70 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:LinePlotModel fillAreaEnabled="true" >
interpolationEnabled The interpolationEnabled attribute sets the display property of interpolation among the markers. The default value is True. This example demonstrates a False value. Valid values: Boolean (True/False)
<sas:LinePlotModel interpolationEnabled="false" >
markerEnabled The markerEnabled attribute controls whether markers are displayed or not. The default value is True, to show the markers. The attribute in this example is set to False. Valid values: Boolean (True/False)
<sas:LinePlotModel markerEnabled="false" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 71
matchErrorColor The matchErrorColor attribute sets the error markers to use the same color as the error lines. The default value is False. (This attribute did not function with the tested release.)
matchMarkerLabelColor The matchMarkerLabelColor attribute sets the marker labels to use the same color as the markers themselves. The default value is False. So that the model knows what to match to the marker label, you must also set a marker label content using the bottomMarkerLabelContent or topMarkerLabelContent attributes. This example shows the value set to True using the bottomMarkerLabelContent of X. Valid values: Boolean (True/false) Requirements: bottomMarkerLabelContent=“” or topMarkerLabelContent=“” and the nested sas:BottomMarkerLabelTextStyle or sas:TopMarkerLabelTextStyle tag
<sas:LinePlotModel matchMarkerLabelColor="true" bottomMarkerLabelContent="X" >
72 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
matchNeedleColor The matchNeedleColor attribute sets the color of the needles to be the same as the color for the markers. The default value is False. This example shows the value set to True. Valid values: Boolean (True/False) Requirements: You need to nest a sas:DataElementStyles tag and define a sas:MarkerStyle tag to use interpolation=“”
<sas:LinePlotModel matchNeedleColor="true" > <sas:DataElementStyles > <sas:MarkerStyle interpolation="VerticalNeedles" >
skipMissing If there are missing values, you can skip these data points by setting the skipMissing attribute to True. By default this attribute is set to True.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 73
Set to False, which causes a visible break in the data.
Set to True, which skips over the missing data.
Valid values: Boolean (True/False) <sas:LinePlotModel skipMissing="true" >
topMarkerLabelContent The topMarkerLabelContent attribute enables you to set the type of content to display above the markers. There are four valid values: Automatic, which displays the topMarkerVariable if it is defined in the tableDataModel; None, which displays nothing; X, which displays the data along the x axis; and Y, which displays the data along the y or y2 axis.
Set to X.
Set to Y.
74 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Valid values: Automatic None X Y Requirements: sas:TopMarkerLabelTextStyle <sas:LinePlotModel topMarkerLabelContent="X" > <sas:TopMarkerLabelTextStyle />
3.4.1 Axis Baselines The baseline anchor position for the x axis can be defined using the xAxisBaseline attribute. The baseline anchor position for the y2 axis can be defined using the y2AxisBaseline attribute. The baseline anchor position for the y axis can be defined using the yAxisBaseline attribute. (None of these attributes functioned with the tested release.)
3.5 PieChartModel The sas:PieChartModel tag can be nested only within a sas:PieChart tag to help define the look and feel of a pie or donut chart. Here is how the syntax might look at the appropriate nested level: <sas:PieChart > <sas:PieChartModel >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 75
across The across attribute enables you to set the number of pies to display horizontally when there are multiple responses. Valid values:
<sas:PieChartModel across="1" >
antialiasedGraphics The antialiasedGraphics attribute of the PieChartModel smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False)
76 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:PieChartModel antialiasedGraphics="true" >
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:PieChartModel antialiasedText="true" >
dimension To set the aspect to 3D, you can use the dimension attribute. The default is 2D. The graph shows the dimension attribute set to 3D. Valid values: 2D 3D
<sas:PieChartModel dimension="3D">
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 77
donutHoleLabel The donutHoleLabel attribute enables you to define a label that will be centered in the pie. The example sets the donut hole size to accommodate the length of the label. Valid values: <String>
<sas:PieChartModel donutHoleLabel="Donut Hole Label" donutHoleSize=”75”>
donutHoleSize The donutHoleSize attribute sets up the size of the open area in the center of the pie (the “donut hole”). This value represents the percentage of the size of the radius of the whole pie. So by specifying 25, you are telling the donut hole to have a radius that is 25% of the radius of the whole pie. The example demonstrates the use of this value. Valid values:
78 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:PieChartModel donutHoleSize="25">
down The down attribute enables you to set the number of pies to display vertically when there are multiple responses.
Valid values: <sas:PieChartModel down="1" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 79
explodedCategories The explodedCategories attribute allows you to set apart (or “explode”) a specified category. The effect looks as though someone pulled out a particular slice or slices from the pie. This attribute is ignored in a pie with subgroups. The following example pulls out the category representing Canada. Valid values: <String> (The string should represent a valid category in the data.)
<sas:PieChartModel explodedCategories="Canada">
insideSliceLabelContent To set up data content to be displayed in the pie slices, you can use the insideSliceLabelContent attribute. The insideSliceLabelContent attribute is set to Percent in this example. Valid values: Automatic None Category Response Percent CategoryResponse CategoryPercent ResponsePercent CategoryResponsePercent
80 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:PieChartModel insideSliceLabelContent="Percent">
insideSliceLabelPlacement The insideSliceLabelPlacement attribute is to be used with the insideSliceLabelContent attribute. This attribute enables you to set the placement of the displayed values. There are two valid values: Automatic, which forces all content to display; and Best, which may or may not place content on each slice, depending on the amount of space in the slice. Valid values: Automatic Best Requirements: insideSliceLabelContent=“” Note: In this example, we are using Best, and in the output the slice representing Australia does not display the content. This is because there is not enough room inside the label to display the content correctly. <sas:PieChartModel insideSliceLabelContent="Percent" insideSliceLabelPlacement="Best" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 81
invisibleCategories If you have ever wanted to focus in on just a few categories of data instead of everything, you are in luck. You can use the invisibleCategories attribute to tell the pie to omit specified categories. Valid values: <String> (The string should represent a valid category in the data.)
<sas:PieChartModel invisibleCategories="Canada">
missingPolicy The missingPolicy attribute sets the behavior of the graph for displaying missing values. There are three values: Automatic, True, and False. The Automatic setting displays all missing values for classification variables except those for category variables. The True setting displays all missing values, whereas the False setting does not display any missing values for classification variables. This example shows this attribute set to True. Valid values: Automatic True False
82 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:PieChartModel missingPolicy="true" >
otherColor The otherColor attribute sets the color to be used for the group defined by the otherThreshold value. (This attribute did not function with the tested release.)
otherSliceLabel Although the otherColor attribute is not currently working, you can set the label of the other slice in the pie using the otherSliceLabel attribute. This attribute can be used when defining the otherThreshold attribute to create a userdefined “Other” category, or by default when a slice is small enough to be below the default threshold. Valid values: <String>
<sas:PieChartModel otherSliceLabel="Other Slice Label" otherThreshold="40.0" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 83
otherThreshold The otherThreshold attribute sets the upper threshold limit for combining slices. This is useful when you have several smaller slices that you might want to combine into a bucket. The threshold is currently based only on percentage values. For example, if you have three slices and they occupy 50, 35 and 15 percent of the pie, then you specify the otherThreshold attribute to be equal to 40. You will see only 2 slices, with the 50% slice labeled with its corresponding category label and the other slice labeled by default with “Other”, unless otherwise specified with otherSliceLabel. Valid values:
<sas:PieChartModel otherThreshold="40.0">
outsideSliceLabelContent To set data content to be displayed outside the pie slices, you can use the outsideSliceLabelContent attribute. This example shows the attribute set to Percent. Valid values: Automatic None Category Response Percent CategoryResponse CategoryPercent ResponsePercent CategoryResponsePercent
84 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:PieChartModel outsideSliceLabelContent="Percent">
outsideSliceLabelPlacement The outsideSliceLabelPlacement attribute is used with the outsideSliceLabelContent attribute. This attribute enables you to set the placement of the displayed values. There are two valid values: Automatic, which forces all content to display; and Arrow, which offsets the content values and places arrows pointing to the slice it represents. This example shows the value set to Arrow. Valid values: Automatic Arrow Requirements: outsideSliceLabelContent=“”
<sas:PieChartModel outsideSliceLabelContent="Percent" outsideSliceLabelPlacement="Arrow" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 85
responseLabelVisiblePolicy The responseLabelVisiblePolicy attribute controls whether response labels are shown or not shown. In the first graph, this attribute has a value of True, whereas the value in the second one is False. Note that the first graph, with a value of True, shows the label “AMOUNT.” In the second graph, “AMOUNT” does not show. Valid values: Boolean (True/False)
<sas:PieChartModel responseLabelVisiblePolicy="True">
86 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
reverseDirection The reverseDirection attribute sets the slices to be displayed in a counterclockwise direction if set to True. The clockwise direction is the default. Valid values: Boolean (True/False)
<sas:PieChartModel reverseDirection="true">
sliceOrder The sliceOrder attribute enables you to set the ordering of the slices based on the data. There are three valid values for this attribute: None, which displays the slices in the order that they are in within the data; Ascending, which sorts and displays the data in an ascending order; and Descending, which sorts and displays the data in a descending order. This example shows values in descending order. Valid values: None Ascending Descending
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 87
<sas:PieChartModel sliceOrder="descending">
startAngle The startAngle attribute sets the angle, in degrees, at which the pie should start the first slice. By default, the 3 o’clock position is set at 0 degrees. Therefore, if you set the startAngle attribute at 90, the pie slices start at the top of the pie. Valid values:
<sas:PieChartModel startAngle="50">
3.6 RadarChartModel The sas:RadarChartModel tag can be nested only within a sas:RadarChart tag to help define the look and feel of a radar chart.
88 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Here is how the syntax might look at the appropriate nested level: <sas:RadarChart > <sas:RadarChartModel >
antialiasedGraphics The antialiasedGraphics attribute of the RadarChartModel smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:RadarChartModel antialiasedGraphics="true" >
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:RadarChartModel antialiasedText="true" >
filledRadar The filledRadar attribute sets up the radar chart to be filled or unfilled.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 89
Set to True.
Set to False.
Valid values: Boolean (True/False) Note: In our example, if we set this to False, the values are not displayed at all. <sas:RadarChartModel filledRadar="false" >
missingPolicy The missingPolicy attribute sets the behavior of the graph for displaying missing values. There are three values: Automatic, True, and False. The Automatic setting displays all missing values for classification variables except those for category variables. The True setting displays all missing values, whereas the False setting does not display any missing values for classification variables.
Set to True
Set to False
90 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Valid values: Boolean (True/False) <sas:RadarChartModel missingPolicy="true" >
radarType The radarType attribute enables you to set the output type for the radar chart. The default value is Wedge.
Set to Wedge.
Set to Polygon.
Set to Spoke.
Set to Radial.
Valid values: Wedge Polygon Spoke Radial <sas:RadarChartModel radarType="polygon" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 91
startAngle The startAngle attribute enables you to set the angle at which you would like to put the first axis on the radar chart. The 12 o’clock position represents 0 degrees, and the axis points move clockwise. Valid values:
<sas:RadarChartModel startAngle="50">
uniformAxes The uniformAxes attribute controls whether or not the axes represent the same range.
Set to true.
Set to false.
Valid values: Boolean (True/False) <sas:RadarChartModel uniformAxes="true" >
92 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
3.7 ScatterPlotModel The sas:ScatterPlotModel tag can be nested only within a sas:ScatterPlot tag to help define the look and feel of a scatter plot. Here is how the syntax might look at the appropriate nested level: <sas:ScatterPlot > <sas:ScatterPlotModel >
antialiasedGraphics The antialiasedGraphics attribute of the ScatterPlotModel smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False) <sas:ScatterPlotModel antialiasedGraphics="true" >
antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False) <sas:ScatterPlotModel antialiasedText="true" >
bottomMarkerLabelContent The bottomMarkerLabelContent attribute enables you to set the type of content to display below the markers. There are four valid values: Automatic, which displays the bottomMarkerVariable if it is defined in the tableDataModel; None, which displays nothing; X, which displays the data along the x axis; and Y, which displays the data along the y or y2 axis.
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 93
(This attribute did not function with the tested release.)
fillAreaEnabled The fillAreaEnabled attribute enables you to fill the area between the line and the axis. The default value is False. The example shows the value set to True.
Valid values: Boolean (True/False) <sas:ScatterPlotModel fillAreaEnabled="true" >
interpolationEnabled The interpolationEnabled attribute sets the display property of interpolation among the markers. The default value is set to True. In the first graph shown, the attribute has a value of True, whereas the value in second one is False.
94 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Valid values: Boolean (True/False) <sas:ScatterPlotModel interpolationEnabled="true" >
markerEnabled The markerEnabled attribute controls whether markers are displayed or not. The default value is True, to show the markers. The attribute in this example is set to False. Valid values: Boolean (True/False)
<sas:ScatterPlotModel markerEnabled="false" >
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 95
matchErrorColor The matchErrorColor attribute sets the error markers to use the same color as the error lines. The default value is False. (This attribute did not function with the tested release.)
maxMarkerSize The maxMarkerSize attribute sets the maximum size of the displayed markers. (This attribute did not function with the tested release.)
minMarkerSize The minMarkerSize attribute sets the minimum size of the displayed markers. (This attribute did not function with the tested release.)
skipMissing If there are missing values, you can skip these data points by setting the skipMissing attribute to True. By default this attribute is set to True. To show this more distinctively, we have also included the interpolationEnabled attribute and set it to True. Valid values: Boolean (True/False)
<sas:ScatterPlotModel skipMissing="true" interpolationEnabled="true" >
96 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
topMarkerLabelContent The topMarkerLabelContent attribute enables you to set the type of content to display above the markers. There are four valid values: Automatic, which displays the topMarkerVariable if it is defined in the tableDataModel; None, which displays nothing; X, which displays the data along the x axis; and Y, which displays the data along the y or y2 axis. To enable this display, you also need to specify the use of the sas:TopMarkerLabelTextStyle tag. Notice in the example code that we did not need to set any attributes for this tag. It is enough that it is there.
Set to X
Set to Y
Valid values: Automatic None X Y
Chapter 3: SAS AppDev Studio 3 Graph Model Tags 97
Requirements: sas:TopMarkerLabelTextStyle <sas:ScatterPlotModel topMarkerLabelContent="X" > <sas:TopMarkerLabelTextStyle />
3.7.1 Baselines The baseline anchor position for the x axis can be defined using the xBaseline attribute. The baseline anchor position for the y2 axis can be defined using the y2Baseline attribute. The baseline anchor position for the y axis can be defined using the yBaseline attribute. (None of these attributes functioned with the tested release.)
98 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
4
Nested Tags for Graph Models 4.1 Axis Models 100 4.1.1 Response Axis Baseline Models 107 4.1.2 Corresponding Graph Models 108 4.1.3 Column and Row Axis Models 110 4.2 Legends 111 4.2.1 Corresponding Graph Models 113 4.3 Line Style Tags 113 4.3.1 Corresponding Graph Models 116 4.4 Text Style Tags 116 4.4.1 Corresponding Graph Models 117 4.5 AxisWallModel 118 4.6 BackgroundFillStyle 119 4.6.1 Corresponding Graph Models 122 4.7 DataElementStyle 123 4.8 DataTipModel 123 4.9 SubgroupLabelModel 124
100 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
The following tags and their corresponding attributes are found in many of the upperlevel graph models. Where applicable, we show a screen shot of the output so you can see the effect of the referenced nested tag’s attribute. Nested tags can be used at various levels. However, these particular tags are found at the third level, similar to the following. <sas:BarChart > <sas:BarChartModel > <sas:ResponseAxisModel />
Each section also gives you information about which graphs accept which nested tag.
4.1 Axis Models Axis models have attributes that affect the tick marks, offsets, grid, categories, and direction of the graph. These seven axis models can be nested within several of the graph models: AxisModel, CategoryAxisModel, Response2AxisModel, ResponseAxisModel, XAxisModel, Y2AxisModel and YAxisModel. The following is a description of their attributes with corresponding examples.
categories The categories attribute sets the midpoint labels displayed on a noncontinuous axis. Valid values must be in the form of a string, but can contain more than one value. (This attribute did not function with the tested release.)
Chapter 4: Nested Tags for Graph Models 101
continuousMajorTickAnchor You can set the anchored location for the major tick marks on the axis by using the continuousMajorTickAnchor attribute. This attribute must be used with the attribute setting continuousMajorTickPositionPolicy= “AnchoredInterval”. Valid values: (This should be some number within or just outside the range of valid data values.) Requirement: continuousMajorTickPositionPolicy= “AnchoredInterval” <sas:ResponseAxisModel continuousMajorTickAnchor="50000" continuousMajorTickPositionPolicy="AnchoredInterval" continuousMajorTickInterval="100000" />
continuousMajorTickCount The continuousMajorTickCount attribute sets the number of major tick marks for the axis. This attribute must be used with the attribute setting continuousMajorTickPositionPolicy= “Count”. Valid values: Requirements: continuousMajorTickPositionPolicy= “Count”
<sas:ResponseAxisModel continuousMajorTickCount="10" continuousMajorTickPositionPolicy="Count" />
102 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
continuousMajorTickInterval The continuousMajorTickInterval attribute sets the interval value for major tick marks. This attribute must be used with the attribute setting continuousMajorTickPositionPolicy= “Interval” or continuousMajorTickPositionPolicy= “AnchoredInterval”. Valid values: Requirements: continuousMajorTickPositionPolicy= “Interval” or continuousMajorTickPositionPolicy= “AnchoredInterval”
<sas:ResponseAxisModel continuousMajorTickInterval="35000.0" continuousMajorTickPositionPolicy="Interval" />
continuousMajorTickPositionPolicy The continuousMajorTickPositionPolicy attribute sets the placement policy for major tick marks. This attribute is used in conjuction with some of the other continuous attributes. We’ve included the specifics and examples in the sections that discuss these attributes. Valid values: Default Count Interval AnchoredInterval UserDefined
Chapter 4: Nested Tags for Graph Models 103
continuousMajorTickValues To define your own placement of major tick marks, use the continuousMajorTickValues attribute in conjuction with the continuousMajorTickPositionPolicy= “UserDefined” statement. This will then enable you to define every one of the major tick marks on that axis. Valid values: Requirements: continuousMajorTickPositionPolicy= “UserDefined”
<sas:ResponseAxisModel continuousMajorTickValues="250000 400000" continuousMajorTickPositionPolicy="UserDefined" />
continuousMinorTickCount The continuousMinorTickCount attribute enables you to define how many minor tick marks exist between each major tick mark pair. The default value is 4. Valid values:
<sas:ResponseAxisModel continuousMinorTickCount="2" />
104 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
endOffset To set the length of offset of the graph area from the last major tick mark to the end of the axis line, use the endOffset attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in <sas:ResponseAxisModel endOffset="50px" />
gridInFront The gridInFront attribute sets the grid lines in the front or the back of the graph. Note that you need to use this attribute in combination with the nested GridLineStyle tag. Otherwise, on a two-dimensional graph the grids will not display.
Set to True
Set to False
Chapter 4: Nested Tags for Graph Models 105
Valid values: Boolean (True/False) Requirements sas:GridLineStyle <sas:ResponseAxisModel gridInFront="true" > <sas:GridLineStyle id="newgrid" visibilityPolicy="true"/>
label The label attribute overrides the current label for the axis. Valid values: <String>
Note: The label output is cut off. Be careful with how long your strings are, because they may not fit in the graph area. <sas:AxisModel label="AxisModel Label">
majorTickTimeInterval The majorTickTimeInterval attribute helps to specify the time intervals to show on the axis. (This attribute did not function with the tested release.)
106 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
reverseDirection The reverseDirection attribute enables you to reverse the direction of the axis, thereby changing the overall appearance of the data points. In this example, the value is set to True. Valid values: Boolean (True/False)
<sas:ResponseAxisModel reverseDirection="true" />
startOffset To set the length of offset of the graph area from the first major tick mark to the beginning of the axis line, use the startOffset attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in <sas:ResponseAxisModel startOffset="50px" />
Chapter 4: Nested Tags for Graph Models 107
4.1.1 Response Axis Baseline Models There are two more tags that affect axes: Response2AxisBaselineModel and ResponseAxisBaselineModel. These tags enable you to adjust the look and feel of the base reference line. Each has a common set of attributes, but they are not used in the same way. These tags are modeled after the ReferenceLineModel tag discussed in Chapter 5, “Supporting Tags.”
inFront The inFront attribute enables you to define whether or not the response baselines should be presented in front of the chart or in the background. If you look closely, you will see in the graph below that inFront is set to True.
Valid values: Boolean (True/False) <sas:ResponseAxisBaselineModel inFront="true" label="Goal" labelPlacement="outside" position="250000.0" visible="true" />
108 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
position The position attribute enables you to place the baseline on the chart. Valid values:
<sas:ResponseAxisBaselineModel inFront="true" label="Goal" labelPlacement="outside" position="250000.0" visible="true" />
4.1.2 Corresponding Graph Models Not all seven axis models (AxisModel, CategoryAxisModel, Response2AxisModel, ResponseAxisModel, XAxisModel, Y2AxisModel, and YAxisModel) work with all chart models. These charts show which axis models you can use with the chart types.
AxisModel BarChartModel BarLineChartModel LineChartModel LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
3
Chapter 4: Nested Tags for Graph Models 109
CategoryAxisModel BarChartModel BarLineChartModel LineChartModel
3 3 3
LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
Response2AxisModel BarChartModel BarLineChartModel LineChartModel
3 3 3
LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
ResponseAxisModel BarChartModel BarLineChartModel LineChartModel LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
3 3 3
110 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
XAxisModel BarChartModel BarLineChartModel LineChartModel LinePlotModel
3
PieChartModel RadarChartModel ScatterPlotModel
3
Y2AxisModel BarChartModel BarLineChartModel LineChartModel LinePlotModel
3
PieChartModel RadarChartModel ScatterPlotModel
3
YAxisModel BarChartModel BarLineChartModel LineChartModel LinePlotModel
3
PieChartModel RadarChartModel ScatterPlotModel
3
4.1.3 Column and Row Axis Models The ColumnAxisModel and RowAxisModel tags do not have specific look and feel attributes. However, they have several nested tags that can be used. For examples and a list of these nested tags, see Chapter 5.
Chapter 4: Nested Tags for Graph Models 111
Column and row axis models are supported for use with the following graph models. BarChartModel BarLineChartModel LineChartModel LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
3 3 3 3 3 3 3
4.2 Legends These legend model tags can be used with various graph models: ColorLegendModel, LegendModel, LineLegendModel, and ShapeLegendModel. They each share a common set of attributes and supporting tags.
label The label attribute sets a string to be the legend title. Valid values: <String>
<sas:LegendModel label="Legend Label" labelPlacement="Right" placement="West" visible="true" />
112 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
labelPlacement You can set the alignment of the label using the labelPlacement attribute. In this example, the labelPlacement attribute is set to Right. Valid values: Automatic Right Outside InsideLeft InsideRight AcrossCenter OutsideLeft OutsideRight
Left Inside Across InsideCenter AcrossLeft AcrossRight OutsideCenter
<sas:LegendModel label="Legend Label" labelPlacement="Right" placement="West" visible="true" />
placement You can use the placement attribute to position the legend in the graph space. In this example, the placement attribute is set to West. Valid values: Automatic North South East West
<sas:LegendModel label="Legend Label" labelPlacement="Right" placement="West" visible="true" />
Chapter 4: Nested Tags for Graph Models 113
4.2.1 Corresponding Graph Models You can use the following legend models with the following graph models. ColorLegendModel
3 3 3
BarChartModel BarLineChartModel LineChartModel LinePlotModel
3 3
PieChartModel RadarChartModel ScatterPlotModel
LegendModel
3 3 LineLegendModel
ShapeLegendModel
BarChartModel BarLineChartModel LineChartModel LinePlotModel
3
PieChartModel RadarChartModel ScatterPlotModel
3
4.3 Line Style Tags The FrameLineStyle and NeedleLineStyle tags are the two upper-level tags that help to define lines such as the frame around objects and the needles used with markers on plots. Note: The FrameLineStyle tag is also a supporting tag, because frames are used in multiple objects. The FrameLineStyle tag used with legends is at a different nesting level than the one used in this section, which is a component of the graph. This tag is discussed both here and in Chapter 5. The FrameLineStyle and NeedLineStyle tags each contain the following visual attributes.
114 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
color The color attribute defines the color to use for the line.
<sas:BarChart id="frameLineStyleAttributes" model="bcTDMGrains2" scope="session"> <sas:BarChartModel> <sas:FrameLineStyle color="red" thickness="3px" visibilityPolicy="true" />
Chapter 4: Nested Tags for Graph Models 115
<sas:LinePlot id="needleLineStyleAttributes" model="lpTDMPopData" scope="session" > <sas:LinePlotModel > <sas:DataElementStyles > <sas:MarkerStyle interpolation="VerticalNeedles" > <sas:NeedleLineStyle color="red" thickness="3px" visibilityPolicy="true" />
Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.) Note: When you use the NeedleLineStyle you will also need to set the DataElementStyles of the line plot to use either of the interpolation types that use needles.
thickness You can define the line thickness using the thickness attribute. The previous examples and code illustrate the use of this attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
116 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
4.3.1 Corresponding Graph Models These line style tags can be used with the following graph models. FrameLineStyle
3 BarLineChartModel 3 LineChartModel 3 LinePlotModel 3 PieChartModel 3 RadarChartModel 3 ScatterPlotModel 3
NeedleLineStyle
BarChartModel
3
3
4.4 Text Style Tags Many nested tags support text styles: BottomMarkerLabelTextStyle, DonutHoleLabelTextStyle, InsideBarLabelTextStyle, InsideSliceLabelTextStyle, OutsideBarLabelTextStyle, OutsideMarkerLabelTextStyle, OutsideSliceLabelTextStyle, and TopMarkerLabelTextStyle. Each have the same common attributes. The following chart is an example of the use of all three attributes.
<sas:BottomMarkerLabelTextStyle baselineAngle="50.0" color="red" justification="right" visible="true" />
Chapter 4: Nested Tags for Graph Models 117
baselineAngle The baselineAngle attribute sets the angle at which the text should be displayed. The starting angle 0 is located at 3 o’clock. The text pivots around an anchor point. The anchor point may vary, depending on the type of graph, the display method, and other factors. Valid values:
color To set the color of the text use the color attribute. Valid values: <String> (This value can be any valid Java java.awt.Color.)
justification The justification attribute enables you to define the justification or alignment of the text. The default value is Left. Valid values: Left Right Center
4.4.1 Corresponding Graph Models These text style tags can be used with the following graph models. BottomMarkerLabelTextStyle
TopMarkerLabelTextStyle
LinePlotModel
3
3 3 3
PieChartModel RadarChartModel ScatterPlotModel
3
3
BarChartModel BarLineChartModel LineChartModel
118 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
BarChartModel BarLineChartModel
InsideBarLabelTextStyle
OutsideBarLabelTextStyle
3 3
3 3
InsideSliceLabelTextStyle
OutsideSliceLabelTextStyle
3
3
LineChartModel LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
BarChartModel BarLineChartModel LineChartModel LinePlotModel PieChartModel RadarChartModel ScatterPlotModel
DonutHoleLabelTextStyle BarChartModel BarLineChartModel
3 3
LineChartModel LinePlotModel PieChartModel
OutsideMarkerLabelTextStyle
3
RadarChartModel ScatterPlotModel
4.5 AxisWallModel The AxisWallModel tag enables you to define certain visual properties of the axis wall with several chart types. This particular tag does not have specific attributes. Instead, it uses other supporting tags such as WallFillStyle and FloorFillStyle. See Chapter 5 for more information on these tags.
Chapter 4: Nested Tags for Graph Models 119
This tag can be used with the following graph models.
3 BarLineChartModel 3 LineChartModel 3 LinePlotModel 3 BarChartModel
PieChartModel RadarChartModel ScatterPlotModel
3 3
4.6 BackgroundFillStyle The BackgroundFillStyle tag enables you to define how to display the background of the graph area. This background can be a solid color or a gradient. This is another tag that can be used at several different levels. At this level it is used to describe the background of the graph area; however, in other circumstances it can also be used to describe the background of a legend. Therefore it can be reviewed twice, once here and once in the Chapter 5. The following attributes are associated with the BackgroundFillStyle tag.
fillType The fillType attribute sets the type of background. This example shows the fillType attribute set to Gradient. Valid values: SolidColor Gradient Image ImageColorBlend ImageGradientBlend
120 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="orange" gradientFillEndColor="white" gradientFill="DiagonalDown" />
gradientBlendBeginColor The gradientBlendBeginColor attribute sets the color to use as the starting color in a gradient. This is only applicable when used with fillType=“ImageGradientBlend”. (This attribute did not function with the tested release.)
gradientBlendEndColor The gradientBlendEndColor attribute, when used with fillType=“ImageGradientBlend”, defines the end color used in a gradient. (This attribute did not function with the tested release.)
gradientFillBeginColor The gradientFillBeginColor attribute sets the color to use as the starting color in a gradient. This is only applicable when used with fillType=“Gradient”. This example starts the gradient with red. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.) Requirements: fillType=“Gradient”
<sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown" />
Chapter 4: Nested Tags for Graph Models 121
gradientFillEndColor The gradientFillEndColor attribute, when used with fillType=“Gradient”, defines the end color used in a gradient as shown in the previous example. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.) Requirements: fillType=“Gradient” <sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown" />
gradientFill The gradientFill attribute sets the directional property for the gradient as shown in the previous example. Valid values: LeftToRight BottomToTop FrontToBack DiagonalUp DiagonalDown Requirements: fillType=“Gradient” <sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown" />
imageFillColor The imageFillColor attribute sets the color used to fill the area before the image is applied. This attribute can be used only when the fillType attribute is defined using one of the image types. (This attribute did not function with the tested release.)
122 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
imageFill The imageFill attribute defines how to display the image specified and can be used only when the fillType attribute defines an image type. (This attribute did not function with the tested release.)
imageIcon The imageIcon attribute sets the image to use. This attribute can be used only when the fillType attribute is defined using one of the image types. (This attribute did not function with the tested release.)
solidBlendColor To define the color that is applied to the area after the image has been applied, use the solidBlendColor attribute. This attribute can be used only with fillType=“ImageColorBlend”. (This attribute did not function with the tested release.)
x The x attribute defines the x coordinate used with the image. (This attribute did not function with the tested release.)
y The y attribute defines the y coordinate used with the image. (This attribute did not function with the tested release.)
4.6.1 Corresponding Graph Models In general, only the solid color fills function correctly with the tested release. Just be aware of this when constructing your own graphs.
Chapter 4: Nested Tags for Graph Models 123
The BackgroundFillStyle can be used with the following graph models.
3 BarLineChartModel 3 LineChartModel 3 LinePlotModel 3 PieChartModel 3 RadarChartModel 3 ScatterPlotModel 3 BarChartModel
4.7 DataElementStyle You can use the DataElementStyle tag to adjust the data descriptions. This adjustment could apply to anything from bars to markers. The direct attributes of this tag do not seem to be working with the tested release; however, the supporting tags may. (This tag did not function with the tested release.)
4.8 DataTipModel The DataTipModel tag is used to adjust the visual elements of the data tip. (This tag did not function with the tested release.)
124 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
4.9 SubgroupLabelModel You can use the SubgroupLabelModel tag to describe the subgroup labels in a pie chart. There is only one attribute to be defined with this tag.
placement The placement attribute describes which side of the pie chart to display subgroup label information. This attribute is only applicable if there are subgroups. This example shows the value for placement set to West. Valid values: East West
<sas:SubgroupLabelModel placement="west" />
C h a p t e r
5
Supporting Tags 5.1 Fill Tags 126 5.2 Line Tags 130 5.2.1 AxisLineStyle, GridLinestyle, StrokeLineStyle, FrameLineStyle, and OutlineLineStyle 130 5.2.2 BasicStroke 133 5.3 Text Tags 133 5.3.1 Font 133 5.3.2 LabelTextStyle and ValueTextStyle 134 5.3.3 TextStyle 136 5.3.4 ShadowStyle 136 5.4 Tick Mark Tags 136 5.5 Miscellaneous Tags 137 5.5.1 DiscreteFillColor 137 5.5.2 MarkerStyle 137 5.5.3 ReferenceLineModel 141
126 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Supporting tags are used in many places and support many other tags to further define the visual aspects of a graph. A good example is the sas:Font tag, which is not defined at the top level but is nested in almost every tag that supports text descriptions. <sas:BarChart id="fontAttributes" model="bcTDMGrains3" scope="session" > <sas:BarChartModel > <sas:LegendModel label="Legend Label" labelPlacement="Right" placement="West" visible="true"> <sas:LabelTextStyle > <sas:Font bold="true" family="Helvetica" size="14.0" />
Here we can see that the sas:Font tag is nested at the fifth level of this graph. Because these supporting tags are everywhere in the graph models, we do not provide a complete list of corresponding dependent tags here. See the SAS Custom Tag Reference in the Web Technologies Community pages at http://support.sas.com for more information on these tags.
5.1 Fill Tags Fill styles enable you to define how to display the background of the graph area. This background could be a solid color or a gradient. There are four main fill tags: BackgroundFillStyle, FillStyle, FloorFillStyle, and WallFillStyle The following are attributes associated with the fill style tags.
Chapter 5: Supporting Tags 127
fillType The fillType attribute sets the type of fill. This example shows the value of fillType set to Gradient. Valid values: SolidColor Gradient Image ImageColorBlend ImageGradientBlend
<sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown" />
gradientBlendBeginColor The gradientBlendBeginColor attribute sets the color to use as the starting color in a gradient. This attribute is applicable only when used with fillType=“ImageGradientBlend”. (This attribute did not function with the tested release.)
gradientBlendEndColor The gradientBlendEndColor attribute, when used with fillType=“ImageGradientBlend”, defines the end color used in a gradient. (This attribute did not function with the tested release.)
128 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
gradientFillBeginColor The gradientFillBeginColor attribute sets the color to use as the starting color in a gradient. This attribute is applicable only when used with fillType=“Gradient”, as shown in the fillType example. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.) Requirements: fillType=“Gradient” <sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown"/>
gradientFillEndColor The gradientFillEndColor attribute, when used with fillType=“Gradient”, defines the end color used in a gradient, as shown in the fillType example. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.) Requirements: fillType=“Gradient” <sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown"/>
gradientFill The gradientFill attribute sets the directional property for the gradient, as shown in the fillType example. Valid values: LeftToRight BottomToTop FrontToBack DiagonalUp DiagonalDown
Chapter 5: Supporting Tags 129
Requirements: fillType=“Gradient” <sas:BackgroundFillStyle fillType="Gradient" gradientFillBeginColor="red" gradientFillEndColor="yellow" gradientFill="DiagonalDown" />
imageFillColor The imageFillColor attribute sets the color used to fill the area before the image is applied. This attribute can be used only when the fillType attribute is defined using one of the image types. (This attribute did not function with the tested release.)
imageFill The imageFill attribute defines how to display the image specified and can be used only when the fillType defines an image type. (This attribute did not function with the tested release.)
imageIcon The imageIcon attribute sets the image to use. This attribute can be used only when the fillType attribute is defined using one of the image types. (This attribute did not function with the tested release.)
solidBlendColor To define the color that is applied to the area after the image has been applied, use the solidBlendColor attribute. This attribute can be used only with fillType=“ImageColorBlend”. (This attribute did not function with the tested release.)
x The x attribute defines the x coordinate used with the image. (This attribute did not function with the tested release.)
y The y attribute defines the y coordinate used with the image.
130 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
(This attribute did not function with the tested release.) In general only the solid color fills function correctly with the tested release. Just be aware of this when constructing your own graphs.
5.2 Line Tags 5.2.1 AxisLineStyle, GridLineStyle, StrokeLineStyle, FramelineStyle, and OutlineLineStyle There are several different types of line tags to use. The AxisLineStyle, GridLineStyle and StrokeLineStyle tags affect the axis, grids and strokes. The FrameLineStyle and OutlineLineStyle tags (used in the following examples) control the frame and the outline of the referenced graph area. The FrameLineStyle tag sets attributes for the frame of the referenced graph area. In this example, the FrameLineStyle tag is nested within a sas:LegendModel tag.
<sas:FrameLineStyle color="red" thickness="5px" visibilityPolicy="true"/>
Chapter 5: Supporting Tags 131
The OutlineLineStyle tag sets attributes for the outline of the referenced graph area. In this example, the OutlineLineStyle tag is nested within a sas:DataElementStyles tag.
<sas:OutlineLineStyle color="red" thickness="3px" />
All of the Line tags share the following attributes.
color The color attribute defines the color to use for the line. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.)
<sas:AxisLineStyle color="red" SASGraphLineStyle="SASGRAPHLINE15" thickness="5px" visibilityPolicy="true"/>
132 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
thickness The thickness attribute defines the thickness or weight of the line. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
<sas:OutlineLineStyle color="red" thickness="3px" />
SASGraphLineStyle The SASGraphLineStyle attribute sets the type of line to use. The values include a solid line (SASGRAPHLINE1) and combinations of dashes, dots, and solids (SASGRAPHLINE2 through 46). Refer to the webAF Online Help for samples of the line styles. Valid values: SASGRAPHLINE1 through SASGRAPHLINE46
<sas:GridLineStyle color="red" SASGraphLineStyle="SASGRAPHLINE15" thickness="5px" visibilityPolicy="true"/>
Chapter 5: Supporting Tags 133
5.2.2 BasicStroke Another line style is the BasicStroke tag. This tag has the following attributes: dashPhase, dashSegmentsChanged, endCap, lineJoin, lineWidth, and miterLimit. (This tag did not function with the tested release.) A tag that can be nested in the BasicStroke tag is the DashSegment tag. This tag has one attribute, length. (This tag did not function with the tested release.)
5.3 Text Tags Most of the text tags do very similar things. The Font tag defines the type of font to use. The LabelTextStyle and ValueTextStyle tags describe labels and values in a graph. The base TextStyle tag works on general text elements. The ShadowStyle tag defines any shadows used with text.
5.3.1 Font The Font tag defines the type of font to use. It enables you to define such things as whether the font is bold or italic. It can adjust the font size and specify a font family such as Arial or Times New Roman. This tag has four attributes that are all shown in this one example. In this case, the Font tag has been nested inside the sas:LabelTextStyle tag for the sas:CategoryAxisModel.
<sas:Font bold="true" family="Helvetica" italic="true" size="14.0" />
bold The bold attribute takes a Boolean value and specifies whether the text should be bolded. Valid values: Boolean (True/False)
134 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
family You can define what font family you want to use by setting the family attribute. Valid values: <String> (java.awt.Font)
italic The italic attribute enables you to set the font to italic. Valid values: Boolean (True/False)
size The size attribute enables you to customize the font size to use with the text you are describing. Valid values:
5.3.2 LabelTextStyle and ValueTextStyle The next couple of tags are the LabelTextStyle and ValueTextStyle tags. They enable you to define how the text for labels and values should look. Each has only two attributes, both shown in this example. These have been nested inside the sas:LabelTextStyle tag for the sas:CategoryAxisModel.
<sas:LabelTextStyle color="red" justification="left" />
Chapter 5: Supporting Tags 135
<sas:ValueTextStyle color="red" justification="left" />
color The color attribute defines what color to use when displaying the text you are describing. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.)
justification The justification attribute enables you to set the justification properties of the text. Valid values: Left Right Center
136 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
5.3.3 TextStyle The TextStyle tag is very similar to the LabelTextStyle and ValueTextStyle tags. In addition to controlling the color and justification, you can also use this tag to set the angle of the text in relation to the baseline. Notice the text is to the left of the baseline.
<sas:TextStyle baselineAngle="50.0" color="red" justification="left" />
baselineAngle The baselineAngle attribute defines the angle at which to write the text. Valid values:
5.3.4 ShadowStyle The ShadowStyle tag is used to define shadows. There are four visual attributes: color, offsetX, offsetY, and softness. (This tag did not function with the tested release.)
5.4 Tick Mark Tags Two tags are responsible for describing tick marks in the graphs, MajorTickStyle and MinorTickStyle. The MajorTickStyle tag is responsible for all major tick marks, whereas the MinorTickStyle tag is responsible for all minor tick marks, if any. Each have two attributes, length and placement.
Chapter 5: Supporting Tags 137
length The length attribute sets the base length of the tick marks. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
placement The placement attribute enables you to define how the tick mark should be placed in relationship to the graph axes. Valid values: Inside Outside Across (None of these attributes functioned with the tested release.)
5.5 Miscellaneous Tags There are a few miscellaneous supporting tags, such as DiscreteFillColor, MarkerStyle and ReferenceLineModel.
5.5.1 DiscreteFillColor The DiscreteFillColor tag applies to data elements and has one attribute, value. (This tag did not function with the tested release.)
5.5.2 MarkerStyle The MarkerStyle tag enables you to describe the visual aspects of markers in plots. It has several attributes, as shown in the following example. This example shows the MarkerStyle tag nested inside a sas:DataElementStyles tag.
138 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:MarkerStyle color="red" connectionOrder="X" interpolation="Straight" size="20px" symbol="aster" />
color The color attribute defines the color to use for the markers. In the preceding example there are two data elements. Only the first data element (response) uses the red color specified in the attribute (in this example, this shows up as the bolder items). The second data element (shown as gray) uses a default color. Valid values: <String> (This value can be any valid Java java.awt.Color or hexadecimal value representing a color.)
connectionOrder To determine the order in which the data elements are connected, you can use the connectionOrder attribute. Valid values: Data X Y
Chapter 5: Supporting Tags 139
interpolation The interpolation attribute enables you to define whether and how the markers are connected. Valid values: None Default Straight StepLeft StepCenter
StepRight Spline VerticalNeedles HorizontalNeedles BoxPlot
size You can define the size of the markers using the size attribute. Valid values: <Measure> The <Measure> value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in
symbol There are many different shapes you can use for your markers. You can define these using the symbol attribute. Valid values: None, Circle, Plus, Triangle, Square, X, TriangleDown, Diamond, Aster, CircleBold, PlusBold, TriangleBold, SquareBold, XBold, TriangleDownBold, DiamondBold, AsterBold, CircleFilled, CrossFilled, TriangleFilled, SquareFilled, SaltireFilled, TriangleDownFilled, DiamondFilled, StarFilled, Venus, Mars, Earth, VenusBold, MarsBold, EarthBold, VenusFilled, MarsFilled, EarthFilled, Horizontal, Vertical, HorizontalBold, VerticalBold, RectangleHorizontalFilled, RectangleVerticalFilled, PlusX, CirclePlus, CircleX, SquarePlus, SquareX, SquareUp, SquareDown, SquareLeft, SquareRight, UpDown, LeftRight, DiamondPlus, DiamondX, Cross, Saltire, Star, CrossMaltese, Hash, Smash, Asterisk, TriangleLeft, TriangleRight, LessThan, GreaterThan, Tilde, Wreath, Union, Ibeam, Hex, Home, Heart, Tack, Sporal, Weave, HomeDown, FixedStar, Chain, Arrow, DiamondNarrow, HomeNarrow, HomeNarrowDown, Dagger, Flag, CircleTriangle, CircleTriangleDown, CircleOdd, ArrowWide, ArrowWideDown, CircleArrowWide, CircleArrowWideDown, Hourglass, TriangleLeftBold, TriangleRightBold, AsteriskBold, UnionBold, IbeamBold, HexBold,
140 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HomeBold, HeartBold, TackBold, SpiralBold, WeaveBold, HomeDownBold, FixedStarBold, ChainBold, ArrowBold, TriangleLeftFilled, TriangleRightFilled, HomeFilled, HomeDownFilled, DiamondNarrowFilled, HomeNarrowFilled, HomeNarrowDownFilled, FlagFilled, ArrowWideFilled, ArrowWideDownFilled, CircleArrowWideFilled, CircleArrowWideDownFilled, CircleTriangleFilled, CircleTriangleDownFilled, CircleOddFilled, HourGlassFilled, FemaleFigureFilled, MaleFigureFilled, RectangleHorizontal, RectangleVertical
5.5.3 ReferenceLineModel The ReferenceLineModel tag is normally used to support an axis definition.
<sas:ReferenceLineModel inFront="true" label="Goal" labelPlacement="outside" position="250000.0" visible="true" />
The following are the supporting attributes.
inFront The inFront attribute takes a Boolean value and places the reference line in front of or behind the graph (in this case bars). Valid values: Boolean (True/False)
label The label attribute enables you to define a label for the reference line.
Chapter 5: Supporting Tags 141
Valid values: <String>
labelPlacement The labelPlacement attribute defines where to put the label in relationship to the graph. Valid values: Inside Outside InsideHigh InsideLow
position To position the reference line at a specific point on the graph, use the position attribute. Valid values:
142 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
P a r t
2
Output Delivery System Chapter
6 Important Concepts for Getting Started with ODS and Java 145
Chapter
7 Creating Graphs 153
Chapter
8 Parameters for Colors 169
Chapter
9 Parameters for Text 207
Chapter 10 Other Parameters 241
144 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Part 2 is all about how to use more traditional SAS code, including the Output Delivery System (ODS), and Java together to get results that might not be possible with the defined SAS AppDev Studio custom tags. Many of the custom tags have limitations; however, that is not to say that ODS using a Java device does not have its own limitations. The following chapters cover some basics before diving deeper. We concentrate only on using SAS/GRAPH software and ODS with the Java device. There are many other publications that cover other uses of SAS/GRAPH software and ODS in more depth.
C h a p t e r
6
Important Concepts for Getting Started with ODS and Java 6.1 Java Scriptlet Code 146 6.2 General JSP Structure 146 6.3 General JSP Requirements 148 6.4 Connecting and Data Extraction 148 6.5 A Few Last Notes about Data 151
This chapter is designed to cover things that are common to almost all examples. After reading this chapter, you will be able to skip around to look over the graphs you are most interested in. Each of the graph examples is self-contained, so you will see some repetition of attributes. The following sections briefly explain some general concepts for using Java and SAS together in a JavaServer Page (JSP) file.
146 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Note: For brevity in this book, we have decided to use SocketListener and SubmitInterface objects. These objects utilize the SAS/CONNECT product and in general are easier and quicker to set up. The purpose of this book is to provide visual aids and information concerning what you can do with graphs using Java. In a production environment, you would not want to use the example or ® SubmitInterface objects. SAS 9 has extensive tools with which to create more robust applications.
6.1 Java Scriptlet Code When you combine HTML, Java, and SAS, you need some way to distinguish one from the other. There is no one translating Web system that will interpret all three of these languages without some way of keeping them separated. HTML consists of tags that you can use openly in a JSP, HTML page, and many other types of Web page files. However, to distinguish a section of code, such as Java, that may need to be interpreted differently, you need some way to set it apart. You do this by using scriptlet coding. This just means that you use <% and %> to open and close sections of code that need to be pure Java. To use SAS in a JSP file, you can use the SubmitInterface. The syntax is explained later in this chapter. What this object does is break down your SAS code into a long stream that is sent to the connected SAS server for interpretation of the code. Basically the file is read in by the application server and compiled, and then it all runs. So there is a bunch of stuff happening on your server to get this mixed JSP file to produce a graph.
6.2 General JSP Structure Java Server Pages and SAS can live and work together. However, there are several pieces you need along the way to make this happen. When you are getting started, easier is better. In a production environment, you need a more robust and complete approach. We have combined the use of SAS/CONNECT software, a SocketListener, and the sasads:Submit tag to write most of the ODS examples. This is an example of a complete JSP file that connects to SAS, creates a graph from an existing SAS data set, and sends it back for display.
Chapter 6: Important Concepts for Getting Started with ODS and Java 147
<%@taglib uri="http://www.sas.com/taglib/sasads" prefix="sasads"%> <%@ page import = "com.sas.servlet.util.SocketListener" %> <%@ page import = "com.sas.servlet.util.Util" %> <%@ page import = "com.sas.rmi.Connection" %> <sasads:Connection id="bbuConnection" scope="session" /> <% SocketListener socket = new SocketListener(); int port = socket.setup(); String host = (java.net.InetAddress.getLocalHost()).getHostAddress(); String archivePath="../assets/graph/"; String libraryPath = "C:\\SAS9_1_3\\SAS 9.1\\graph\\sample"; socket.start(); %> <sasads:Submit id="smbStreamingBar" display="none" connection="bbuConnection"> libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400; ods listing close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" ; proc gchart data=samples.grains; hbar country / sumvar=amount; run; quit; ods html close; <% socket.write(out); socket.close(); %>
148 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
6.3 General JSP Requirements The first piece we’ll look at are the lines required by JSP files when using Java code and tag libraries. At the very top of the sample JSP, you will notice a declaration of the tag library. In this case we’ve elected to use the sasads:Connection tag, which can be found in the SAS AppDev Studio 2 tag library. The sasads:Connection tag is discussed later in this chapter. <%@taglib uri="http://www.sas.com/taglib/sasads" prefix="sasads"%>
Next we need to import all the Java classes needed. Because of the way we wrote the Java code, these import statements are the minimum required for our examples. More import statements might be needed if you add additional Java functionality to the JSP. <%@ page import = "com.sas.servlet.util.SocketListener" %> <%@ page import = "com.sas.servlet.util.Util" %> <%@ page import = "com.sas.rmi.Connection" %>
6.4 Connecting and Data Extraction To communicate back to the data server, we have chosen to use SAS/CONNECT software and the sasads:Connection tag. This choice was made for pure ease of use. The sasads:Connection tag by default uses the SAS/CONNECT spawner. The default assumption is that the spawner runs on port 2323. When we use the defaults, the only things we need to do are give the connection object a name via the id statement and tell the application server how long this object should exist during execution via the scope statement. <sasads:Connection id="bbuConnection" scope="session" />
Next we define a little bit of HTML—not much, just enough to indicate the start of any output statements. After that the fun begins. We have Java scriptlet code (which is Java code embedded in a JSP and sometime intermingled with HTML). In this section we need to define a SocketListener Java object (for use in streaming back our graph output) and several Java variables to use later in the JSP. We need to use the SocketListener to grab the assigned port number, get the host address used for this application, set up the path to the archives or JAR files, and set a string representing the SAS library we will be assigning later. Finally, we start the socket.
Chapter 6: Important Concepts for Getting Started with ODS and Java 149
<% SocketListener socket = new SocketListener(); int port = socket.setup(); String host = (java.net.InetAddress.getLocalHost()).getHostAddress(); String archivePath="../assets/graph/"; String libraryPath = "C:\\SAS9_1_3\\SAS 9.1\\graph\\sample"; socket.start(); %>
Now that we have established our connection and opened up a socket for use, we can use the sasads:Submit tag (which uses the com.sas.sasserver.submit.SubmitInterface class) to send SAS code to the server to run. The tag needs to define a connection object for use. We have one already set up earlier in the page called bbuConnection. Now anywhere between the opening sasads:Submit tag and the close sasads:Submit tag we can write standard SAS Code. <sasads:Submit id="smbStreamingBar" display="none" connection="bbuConnection"> libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400; ods listing close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" ; proc gchart data=samples.grains; hbar country / sumvar=amount; run; quit; ods html close;
One of the first things most SAS programs need is a LIBNAME statement. Therefore we have used the Java variable we had set up earlier in the JSP page called libraryPath to assign the library “samples”. Next the SAS statements need to utilize the socket to stream its content back through to the browser. To do this, we use a FILENAME statement. The filename also needs two of the previously assigned Java variables, host and port, to complete the filename set up.
150 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
The GOPTIONS statement sets graphing options. The RESET option restores the defaults and can cancel global statements. In this example, we have chosen to reset all graphical options and cancel all global statements. An important element in SAS when delivering graphs to a system based on Java is to define the appropriate device to use. For the purpose of this book, the device we use is Java, which we specify with DEVICE=JAVA. The XPIXELS and YPIXELS options help to define the display area in pixels, where XPIXELS is the width and YPIXELS the height. These options are device-dependent and can only use values between 0 and 99999. Our first instruction to ODS is to close the listing. This allows us to open ODS to direct the output back to HTML. We do this with the ODS HTML statement. The ODS HTML statement has three options defined in this example: BODY, RS, and CODEBASE. The BODY=SOCK option tells the ODS statement that the body of the output will stream the results back to the browser using the filename sock. With the RS=NONE (record_separator) option, the ODS output is automatically formatted for the operating system where the SAS job runs. When using DEVICE=JAVA with ODS, you need to define the location of the graph applet JAR files using the CODEBASE option. In ® a standard Windows installation of SAS 9 these JAR files can be found here: /SAS9.1/common/applets. This path is called the ® archivePath in the example. There was a change from SAS 8.2 to SAS 9 so that you now only have to define the path to the directory where you store the JAR files for the applets. The PROC GCHART statements are used to produce the graph. Finally, we need ODS to close the HTML output. This prevents any following SAS statements from adversely affecting the output. In the LIBNAME, FILENAME and the ODS HTML statements, we used Java variables inside of scriptlet code. These are not required. You could just code the values. The Java variables provide a convenient way to put code that could change near the top of the JSP file. We believe that once you get used to using scriptlet variables, you will find them very handy. Remember that all these examples were run locally. If you are running on a production, test, or development server, your paths might be somewhat different, and you need to be sure to copy the correct JAR files over to the server. For example, if you are running on a Tomcat server and you want these JAR files to be accessible only by your current application, you might try putting them here: /webapps/<myCurrentApplication>/assets/graphApplets or something similar. For this example, we have used /webapps/BBU/assets/graph.
Chapter 6: Important Concepts for Getting Started with ODS and Java 151
Now all that is left to do is to clean up the socket so it is not left open. Then end the HTML output section. <% socket.write(out); socket.close(); %>
In summary, you need to define the tag library, import Java classes, open a connection, get a socket, and write some SAS code. It’s always good form to close any open sockets, connections, and anything else that might be open.
6.5 A Few Last Notes about Data The data we used in this book is the standard samples data sets that come with a regular installation of SAS/GRAPH software. This data can be found in /SAS9.1/graph/sample. In a SAS program, if you omit the DATA= option, the procedure uses the most recently created SAS data set in the current SAS session. If there was not a previously created data set, then a SAS error occurs and the procedure stops. When running SAS/GRAPH procedures, the SAS system applies a lock to the input data set. This lock prevents another user or process from updating the data at same time. If, however, the data changes while you are using it, unpredictable results can occur, as well as the processing ending in errors.
152 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
7
Creating Graphs 7.1 Types of Bar Charts 154 7.1.1 Horizontal Bar Charts 154 7.1.2 Vertical Bar Charts 155 7.2 Types of Pie Charts 156 7.2.1 Pie Charts 157 7.2.2 Donut Charts 158 7.2.3 Star Charts 159 7.3 Contour Plots 159 7.4 Types of Maps 160 7.4.1 Block Maps 160 7.4.2 Choropleth Maps 161 7.4.3 Prism Maps 162 7.4.4 Surface Maps 163 7.5 Types of Plots 163 7.5.1 Bubble Plots 164 7.5.2 Plots 165
154 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
7.6 Three-Dimensional Graphs 166 7.6.1 Scatter Plots 166 7.6.2 Surface Plots 167
This chapter provides an overview of the types of graphs, charts, plots and maps that are possible with the SAS Java device. It is meant to show you how to use the different graph applets, rather than providing an exhaustive sampling of all SAS graphing techniques.
7.1 Types of Bar Charts Bar charts represent statistics over one or more variables. In the example, the amount is summarized per country. This gives the user a way to interpret the differences of amounts across countries.
7.1.1 Horizontal Bar Charts Bar charts use the SAS GCHART procedure. The action statement names the type of chart, the data being charted, and any options.
proc gchart data=samples.grains; hbar country / sumvar=amount; run;
Chapter 7: Creating Graphs 155
In the horizontal bar chart example, we are creating a chart using the country and amount variables. HBAR is the type of chart, and COUNTRY is the category variable we are going to chart. These elements of the code are required. A slash separates the category variable from the options. We want to chart the AMOUNT variable for each COUNTRY. To do this we use the SUMVAR= option. To make our horizontal bar chart three-dimensional, we simply change the type of chart to HBAR3D. All the other statements stay the same.
proc gchart data=samples.grains; hbar3d country / sumvar=amount; run;
7.1.2 Vertical Bar Charts For a vertical bar chart, change the type of chart to VBAR. All the other statements stay the same.
156 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gchart data=samples.grains; vbar country / sumvar=amount; run;
Use the chart type VBAR3D to create a three-dimensional vertical bar chart. All the other statements stay the same.
proc gchart data=samples.grains; vbar3d country / sumvar=amount; run;
7.2 Types of Pie Charts In general, pie and donut charts show the user the relationship of each summarized item against the total of all summarized items. For instance, in this example we see that when compared to the amounts for US and Canada, Australia holds a small percentage of the total of all types of grains. The defaults that SAS uses for the positioning of the slices and the color can be changed with options that we review later.
Chapter 7: Creating Graphs 157
7.2.1 Pie Charts
proc gchart data=samples.grains; pie country / sumvar=amount; run;
Like the bar charts, pie and donut charts use the SAS GCHART procedure. The action statement defines the type of chart, the data being charted, and any options. In the pie chart example, we are creating a pie chart with the COUNTRY variable. PIE is the type of chart, and COUNTRY is the category variable we are going to chart. These are required. A slash separates the category variable from the options. We want to chart the AMOUNT variable for each COUNTRY. To do this we use the SUMVAR= option. proc gchart data=samples.grains; pie country / sumvar=amount; run;
158 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
To make a three-dimensional pie chart, change the type of chart to PIE3D. All the other statements stay the same.
proc gchart data=samples.grains; pie3d country / sumvar=amount; run;
7.2.2 Donut Charts For a donut chart, change the type of chart to DONUT. All the other statements stay the same.
proc gchart data=samples.grains; donut country / sumvar=amount; run;
Chapter 7: Creating Graphs 159
7.2.3 Star Charts A star chart is a cross between a vertical bar chart and a pie chart, with the data points radiating from a center point. The code is very similar to a pie chart, but uses the chart type of STAR. The star chart is not fully supported and in our testing produced what looked like a pie chart. proc gchart data=samples.grains; star country / sumvar=amount; run;
7.3 Contour Plots Contour plots use lines or patterns to represent levels of magnitude of variable(s) plotted on the horizontal and vertical axes. They are useful when examining trends where the level of the data, not the shape, is important.
proc gcontour data=work.clay; plot y*x=pct_clay / levels=10 to 90 by 5 ; run;
A contour plot uses the SAS GCONTOUR procedure. In this example, we are using a subset of the samples.clay data set as our sample data. Note that in this example a chunk of the graph appears to be missing. This is due to missing values in the data and is not an error in the graph. For a simple contour plot, the required action statement PLOT is used.
160 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
In our example, we want to run the contour plot using the X, Y and PCT_CLAY variables. The X variable is plotted on the horizontal axis. The Y variable is plotted on the vertical axis. The PCT_CLAY variable plots the contour lines and can be thought of as a type of z axis.
7.4 Types of Maps Maps can be used to summarize data by physical area, show trends in geographic regions, and highlight extremes. In these examples, the graphs show the concentration of sites in a state.
7.4.1 Block Maps Block maps use the SAS GMAP procedure. With the GMAP procedure, you are required to define a map data set and a response data set. Here we have used the U.S. map (maps.us), and the response data set is samples.rgnsites. You can use the same data set as both the map and response; see the SAS Help on the GMAP procedure for details.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites; run;
The next action statements help define the visual aspects of the map by naming the variable which joins the map data, the type of map and the data being mapped, and any additional options.
Chapter 7: Creating Graphs 161
The ID statement is required and names a variable that must be present in both map and response data definitions. It is used to join the data sets and define the mapped region; in this case, we use the STATE variable. For a simple block map, the required BLOCK statement represents the type of map and names the variable being mapped. Here we have defined the BLOCK statement and named the SITES variable (which defines the height of the blocks on the map).
7.4.2 Choropleth Maps Choropleth two-dimensional maps fill in map areas with combinations of patterns and colors to represent the data values. To make a choropleth map, just change the type of map to CHORO from BLOCK. All the other statements stay the same.
proc gmap map=maps.us data=samples.rgnsites; id state; choro sites; run;
162 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
7.4.3 Prism Maps Prism three-dimensional maps display data by raising the map areas and filling them with combinations of patterns and colors. To create a PRISM Map, change the type of map to PRISM from CHORO in the PROC GMAP definition. All other statements remain the same.
proc gmap map=maps.us data=samples.rgnsites; id state; prism sites; run;
Chapter 7: Creating Graphs 163
7.4.4 Surface Maps Surface maps are only partially supported. In our testing they displayed a map similar to a choropleth map.
proc gmap map=maps.us data=samples.rgnsites; id state; surface sites; run;
7.5 Types of Plots A plot shows the relationship of one variable to another. It is useful for displaying long series of data for trends and patterns. Plots also have the option to create a secondary comparison axis on the right side of the chart. This allows the user to compare and contrast three variables where one axis stays the same. In our examples, we’re looking at the energy consumed by year in one or two currencies. In order to do this, we had to create a work data set with additional variables. We used the samples.energy1 data set to create the work.energyPrice data set.
164 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc sql; create table work.energyPrice as select year as year, consumed as energy, consumed*.03 as dollars, consumed*.03*125 as yen from samples.energy1; quit;
7.5.1 Bubble Plots Bubble plots use the SAS GPLOT procedure. Using the graph type of BUBBLE, we define the three chart variables. In this example, we have used DOLLARS as the y axis, YEAR as the x axis, and ENERGY as the size of the bubble.
proc gplot data=work.energyPrice; bubble dollars*year=energy; run;
Use a second bubble statement, BUBBLE2, to create a bubble plot with a second y axis on the right side to compare another variable on the same graph. The BUBBLE2 statement produces a graph to compare the original DOLLARS variable to the YEN variable across the same YEAR and ENERGY.
Chapter 7: Creating Graphs 165
proc gplot data=work.energyPrice; bubble dollars*year=energy; bubble2 yen*year=energy; run;
7.5.2 Plots A regular plot is very similar to a bubble plot, except there is no variable to affect the size of the plot marker. In a plot chart all the markers are the same size. Use a PLOT statement instead of the BUBBLE statement. A plot denotes the crossing or intersection of the two variables. Here we have chosen to plot the intersection between the variables DOLLARS and YEAR.
proc gplot data=work.energyPrice; plot dollars*year; run;
A plot can also have a second y axis to use as a comparison value. You can accomplish this by using the PLOT2 statement. In this example, we are comparing dollars to yen, so in the PLOT2 statement we use YEN and YEAR as our comparison variables.
166 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gplot data=work.energyPrice; plot dollars*year; plot2 yen*year; run;
7.6 Three-Dimensional Graphs The G3D procedure produces three-dimensional graphs. This procedure enables you to create a graph which plots the intersection of three variable values. All three variables must be numeric.
7.6.1 Scatter Plots In the three-dimensional scatter plot example, we are creating a scatter plot with its type defined as SCATTER and the data variables PETALLEN, PETALWID, and SEPALLEN. Three numeric variables are required. The order of the variables determines the axis. The first variable is always plotted on the y axis. The second variable is always plotted on the x axis. The last variable is plotted on the z axis. The pattern is y*x=z.
proc g3d data=samples.giris; scatter petallen*petalwid=sepallen; run;
Chapter 7: Creating Graphs 167
7.6.2 Surface Plots The three-dimensional surface plot can be created using the SAS G3D procedure. The samples.hat data set contains three variables used by the G3D procedure. Variable Y represents the y axis, X the x axis, and Z the z axis. All three variables contain numeric values, which creates a gridlike structure on the graph.
proc g3d data=samples.hat; plot y*x=z; run;
168 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
8
Parameters for Colors 8.1 ODS Parameters 170 8.1.1 Non-supported parameters 181 8.2 GOPTIONS 182 8.2.1 Non-supported options 186 8.3 PROC GCHART 186 8.3.1 Summary 192 8.3.2 Non-supported parameters 193 8.4 PROC GCONTOUR 193 8.4.1 Summary 197 8.5 PROC GMAP 197 8.5.1 Summary 199 8.6 PROC GPLOT 199 8.6.1 Summary 204 8.7 PROC G3D 204 8.7.1 Summary 205 8.7.2 Non-supported parameters 205
170 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
8.1 ODS Parameters You can use ODS parameters to customize the appearance of your graphs. In this chapter we use the more common color parameters to dramatically change the look of the basic graphs. In the ODS statement, the PARAMETERS= option defines parameters to be passed to a Java applet. Not all parameters work with all the applets. In each parameter section, we note where the parameter is applicable. The parameters are specified in the PARAMETERS= option in the ODS HTML statement as name/value pairs. The applet parameter names are not case sensitive. However, some applet parameter values are case sensitive. In this section, we show only the ODS HTML code. To see the ODS statements in context, review the beginning or ending chapters of this book. Full examples are provided in those sections.
AMBIENT The AMBIENT parameter specifies the nondirectional light on the graph. The valid ranges are from 0.0 to 1.0, with a default of 0.4. This parameter is valid when producing Contour applets or when using PROC GCONTOUR or PROC G3D with plots. The AMBIENT parameter is used with the DIRECT parameter. When either is used, the other, if not specified, is implied. Their values should equal 1.0. Since the default for AMBIENT is 0.4, this means that the default for DIRECT is 0.6. If you set the AMBIENT parameter to something higher than 0.4, you need to also adjust the setting for the DIRECT parameter. This is because DIRECT takes precedence. If DIRECT is not defined, it assumes a value of 0.6 and automatically adjusts AMBIENT to 0.4 so that in combination they equal 1.0. The following example compares a PROC G3D plot with and without the AMBIENT parameter. The example on the left (code not shown) is using the default settings for the parameters AMBIENT and DIRECT. The example on the right is using an AMBIENT setting of 0.8 and a DIRECT setting of 0.2.
Chapter 8: Parameters for Colors 171
Default Settings
AMBIENT=0.8 and DIRECT=0.2
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("AMBIENT"="0.8") parameters=("DIRECT"="0.2");
BACKDROPCOLOR The BACKDROPCOLOR parameter sets the color of the walls and floor of the graph. This worked in our examples using PROC GCONTOUR, PROC GCHART, and PROC G3D. However, it did not work with PROC GMAP.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("BACKDROPCOLOR"="yellow");
172 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
BACKIMAGE You can use the BACKIMAGE parameter to place an image in the background of the graphic area inside the applet. In this example, we can clearly see that the map portion of the applet is the graphical area and contains the background image. On the other hand, the legend, which is still part of the applet, does not contain any portion of the image. This parameter does not work with PROC GCHART. ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=( "backimage"="http://localhost:8095/BBU/images/earth_dim.gif");
By default, the BACKIMAGE parameter scales to fit the graphical region. Use the DRAWIMAGE parameter to change the location.
Chapter 8: Parameters for Colors 173
COLORSCHEME You can use a predefined series of colors for your chart by using the COLORSCHEME parameter. The GOPTIONS COLORS= option also specifies a string of colors to use in the chart. If both are specified, the GOPTIONS option overrides any color scheme. Valid values: Autumn, Bright Carnival Commerce Festival Grayscale Industry Magellan Neon
Ocean Pastel Picnic Pine Seaside Terra Wheat Woodland
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("colorscheme"="GRAYSCALE");
Note: As of SAS 9.1.3, the COLORSCHEME parameter is only partially supported when used with bar charts. This should be corrected with SAS 9.2. This parameter is also supported by the Graph applet.
DIRECT The DIRECT parameter specifies the light intensity from direct light. The valid range is from 0.0 to 1.0. This parameter is used with the parameter AMBIENT. See the section on the AMBIENT parameter earlier in this chapter for details.
174 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
DRAWIMAGE The DRAWIMAGE parameter is used with the BACKIMAGE parameter to specify the location of the image in the applet area. There are four valid options: CENTER, POSITION, SCALE, and TILE. For SAS 9.1.3, the default position when using the DRAWIMAGE parameter with PROC GMAP is centered, as shown below. CENTER: Notice that the background image here is the image of the world. However, it is behind the current map and so is effectively hidden. You can see the rectangle behind the map, which is where the image is.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=( "backimage"="http://localhost:8095/BBU/images/earth_dim.gif" "drawimage"="center");
POSITION: The position of the background image here is similar to that for the CENTER option in that it is hidden behind the map. The POSITION option can also be used with the IMAGEPOSY and IMAGEPOSX parameters to place the image in a specific location within the graphic area.
Chapter 8: Parameters for Colors 175
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=( "backimage"="http://localhost:8095/BBU/images/earth_dim.gif" "drawimage"="position");
SCALE: This example shows the background image scaled to fit the area reserved for the map output.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=( "backimage"="http://localhost:8095/BBU/images/earth_dim.gif" "drawimage"="scale");
TILE: This example shows the background image tiled throughout the reserved map output area.
176 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=( "backimage"="http://localhost:8095/BBU/images/earth_dim.gif" "drawimage"="tile");
GRADIENTBACKGROUND, GRADIENTENDCOLOR, and GRADIENTSTARTCOLOR You can use the GRADIENTBACKGROUND parameter to override any previously set gradients applied to the applet’s background. You can also use it to define the gradient’s orientation. Valid options to use with this parameter are TRUE, FALSE, VERTICAL, and HORIZONTAL. The TRUE and FALSE options allow you to either retain a previously set GRADIENTBACKGROUND parameter or dismiss it. The VERTICAL and HORIZONTAL options define the orientation of the gradient colors defined with the GRADIENTENDCOLOR and GRADIENTSTARTCOLOR parameters. In the tested release, gradients did not work with the Graph applet or bar charts. These examples show the four different parameter values.
TRUE
FALSE
VERTICAL
HORIZONTAL
Chapter 8: Parameters for Colors 177
The GRADIENTENDCOLOR and GRADIENTSTARTCOLOR parameters are used with the GRADIENTBACKGROUND HORIZONTAL or VERTICAL options. These two parameters define the color to use at the starting and ending points of the gradient. The starting points are from the top down for the VERTICAL option and from left to right for the HORIZONTAL option. So if you define red as the start color and yellow as the ending color with GRADIENTBACKGROUND=VERTICAL, the red will turn to yellow from the top down. With the HORIZONTAL option, red will start the gradient on the left and yellow will end the gradient on the right. The default start color is white and the default end color is blue. Also, if the parameter BACKIMAGE is used, gradient parameters are ignored. ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("gradientbackground"="vertical" "gradientstartcolor"="red" "gradientendcolor"="yellow"); ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("gradientbackground"="vertical" "gradientstartcolor"="yellow" "gradientendcolor"="red");
LIGHTING The LIGHTING parameter specifies the position of the light source. There are four valid options for use with this parameter: HEADLIGHT, OVERHEAD, NORTHEAST, and SOUTHEAST. The default value is HEADLIGHT. The following examples show the different options. The LIGHTING parameter is supported only with the Contour applet.
178 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HEADLIGHT
OVERHEAD
NORTHEAST
SOUTHEAST
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LIGHTING"="HEADLIGHT"); ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LIGHTING"="OVERHEAD"); ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LIGHTING"="NORTHEAST"); ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LIGHTING"="SOUTHEAST");
SHOWBACKDROP The SHOWBACKDROP parameter has two valid values, TRUE or FALSE, which allow or disallow the walls and floor to be shown on the graph. Like the LIGHTING parameter, this is supported only with the Contour applet.
Chapter 8: Parameters for Colors 179
TRUE
FALSE
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("SHOWBACKDROP"="FALSE");
TIPBACKCOLOR The TIPBACKCOLOR parameter specifies the background color of the data tips. This parameter is supported by the following procedures: G3D, GCONTOUR, and GMAP. In this example, we have changed the value of the TIPBACKCOLOR parameter to RED. The default color is yellow.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("TIPBACKCOLOR"="RED");
180 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
TIPBORDERCOLOR The TIPBORDERCOLOR parameter specifies the color of the border around the data tip area. This parameter is supported by PROC G3D and PROC GCONTOUR. In this example, we have changed the value of the TIPBORDERCOLOR parameter to RED. The default color is black.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("TIPBORDERCOLOR"="RED");
TIPTEXTCOLOR The TIPTEXTCOLOR parameter defines the color of the data tip text. This parameter works with PROC G3D (Surface), PROC GCONTOUR, and PROC GMAP. In this example, we have changed the value of the TIPTEXTCOLOR parameter to RED. The default color is black.
Chapter 8: Parameters for Colors 181
Curiously, with PROC GMAP this parameter also changes the border color.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("TIPTEXTCOLOR"="RED");
8.1.1 Non-supported parameters ®
Not all ODS color parameters from SAS 8.2 are available in SAS 9. The parameters ® listed here are ignored in SAS 9. BACKCOLOR
The BACKCOLOR parameter specifies the background color of the applet area. This item is no longer supported with ® SAS 9. There are alternatives, however, using the procedure options.
OUTLINECOLOR
The OUTLINECOLOR parameter defines the color to use for ® outlines of graphs. The SAS 9 documentation lists this as a ® valid option; however, it has been dropped for SAS 9 in lieu of using the SAS/GRAPH options for OUTLINECOLOR.
182 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
8.2 GOPTIONS This section covers color options for the SAS/GRAPH GOPTIONS statement. You can use these options to control the display. Some of these options produce results that are similar to those for the ODS color parameters. ®
Colors in these options are defined as SAS color names. Refer to SAS 9 documentation for valid examples.
CBACK The CBACK option defines the background color of the graph area.
goptions reset=all device=java xpixels=600 ypixels=400 cback=red;
Chapter 8: Parameters for Colors 183
COLORS The COLORS option specifies the foreground colors. These colors are used if the program does not define the colors elsewhere. In this example, there are three types of grains, but only two colors. In the COLORS option we list only two colors. SAS cycles through the colors defined, repeating as necessary. In our example, this makes corn and wheat use the same color. goptions reset=all device=java xpixels=600 ypixels=400 colors=(purple green);
184 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CTEXT The CTEXT option specifies the default color for all text and the border. If the CTITLE option is also used, CTITLE overrides the CTEXT option for titles, notes, footnotes, and the border. Other specifications for text in the SAS statements also override the value of CTEXT. When using the CTEXT or CTITLE options, you need to also specify USEGOPT in an ODS statement. goptions reset=all device=java xpixels=600 ypixels=400 ctext=purple ctitle=red; ods listing; ods html close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>"; ods usegopt; title "CTEXT and CTITLE GOPTIONS"; proc gchart data=samples.grains; hbar3d country / sumvar=amount; run; quit; ods html close;
CTITLE To specify the title color, you can use the CTITLE option. This option can also specify the color for footnotes, notes and borders. See the section on the CTEXT option for an example.
Chapter 8: Parameters for Colors 185
IBACK The IBACK option defines an image to be used in the background area of the graph space. This option is used in conjunction with the IMAGESTYLE option. In the tested release, this did not work with PROC GCONTOUR.
goptions reset=all device=java xpixels=600 ypixels=400 iback='http://localhost:8095/BBU/images/earth_dim.gif' imagestyle=fit;
IMAGESTYLE The IMAGESTYLE option helps to specify how to display the image used with the IBACK option. This option has two possible values: FIT and TILE. The FIT setting fits the single image to the graphical area. The TILE setting uses the original image size and repeats it to fill the graphical area.
186 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
goptions reset=all device=java xpixels=600 ypixels=400 iback='http://localhost:8095/BBU/images/earth_dim.gif' imagestyle=tile;
8.2.1 Non-supported options Some options for the GOPTIONS statement are not supported by the Java device driver. CBY CPATTERN
The CBY option defines the color of the BY lines. The CPATTERN option specifies the default color for PATTERN definitions.
CSYMBOL
The CSYMBOL option sets the color for the SYMBOL defined.
IMAGEPRINT/ NOIMAGEPRINT OFFSHADOW
The IMAGEPRINT/NOIMAGEPRINT options allow and disallow image output. The OFFSHADOW option controls the height and width of the drop shadow used with the legend frames.
TRANSPARENCY/ NOTRANSPARENCY
The TRANSPARENCY/NOTRANSPARENCY options specify whether or not to display the background of the graphic as transparent.
8.3 PROC GCHART This section covers defining colors by modifying the PROC GCHART parameters. For each parameter, we provide information on what the parameter does, what it looks like, and how to use it. At the end, a summary table shows which options are valid with the various types of charts. The syntax of the parameter is shown in a code box following the example. In all cases, the parameter is coded in the PROC GCHART statement. For the standard graph types, we show only the parameter part of the statement. If the example is an unusual graph, we include the full code and highlight the parameter syntax. The following code is a standard three-dimensional horizontal bar graph. The color parameter is highlighted. proc gchart data=samples.grains; hbar3d country / sumvar=amount cautoref=red autoref; run; quit;
Chapter 8: Parameters for Colors 187
CAUTOREF The CAUTOREF parameter, in conjunction with the AUTOREF parameter, defines the color to use for the reference lines drawn at the major tick marks. In the example, the tick marks are along the x axis denoted by AMOUNT. If CAUTOREF is not defined, the CAXIS parameter value or the first color in the color list is used by default. cautoref=red autoref
CAXIS The CAXIS parameter in the PROC GCHART statement specifies the color for the response and the midpoint axis area frame if there is one. This parameter can also be used to specify the default color for all the reference lines.
caxis=red
188 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CERROR When the graph uses the error bar options, the CERROR parameter specifies the color of error bars. The default color is the response axis color.
proc gchart data=samples.fitness; hbar3D age / type =mean sumvar=heart discrete frame errorbar=bar clm=95 cerror=red; run; quit;
CFILL The CFILL parameter is used with a threedimensional pie chart to define a single color for all patterns in the pie chart. This option makes all the slices in the pie the same color. The default for a threedimensional pie is a solid fill pattern. The CFILL and FILL parameters can be specified together to produce specified color hatching. With a threedimensional pie chart, the FILL is limited to solid. cfill=red
Chapter 8: Parameters for Colors 189
CFRAME/CFR The CFRAME parameter defines the background color of the filled axis area or the three-dimensional backplane in the threedimensional charts. This parameter can also be defined using the CFR abbreviation.
cframe=red
COUTLINE The COUTLINE parameter, when used with the PROC GCHART statement, defines the color to use for all bar and slice outlines. The default color is the foreground color. You can also specify SAME to match the color of the bars or slices. To define the outline of all bars or bar segments as well as the legend values in the subgroup legend, you can use the COUTLINE parameter.
coutline=red
190 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CREF/CR The CREF parameter represents the reference line color. This parameter can also be defined using the CR abbreviation.
cref=red autoref
CTEXT The CTEXT parameter specifies the color to use for all text. The CTEXT parameter for PROC GCHART allows you to set the color for all the text on the chart. This text includes the labels, headings, and arrows if they are used.
ctext=red
FILL The FILL parameter specifies the pattern for all slices in the pie chart. The default value is SOLID. This parameter is only partially supported by the Java device driver. It has two options: SOLID or X (which represents the number of times to rotate a hatch pattern).
Chapter 8: Parameters for Colors 191
The SOLID option is the only one supported. See the section on the CFILL parameter for an example of how to fill a pie chart.
INVISIBLE The INVISIBLE parameter enables you to hide one or more values. In this example, the pie slice and the label for the values listed are invisible in the pie chart. The values must exactly match the existing midpoints, including the case of character midpoints. When using multiple values, separate them with a blank space.
invisible='Canada'
MATCHCOLOR The MATCHCOLOR parameter in PROC GCHART sets the label color to match the slice color. This parameter overrides the color defined in the CTEXT parameter.
Matchcolor
192 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
OTHERCOLOR The OTHERCOLOR parameter defines the color to use with pie slices that are defined by the OTHER parameter.
other=50 othercolor=red
8.3.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D VBAR VBAR3D
CAUTOREF
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D VBAR VBAR3D
CREF
CAXIS
CERROR
CFILL
CFRAME
3
COUTLINE
3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3
3 3 3 3
3 3 3 3
3 3 CTEXT
3 3 3 3 3 3 3 3
3 3 INVISIBLE
MATCHCOLOR
OTHERCOLOR
3
3
3
3 3
3 3
3 3
Chapter 8: Parameters for Colors 193
8.3.2 Non-supported parameters Some parameters are not supported by the Java device driver. If an alternative is available, it is listed in the description. IFRAME
IMAGESTYLE
The IFRAME parameter specifies an image file to use on the chart frame. If you need to define something like this, consider using the ODS options such as BACKIMAGE, DRAWIMAGE, IMAGEPOSX, and IMAGEPOSY. The IMAGESTYLE parameter defines the way to display the image defined by the IFRAME parameter. Since IFRAME is not supported by the Java device driver, neither is this parameter.
8.4 PROC GCONTOUR The PROC GCONTOUR parameters that affect colors are shown in this section. At the end a summary table shows which options are valid with the various types of charts.
CAUTOHREF The CAUTOHREF parameter, in conjunction with the AUTOHREF parameter, defines the color to use for the reference lines drawn at the major horizontal tick marks. If CAUTOHREF is not defined, the CAXIS parameter value or the first color in the color list is used by default. An example of horizontal reference lines and the CAUTOHREF parameter can be seen in the PROC GPLOT examples.
CAUTOVREF The CAUTOVREF parameter, in conjunction with the AUTOVREF parameter, defines the color to use for the reference lines drawn at the major vertical tick marks. If CAUTOVREF is not defined, the CAXIS parameter value or the first color in the color list is used by default. An example of vertical reference lines and the CAUTOVREF parameter can be seen in the PROC GPLOT examples.
194 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CAXIS The CAXIS parameter in the PROC GCONTOUR statement specifies the color for the response and the midpoint axis area frame if there is one. This parameter can also be used to specify the default color for all the reference lines. The default color is the second color in the current color list.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 caxis=yellow; run;
CFRAME/CFR The CFRAME parameter defines the background color of the filled axis area or the three-dimensional backplane. This parameter can also be defined using the CFR abbreviation.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 cframe=yellow; run;
Chapter 8: Parameters for Colors 195
CHREF/CH The CHREF parameter specifies the color of the reference lines that run perpendicular to the horizontal axis. This parameter can take a single color or a color list. The default color if CHREF is not defined is the value of the CAXIS parameter, if it is defined. Otherwise, it is the first color in the current color list. This parameter can also be defined using the CH abbreviation.
CLEVELS The CLEVELS parameter specifies a color or list of colors to use for the contour lines. The default colors used come from the current color list. In our example, we specified colors to override the defaults. You can give a gradiant appearance to your contours by using this parameter.
From color list
Defined by CLEVELS
proc gcontour data=samples.clay; plot x*y=pct_clay / levels=10 to 90 by 5 clevels='red' 'orange' 'yellow'; run;
196 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
COUTLINE The COUTLINE parameter specifies the color for outlining the filled areas of the plot. This parameter must be used with the PATTERN option; otherwise it is ignored. Without the PATTERN option, the default color is black. With the PATTERN option, the default color is the foreground color or the first color in the current color list.
CTEXT The CTEXT parameter in the PROC GCONTOUR statement specifies the color to use for all text. The default color is taken first from a CTEXT option on the GOPTIONS statement if there is one defined. Otherwise, it is the first color in the current color list.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 ctext=red; run;
CVREF/CV The CVREF parameter specifies the color of the reference lines that run perpendicular to the vertical axis. This parameter can take a single color or a color list. The default color if CVREF is not defined is the value of the CAXIS parameter, if it is defined. Otherwise, it is the first color in the current color list. This parameter can also be defined using the CV abbreviation.
Chapter 8: Parameters for Colors 197
8.4.1 Summary The following tables show which parameters can be used with a specific type of chart. Chart Type BLOCK
CAUTOHREF
Chart Type BLOCK
COUTLINE
CAUTOVREF
CTEXT
CAXIS
CFRAME
3
3
CHREF
CLEVELS
3
CVREF
3
8.5 PROC GMAP This section covers defining colors by modifying the PROC GMAP parameters. For each parameter, we provide information on what the parameter does, what it looks like, and how to use it. At the end, a summary table shows which options are valid with the various types of charts. The syntax of the parameter is shown in a code box following the example. In all cases, the parameter is coded in the PROC GMAP statement. Only the parameter part of the statement is shown. The following code is a standard map graph. The color parameter is highlighted. proc gmap map=maps.us data=samples.rgnsites; id state; block sites / cblkout=red; run;
198 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CBLKOUT The CBLKOUT parameter defines the color to use to outline all blocks. The default color if the PATTERN option is used is SAME, or the color of the interior of the blocks. If there is no PATTERN option defined, then the default color is the foreground or the first color in the current color list. This option is not supported when the shape is defined as CYLINDER.
cblkout=red
CEMPTY The CEMPTY parameter defines the outline color to use when an area of the map is empty. (This parameter did not function with the tested release.)
COUTLINE The COUTLINE parameter, when used with the PROC GMAP statement, defines the color to use for all outlines. The default color is the foreground color. You can also specify SAME to use the same interior pattern color.
coutline=red
Chapter 8: Parameters for Colors 199
CTEXT The CTEXT parameter enables you to set the color for all the text on the map.
ctext=red
8.5.1 Summary The following table shows which parameters can be used with specific types of charts. Chart Type BLOCK CHORO PRISM SURFACE
CBLKOUT
3
CEMPTY
COUTLINE
CTEXT
3 3 3
3 3 3
8.6 PROC GPLOT In this section, we look at parameters that you can use to modify colors in PROC GPLOT. At the end, a summary table shows which options are valid with the various types of charts. The syntax of the parameter is shown in a code box following the example. In all cases, the parameter is coded in the PROC GPLOT statement. Each example uses the same basic code to produce the graph. The full procedure statement is shown in the following code box.
200 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gplot data=work.energyPrice; bubble dollars*year=energy / bcolor=red; run;
BCOLOR The BCOLOR parameter defines the color to use for the bubbles in a bubble plot. The default color when BCOLOR is omitted is the first color in the current color list.
bcolor=red
CAUTOHREF The CAUTOHREF parameter is used to define the color of the horizontal reference lines. The default colors are either the value of the CAXIS parameter if it is used, or the first color in the current color list.
autohref cautohref=red
Chapter 8: Parameters for Colors 201
CAUTOVREF The CAUTOVREF parameter is used to define the color of the vertical reference lines. The default colors are either the value of the CAXIS parameter if it is used, or the first color in the current color list.
autovref cautovref=red;
CAXIS/CA The CAXIS or CA parameter in the PROC GPLOT statement specifies the color for the axis and major tick marks. The default color used is the first color in the current color list.
caxis=red
202 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CFRAME/CFR The CFRAME parameter defines the background color of the filled axis area. This parameter can also be defined using the CFR abbreviation.
cframe=yellow
CHREF/CH Like the CAUTOHREF parameter, the CHREF parameter defines the color to use for the horizontal reference lines. This parameter can use a color list or a single color. This parameter can also be defined using the CH abbreviation.
autohref chref=red
COUTLINE The COUTLINE parameter is used to define the outline color of the filled areas in a plot. (This parameter did not function with the tested release.)
Chapter 8: Parameters for Colors 203
CTEXT/C The CTEXT parameter for PROC GPLOT enables you to set the color for all the text on the chart. This text includes the labels and headings. This parameter can also be defined using the C abbreviation.
ctext=red
CVREF/CV Like the CAUTOVREF parameter, the CVREF parameter defines the color to use for the vertical reference lines. This parameter affects reference lines defined by the AUTOVREF, VREF, or GRID parameters. The CVREF parameter can take a single color or a color list. This parameter can also be defined using the CV abbreviation. autovref cvref=red or cvref=(red blue green)
204 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
8.6.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BUBBLE BUBBLE2 PLOT PLOT2 Chart Type BUBBLE BUBBLE2 PLOT PLOT2
BCOLOR
CAUTOHREF
CAUTOVREF
CAXIS
CFRAME
3
3
3 3 3 3
3 3 3 3
3 3 3 3
3 CHREF
COUTLINE
3 3
CTEXT
CVREF
3 3 3 3
3 3 3 3
8.7 PROC G3D This section covers defining colors by modifying PROC G3D parameters. For each parameter, we provide information on what the parameter does, what it looks like, how to use it, and in which of the charts this parameter is valid.
CAXIS The CAXIS parameter in the PROC G3D statement specifies the color to use for all axis lines as well as tick marks. The default color is taken from the second color in the current color list.
proc g3d data=work.hat; plot y*x=z / caxis=red; run;
Chapter 8: Parameters for Colors 205
CTEXT The CTEXT parameter in the PROC G3D statement specifies the color to use for all text. The default color is taken first from a CTEXT option on the GOPTIONS statement if there is one defined. Otherwise, it is the first color in the current color list.
proc g3d data=work.giris; scatter petallen*petalwid=sepallen / ctext=red; run;
8.7.1 Summary The following table shows which parameters can be used with specific types of charts. Chart Type PLOT SCATTER
CAXIS
CTEXT
3 3
3
8.7.2 Non-supported parameters Some parameters are not supported by the Java device driver. CBOTTOM CTOP
Defines the color to use for the bottom of the plot surface. Defines the color to use for the top of the plot surface.
206 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
9
Parameters for Text 9.1 ODS Parameters 208 9.1.1 Non-supported parameters 213 9.2 GOPTIONS 214 9.2.1 Non-supported parameters 217 9.3 PROC GCHART 217 9.3.1 Summary 225 9.3.2 Non-supported parameters 226 9.4 PROC GCONTOUR 227 9.4.1 Summary 231 9.5 PROC GMAP 232 9.5.1 Summary 234 9.6 PROC GPLOT 234 9.6.1 Summary 238 9.7 PROC G3D 239 9.7.1 Summary 240
208 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
9.1 ODS Parameters You can use the ODS parameters in this chapter to customize the appearance of text in your graphs. In the ODS statement, the PARAMETERS= option defines parameters to be passed to a Java applet. Not all parameters work with all the applets. In each parameter section, we note where the parameter is applicable. The parameters are specified in the PARAMETERS= option in the ODS HTML statement as name/value pairs. The applet parameter names are not case sensitive. However, some applet parameter values are case sensitive. In this section, we show only the ODS HTML code. To see the ODS statements in context, review the beginning or ending chapters of this book. Full examples are provided in those sections.
LEGENDFIT The LEGENDFIT parameter takes a Boolean value (TRUE or FALSE). These values specify whether the legend should fit within the height of the contourplot area. If you set this parameter to TRUE, then you are telling the applet that the legend must fit within the plot area. If the values for XPIXELS and YPIXELS do not allow enough space, then the legend will not be displayed or will shrink to a size to fit. This example shows a graph size too small to allow room for the legend. This parameter is used only with the Contour applet.
Chapter 9: Parameters for Text 209
By adjusting the XPIXELS and YPIXELS values in the GOPTIONS statement, we have provided enough space in this example for the legend to display.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LEGENDFIT"="TRUE");
LEGENDFONT You can use the LEGENDFONT parameter to define which Java font to use with the legend in the Contour applet. Fonts are limited in SAS when using the Java device driver. This parameter is used only with the Contour applet.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LEGENDFONT"="Courier");
210 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
LEGENDFONTSIZE You can use the LEGENDFONTSIZE parameter to set the font size in the legend. This parameter takes positive numeric values and can be used with a contour plot. To create a better representation of the usage of this parameter, we also used the LEVELS parameter to reduce the number of values in the legend in this example. This parameter is used only with the Contour applet. ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("LEGENDFONTSIZE"="20"); proc gcontour data=work.clay; plot x*y=pct_clay / levels=0 to 100 by 20; run; ods html close; ods listing;
Chapter 9: Parameters for Text 211
MINLEGENDFONTSIZE The MINLEGENDFONTSIZE parameter defines the minimum font size to be used in the legend. This parameter prevents the font from going below a specified value if auto-scaling is used. If the minimum font size cannot be maintained for the legend, then no legend is displayed. Our example shows this. This parameter is used only with the Contour applet. ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("MINLEGENDFONTSIZE"="15");
SHOWLEGEND The SHOWLEGEND parameter takes either a TRUE or FALSE value and defines whether or not the graph should display the legend. This parameter is used only with the Contour applet.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("SHOWLEGEND"="FALSE");
212 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
TIPS The TIPS parameter specifies whether to display data tips. There are four valid values: NONE, STATIONARY, TRUE, and FALSE. NONE and STATIONARY can be used with the Graph and Map applets, whereas the TRUE and FALSE values are used with the Contour applet.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("TIPS"="STATIONARY");
TIPMODE The TIPMODE parameter can take three values: STANDARD, HTML, and TABULAR. This parameter defines the types of data tips to display. The default value is STANDARD, which displays both HTML and tabular data tips if both are defined. Tabular data tips represent data values, whereas HTML data tips, when used with the HTML option for the graph, can represent HTML text that you can define. Unfortunately, when the Java device driver is used, only the tabular values are displayed.
Chapter 9: Parameters for Text 213
TIPTEXTCOLOR The TIPTEXTCOLOR parameter defines the color to use for data tip fonts. This parameter is used only with the Contour applet.
ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("TIPTEXTCOLOR"="RED");
9.1.1 Non-supported parameters Some parameters are not supported by the Java device driver. FREQNAME
FREQNAME is a parameter used to specify the newly created variable when running frequency charts.
214 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
9.2 GOPTIONS The fonts shown to the right can be used with text options for the GOPTIONS statement and the Java device driver. Although many more fonts are available in SAS, these are the ones that are supported by SAS using Java for display.
FTEXT The FTEXT option specifies the font to use for all text. Some fonts can be used only with certain graphs. For example, Courier is only used with the Graph applet. If you specify a font that is not available, a standard font is substituted by default. A message is shown in the SAS log indicating that a default was substituted.
goptions reset=all device=java xpixels=600 ypixels=400 ftext=courier;
Chapter 9: Parameters for Text 215
FTITLE The FTITLE option defines the font to use with TITLE1. This option must be used with the ODS USEGOPT statement. The default font used is FTEXT if it is defined. Otherwise, SWISS is used as the default.
libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400 ftitle=courier; ods listing; ods html close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>"; ODS USEGOPT; title1 "Proc GChart - Courier Title"; proc gchart data=samples.grains; hbar3d country / sumvar=amount; run; ods html close; ods listing;
216 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HTEXT The HTEXT option defines the height of the text in the output. The default value is 1. This option is only partially supported by the Java device driver. In most cases, this option worked. In the tested release, when used with PROC GCONTOUR, this option was not applied to the output.
goptions reset=all device=java xpixels=600 ypixels=400 htext=2;
HTITLE The HTITLE option is used to specify the height to use with TITLE1. The default value is HTITLE=2 unless the HTEXT option is used. As with the FTITLE option, the ODS USEGOPT statement must be used.
Chapter 9: Parameters for Text 217
libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400 htitle=1; ods listing; ods html close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>"; ODS USEGOPT; title1 "Proc GChart - Title Height = 1"; proc gchart data=samples.grains; hbar3d country / sumvar=amount; run; ods html close; ods listing;
9.2.1 Non-supported parameters Some parameters are not supported by the Java device driver. FBY
The FBY option specifies the font to be used by the BY statement when using subgroups and graph procedures.
FONTRES
The FONTRES option helps to control the resolution of software fonts in output.
FTRACK
The FTRACK option controls the spacing of the letters in fonts.
HBY
The HBY option is used to specify the height of any BY line text.
9.3 PROC GCHART The following parameters, when used with the SAS procedure GCHART, enable you to modify some of the text that is output with the graph.
218 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CFREQ You can use the CFREQ parameter to display the cumulative frequency statistic. In vertical bar charts, if the bars are too narrow and the statistic does not have enough space to display, it is suppressed.
proc gchart data=samples.grains; hbar3d country / sumvar=amount cfreq; run;
CPERCENT/CPCT You can use the CPERCENT parameter to display the cumulative percentage statistic. In vertical bar charts, if the bars are too narrow and the statistic does not have enough space to display, it is suppressed. This parameter can be abbreviated as CPCT.
proc gchart data=samples.grains; hbar3d country / sumvar=amount cpercent; run;
Chapter 9: Parameters for Text 219
CTEXT The CTEXT parameter for PROC GCHART enables you to set the color for all the text on the chart. This text includes the labels, headings, and arrows if they are used.
proc gchart data=samples.grains; hbar3d country / sumvar=amount ctext=red; run;
DETAIL_PERCENT The DETAIL_PERCENT parameter, used with the DETAIL parameter, enables you to specify whether or not to display the percentages of the detail pie slices. There are two settings: BEST and NONE. The BEST setting automatically determines the best percentage format to display. The NONE setting omits the percentage altogether.
proc gchart data=samples.grains; pie country / sumvar=amount detail=type detail_percent=best; run;
220 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
DETAIL_SLICE The DETAIL_SLICE parameter determines whether the variable value should be used as a label for the detail part of the pie. There are two settings: BEST and NONE. The BEST setting determines the best format to be used with the slice. The NONE setting suppresses these labels.
proc gchart data=samples.grains; pie country / sumvar=amount detail=type detail_slice=best; run;
DETAIL_VALUE To display the detail slice value information, you can use the DETAIL_VALUE parameter with the DETAIL parameter. There are two settings: BEST and NONE. The BEST setting determines the best format to be used. The NONE setting suppresses the display of the values.
proc gchart data=samples.grains; pie country / sumvar=amount detail=type detail_value=best; run;
Chapter 9: Parameters for Text 221
FREQ The FREQ parameter defines the variable to use as the weight of each observation used in the statistic.
proc gchart data=samples.grains; pie country / sumvar=amount freq=amount; run;
INSIDE The INSIDE parameter displays the specified statistic inside the bar in a bar chart.
proc gchart data=samples.grains; hbar3d country / sumvar=amount inside=percent; run;
222 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
INVISIBLE The INVISIBLE parameter takes a value or a list of values and makes those slices invisible in the pie chart. Labels for these slices are invisible also.
proc gchart data=samples.grains; pie3d country / sumvar=amount invisible='Canada'; run;
MATCHCOLOR The MATCHCOLOR parameter in PROC GCHART sets the label color of the slice to be the same as the slice color. This parameter overrides the color defined in the CTEXT parameter, if used.
proc gchart data=samples.grains; pie3d country / sumvar=amount matchcolor; run;
Chapter 9: Parameters for Text 223
MEAN The MEAN parameter displays the mean statistic above or beside the bars. In vertical bar charts, if the bars are too narrow and the statistic does not have enough space to display, it is suppressed.
proc gchart data=samples.grains; hbar3d country / sumvar=amount mean; run;
OTHERLABEL The OTHERLABEL parameter defines the label to be used for the “Other” slice on a pie chart. The default label is OTHER.
proc gchart data=samples.grains; pie3d country / sumvar=amount other=50 otherlabel="Under 50%"; run;
224 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
OUTSIDE The OUTSIDE parameter displays the specified statistic outside the bar in a bar chart.
proc gchart data=samples.grains; hbar3d country / sumvar=amount outside=percent; run;
PERCENT The PERCENT parameter displays the percentage of observations that have a given value for the chart variable. In vertical bar charts, if the bars are too narrow and the statistic does not have enough space to display, it is suppressed.
proc gchart data=samples.grains; hbar3d country / sumvar=amount percent; run;
Chapter 9: Parameters for Text 225
RANGE The RANGE parameter displays the range of values for each bar. This option works with axes which represent numeric data and has no effect on character data.
proc gchart data=samples.grains; hbar3d year / sumvar=amount range; run;
9.3.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
CFREQ
3 3
3 3
CPERCENT
CTEXT
3 3
3 3 3 3 3 3
3 3
3 3
DETAIL_PERCENT
DETAIL_SLICE
3
3
3
3
226 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
DETAIL_VALUE
3 3
MEAN
FREQ
INSIDE
3 3 3 3 3 3
3 3
3 3
3 3
OTHERLABEL
OUTSIDE
3 3 3
3 3 3 3
3 3
3 3
INVISIBLE
MATCHCOLOR
3
3
3 3
3 3
PERCENT
3 3 3 3 3 3 3
RANGE
3 3
3 3
9.3.2 Non-supported parameters Some parameters are not supported by the Java device driver. MEANLABEL CFREQLABEL CPERCENTLABEL FREQLABEL PERCENTLABEL
The MEANLABEL parameter used in the GCHART procedure defines the label used for the MEAN statistics in the table of statistics. The CFREQLABEL parameter used in the GCHART procedure defines the label used for the CFREQ statistics in the table of statistics. The CPERCENTLABEL parameter used in the GCHART procedure defines the label used for the CPERCENT statistics in the table of statistics. The FREQLABEL parameter enables the user to define the label that represents FREQ in the table of statistics. The PERCENTLABEL parameter defines the label to use for the PERCENT statistic displayed in the table of statistics.
Chapter 9: Parameters for Text 227
9.4 PROC GCONTOUR The following parameters, when used with the SAS procedure GCONTOUR, enable you to modify some of the text that is output with the graph. Note that in our example graphs a chunk seems to be missing. This is due to missing values in the data and is not an error in the graph.
AUTOLABEL You can use the AUTOLABEL parameter to automatically label the contour lines. The AUTOLABEL suboptions also enable you to customize those labels. The documentation for SAS 9.1.3 says that this parameter is not supported by the Java device.
CTEXT The CTEXT parameter in the PROC GCONTOUR statement specifies the color to use for all text. The default color is taken first from a CTEXT option on the GOPTIONS statement, if there is one defined. Otherwise, it is the first color in the current color list.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 ctext=red; run;
228 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HAXIS The HAXIS parameter enables you to apply axis definitions to the horizontal (x) axis of the plot. This parameter must be used in conjunction with a predefined AXIS statement. Also note that the Java device driver does not fully support all AXIS options.
axis1 order=(-10 to 4 by 2); proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 haxis=axis1; run;
HREVERSE The HREVERSE parameter specifies that the values along the horizontal axis should be reversed. (This parameter did not function with the tested release.)
Chapter 9: Parameters for Text 229
LEGEND The LEGEND parameter assigns a defined legend specification to the graph. This parameter must be used in conjunction with a predefined LEGEND statement. Not all LEGEND options are supported by the Java device driver.
legend1 label=('Percent Clay'); proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 legend=legend1; run;
LEVELS The LEVELS parameter defines the levels to be used on the contour graph.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 10; run;
230 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
NOAXIS/NOAXES NOAXIS and NOAXES parameters specify that the graph should not display the axes, axis values, or axis labels. In this example, we have suppressed both.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 noaxis; run;
NOLEGEND The NOLEGEND parameter suppresses the legend on the graph, as seen in this example.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 nolegend; run;
Chapter 9: Parameters for Text 231
VAXIS Similar to the HAXIS parameter, the VAXIS parameter enables you to apply axis definitions to the vertical (y) axis of the plot. This parameter must be used in conjunction with a predefined AXIS statement. Also note that the Java device driver does not fully support all AXIS options.
axis1 order=(-10 to 10 by 2); proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 vaxis=axis1; run;
VREVERSE The VREVERSE parameter specifies that the values along the vertical axis should be reversed. (This parameter did not function with the tested release.)
9.4.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type PLOT Chart Type PLOT
AUTOLABEL
CTEXT
HAXIS
3
3
NOAXIS
NOLEGEND
VAXIS
3
3
3
HREVERSE
VREVERSE
LEGEND
LEVELS
3
3
232 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
9.5 PROC GMAP The following parameters, when used with the SAS procedure GMAP, enable you to modify some text that is output with the graph.
CTEXT The CTEXT parameter in the PROC GMAP statement specifies the color to use for all text. The default color is taken first from a CTEXT option on the GOPTIONS statement, if there is one defined. Otherwise, it is the first color in the current color list.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / ctext=red; run;
LEGEND The LEGEND parameter assigns a defined legend specification to the graph. This parameter must be used in conjunction with a predefined LEGEND statement. Not all LEGEND options are supported by the Java device driver.
Chapter 9: Parameters for Text 233
legend1 label=('Number of Sites'); proc gmap map=maps.us data=samples.rgnsites; id state; block sites / legend=legend1; run;
LEVELS The LEVELS parameter defines the levels to be used on the map.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / levels=10; run;
NOLEGEND The NOLEGEND parameter suppresses the legend on the graph.
234 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / nolegend; run;
9.5.1 Summary The following table shows which parameters can be used with specific types of charts. Chart Type BLOCK CHORO PRISM SURFACE
CTEXT
LEGEND
LEVELS
NOLEGEND
3 3 3
3 3 3
3 3 3
3 3 3
9.6 PROC GPLOT The following parameters, when used with the SAS procedure GPLOT, enable you to modify some text that is output with the graph.
BFONT The BFONT parameter defines the font to use for labeling bubbles in a bubble plot.
proc gplot data=work.energyPrice; bubble dollars*year=energy / blabel bfont="Courier"; run;
Chapter 9: Parameters for Text 235
BLABEL The BLABEL parameter specifies that the third variable should be used to label the bubbles in a bubble plot. By default, the bubbles are not labeled. In this example, the value of ENERGY is displayed.
proc gplot data=work.energyPrice; bubble dollars*year=energy / blabel; run;
CTEXT The CTEXT parameter specifies the color to use for all text. This text includes the labels and headings.
proc gplot data=work.energyPrice; bubble dollars*year=energy / ctext=red; run;
236 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HAXIS The HAXIS parameter enables you to apply axis definitions to the horizontal (x) axis of the plot. This parameter must be used in conjunction with a predefined AXIS statement. Also note that the Java device driver does not fully support all AXIS options. To utilize this parameter when using BUBBLE2 or PLOT2 statements, put the HAXIS parameter with the BUBBLE or PLOT statement. You cannot specify two different HAXIS parameters within a single PLOT statement.
axis1 order=(1950 to 1990 by 5); proc gplot data=work.energyPrice; bubble dollars*year=energy / haxis=axis1; bubble2 yen*year=energy; run;
HREVERSE The HREVERSE parameter specifies that the values along the horizontal axis should be reversed. Like the HAXIS parameter, you can apply this parameter to a BUBBLE2 or PLOT2 graph. It must be defined in the BUBBLE or the PLOT statements.
Chapter 9: Parameters for Text 237
proc gplot data=work.energyPrice; bubble dollars*year=energy / hreverse; run;
NOAXIS/NOAXES NOAXIS and NOAXES parameters specify that the graph should not display the axes, axis values, or axis labels. Also note that when you want to apply this parameter to a BUBBLE2 or PLOT2 statement, you need to specify this parameter in both statements (i.e., both BUBBLE and BUBBLE2 or both PLOT and PLOT2).
proc gplot data=work.energyPrice; bubble dollars*year=energy / noaxis; bubble2 yen*year=energy / noaxis; run;
VAXIS The VAXIS parameter enables you to apply axis definitions to the vertical (y) axis of the plot. This parameter must be used in conjunction with a predefined AXIS statement. Also note that the Java device driver does not fully support all AXIS options. VAXIS can be applied to either or both the PLOT and PLOT2 or the BUBBLE and BUBBLE2 statements using the same or different AXIS statements.
238 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
axis1 order=(0 to 3 by .5); axis2 order=(100 to 500 by 50); proc gplot data=work.energyPrice; bubble dollars*year=energy / vaxis=axis1; bubble2 yen*year=energy / vaxis=axis2; run;
VREVERSE The VREVERSE parameter specifies that the values along the vertical axis should be reversed.
proc gplot data=work.energyPrice; bubble dollars*year=energy / vreverse; bubble2 yen*year=energy / vreverse; run;
9.6.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BUBBLE BUBBLE2 PLOT PLOT2 Chart Type BUBBLE BUBBLE2 PLOT PLOT2
BFONT
BLABEL
CTEXT
HAXIS
HREVERSE
3 3
3 3 3 3
3
3
3
3
NOAXIS
VAXIS
VREVERSE
3 3 3 3
3 3 3 3
3 3 3 3
Chapter 9: Parameters for Text 239
9.7 PROC G3D The following parameters, when used with the SAS procedure G3D, enable you to modify some text that is output with the graph.
CTEXT CTEXT specifies the color to use for all text. This text includes the labels, headings, and arrows if they are used.
proc g3d data=work.giris; scatter petallen*petalwid=sepallen / ctext=red; run;
NOAXES/NOAXIS The NOAXES or NOAXIS parameter specifies that the graph should not display the axis, axis labels, or tick mark values.
240 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc g3d data=work.giris; scatter petallen*petalwid=sepallen / noaxis; run;
NOLABEL The NOLABEL parameter specifies that the output should have no axis labels or tick mark values.
proc g3d data=work.giris; scatter petallen*petalwid=sepallen / nolabel; run;
9.7.1 Summary The following table shows which parameters can be used with specific types of charts. Chart Type PLOT SCATTER
CTEXT
NOAXIS
NOLABEL
3
3 3
3 3
C h a p t e r
10
Other Parameters 10.1 PROC GCHART 242 10.1.1 Summary 264 10.1.2 Non-supported parameters 267 10.2 PROC GCONTOUR 268 10.2.1 Non-supported parameters 272 10.3 PROC GMAP 273 10.3.1 Summary 277 10.3.2 Non-supported parameters 278 10.4 PROC GPLOT 278 10.4.1 Summary 289 10.4.2 Non-supported parameters 289 10.5 PROC G3D 290 10.5.1 Summary 298 10.5.2 Non-supported parameters 298
242 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
10.1 PROC GCHART In addition to the parameters that affect text and colors, there are lots of other parameters in PROC GCHART that you can use to improve the appearance of your graphs. These parameters enable you to display charts produced with BY groups, add reference lines, control grouping, and more. Not all parameters apply to every chart type. A table at the end of this section summarizes which parameters can be used with which chart type.
ACROSS The ACROSS parameter draws the specified number of graphs across the output area. This parameter must be used with the GROUP parameter. If the number of graphs will not fit, no graphs are drawn, and a message is sent to the SAS log.
proc gchart data=samples.grains; pie3d country / sumvar=amount group=year across=2; run;
Chapter 10: Other Parameters 243
ANGLE The ANGLE parameter tells the graph object where to start the first slice of a pie chart. Valid values are numeric, with 0 at the 3 o’clock position. A positive value moves the pie slice starting position counterclockwise towards the 12 o’clock position. Negative values move the starting position clockwise towards the 6 o’clock position.
proc gchart data=samples.grains; pie3d country / sumvar=amount angle=10; run;
ASCENDING The ASCENDING parameter arranges the slices or bars in ascending order according to the value of the chart’s statistic. By default they are arranged in ascending order based on midpoint values. The ASCENDING parameter does not affect the position of the OTHER slice or bar. It is always reported last, regardless of size or value. If you use the GROUP parameter, the slices and bars are reordered within each group.
proc gchart data=samples.grains; hbar3d country / sumvar=amount ascending; run;
244 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
AUTOREF The AUTOREF parameter draws reference lines at each major tick mark along the response axis.
proc gchart data=samples.grains; vbar country / sumvar=amount autoref; run;
AXIS/RAXIS The AXIS parameter enables you to apply a specific AXIS to the graph for the major tick mark divisions on the response axis. This parameter must be used in conjunction with a predefined AXIS statement. Also note that the Java device driver does not fully support all AXIS parameters.
axis1 color=red; proc gchart data=samples.grains; vbar3d country / sumvar=amount axis=axis1; run;
Chapter 10: Other Parameters 245
CLIPREF The CLIPREF parameter clips the reference lines at the bars. This gives the appearance of putting the reference lines behind the bars in a chart. This is the default for threedimensional charts, so it only affects twodimensional charts.
proc gchart data=samples.grains; hbar country / sumvar=amount autoref clipref; run;
CLM The CLM parameter specifies the confidence interval to use. Values must be numeric and within the range of 50 to 100. The default is 95.
proc gchart data=samples.fitness; vbar3d age / sumvar=heart type=mean discrete clm=55; run;
246 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
CLOCKWISE The CLOCKWISE parameter draws the slices of a pie or donut chart clockwise, starting at the 12 o’clock position.
proc gchart data=samples.grains; donut country / sumvar=amount clockwise; run;
DESCENDING Similar to the ASCENDING parameter, the DESCENDING parameter arranges the slices in descending order based on the value. The OTHER slice is still positioned last, regardless of its size. If you use the GROUP parameter, the reordering occurs within each group.
proc gchart data=samples.grains; hbar3d country / sumvar=amount descending; run;
Chapter 10: Other Parameters 247
DETAIL The DETAIL parameter produces an inner pie or donut overlay which shows the major subcomponents of the outer slice. This is a way to show a grouping in a single pie chart. If you use the GROUP or SUBGROUP parameters, then this parameter is ignored.
proc gchart data=samples.grains; pie country / sumvar=amount detail=type; run;
DETAIL_RADIUS The DETAIL_RADIUS parameter determines the size of the inner detail pie or donut. This parameter is a percentage of the outer pie’s radius and has valid values between 25 and 90. The default is 75.
proc gchart data=samples.grains; donut country / sumvar=amount detail=type detail_radius=50; run;
248 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
DETAIL_THRESHOLD The DETAIL_THRESHOLD parameter sets a percentage value that specifies whether or not an inner pie slice is to be included. The valid range for this percentage value is 0 to 75. The default is 4.
proc gchart data=samples.grains; donut country / sumvar=amount detail=type detail_threshold=10; run;
DISCRETE The DISCRETE parameter breaks the variable values into discrete values instead of a continuous variable. This creates a pie or bar chart with a separate bar or slice per unique value. The LEVELS parameter is ignored with this parameter, and the MIDPOINTS parameter overrides DISCRETE.
proc gchart data=samples.fitness; pie3d age / discrete sumvar=heart; run;
Chapter 10: Other Parameters 249
DONUTPCT DONUTPCT stands for Donut Percentage. This parameter specifies the size of the donut hole as represented by a percentage of the size of the whole donut. Valid numeric values range from 0 to 99. The default is 25.
proc gchart data=samples.fitness; donut age / sumvar=heart donutpct=50; run;
DOWN The DOWN parameter is similar to the ACROSS parameter in that it specifies how many charts are displayed vertically. This is ignored, however, if you use it with the GROUP parameter. Also, if the number specified does not fit vertically in the graphics area of the output, no charts are drawn, and an error is recorded in the SAS log. Note that when you have more groups, the pies are added across while the number of down pies is maintained.
proc gchart data=samples.grains; pie country / sumvar=amount group=type down=2; run;
250 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
ERRORBAR The ERRORBAR parameter draws confidence intervals on the bar chart. This parameter is normally used with the CLM parameter, which has a default of 95 for the confidence level. The ERRORBAR parameter takes three values: BARS, BOTH, or TOP. In this example, we used the BARS value, which created a half-width bar that is placed on top. Use BOTH to draw two tick marks joined by a line that is placed on top. TOP draws a single tick mark and a line from the end of the bar to the mark.
proc gchart data=samples.fitness; hbar age / sumvar=heart type=mean discrete clm=55 errorbar=bar; run;
EXPLODE The EXPLODE parameter pulls a specified slice away from the pie or donut chart. This parameter can take a value list and must match the existing midpoints exactly, including the case of character midpoints. When you use the EXPLODE parameter, the overall radius is reduced on the pie or donut to accommodate the exploded slice. This parameter does not work with the SUBGROUP parameter.
proc gchart data=samples.grains; donut country / sumvar=amount explode='Canada'; run;
Chapter 10: Other Parameters 251
FRAME/NOFRAME FR/NOFR The FRAME or FR parameter tells the graph to display the frame that is drawn around the backplane or axis area. The NOFRAME or NOFR parameter tells the graph not to display the frame. The default is to show the frame. In this example, we have used NOFRAME to suppress the frame.
proc gchart data=samples.fitness; hbar3d age / noframe sumvar=heart; run;
FRONTREF The FRONTREF parameter is used to specify that reference lines be drawn in front of the bars. By default, the reference lines of threedimensional bar charts are drawn on the back plane.
proc gchart data=samples.grains; vbar country / sumvar=amount autoref frontref; run;
252 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
G100 The G100 parameter calculates the percentage and cumulative percentage statistics separately for each group. This parameter is ignored unless used with the GROUP parameter.
proc gchart data=samples.fitness; block teacher / group=sex type=percent subgroup=teacher g100; run;
GAXIS The GAXIS parameter enables you to assign a defined AXIS statement to the group axis.
axis1 color=cyan; proc gchart data=samples.grains; hbar country / sumvar=amount group=year gaxis=axis1; run;
Chapter 10: Other Parameters 253
GROUP The GROUP parameter organizes the data according to the values from the specified variable. The GROUP parameter can use either character or numeric variable values and treats each as discrete values.
proc gchart data=samples.grains; pie3d country / sumvar=amount group=year; run;
GSPACE The GSPACE parameter adjusts the amount of space between grouped bars, adding extra space. The value of the GSPACE parameter can be any nonnegative number and is expressed as character cells. To use this parameter you must define a group. If the defined GSPACE parameter cannot be maintained due to output space restrictions, the graph is not displayed, and an error is written to the SAS log. Use GSPACE=0 to leave no extra space. proc gchart data=samples.grains; vbar3d country / sumvar=amount group=year gspace=0; run;
254 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
LAUTOREF The LAUTOREF parameter defines the line types to use for reference lines at major tick marks defined by the AUTOREF parameter. Valid values for the LAUTOREF parameter include any whole number between 1 and 46, where 1 is a solid line and the rest are variations of dashed lines. ®
See the SAS 9 online documentation for examples of the line types. proc gchart data=samples.grains; hbar country / sumvar=amount autoref lautoref=15; run;
LEGEND Like the AXIS parameter, the LEGEND parameter enables you to define a LEGEND statement and then apply that to the graph. Be aware, though, that the Java device driver does not support all LEGEND statement parameters.
proc gchart data=samples.fitness; vbar3d teacher / group=sex type=percent subgroup=teacher legend=legend1; run;
Chapter 10: Other Parameters 255
LEVELS The LEVELS parameter specifies the number of midpoints for a numeric chart variable. The midpoint values are calculated automatically based on how many levels you specify.
proc gchart data=samples.fitness; pie age / sumvar=heart levels=4; run;
MAXIS The MAXIS parameter is similar to the GAXIS parameter. This parameter assigns a defined AXIS to the midpoint axis. Be aware, though, that the Java device driver does not support all AXIS statement parameters.
axis1 color=cyan; proc gchart data=samples.grains; hbar3d country / sumvar=amount maxis=axis1; run;
256 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
MIDPOINTS The MIDPOINTS parameter specifies values to use for the bars. It can take a value list that includes either a single value, a set of defined values, or a pattern of values.
proc gchart data=samples.fitness; block age / sumvar=exer midpoints=(20 to 50 by 5); run
MIDPOINTS=OLD The MIDPOINTS=OLD parameter setting generates default midpoints using the Nelder algorithm. For more information on this setting, ® review the SAS 9 online documentation and look for the algorithms description section.
proc gchart data=samples.fitness; block age / sumvar=exer midpoints=old; run;
Chapter 10: Other Parameters 257
MISSING The MISSING parameter allows missing values to be a valid midpoint in the chart. By default, missing values are ignored in bar and pie charts.
proc gchart data=samples.fitness; pie3d age / sumvar=exer missing; run;
NOAXES The NOAXES parameter suppresses all axes, axis lines, axis labels, axis values, and tick marks.
proc gchart data=samples.grains; vbar3d country / sumvar=amount noaxes; run;
258 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
NOGROUPHEADING Group headings are normally printed above each pie when used with the GROUP parameter. You can suppress these headings by using the NOGROUPHEADING parameter.
proc gchart data=samples.grains; pie country / sumvar=amount group=year nogroupheading; run;
NOHEADING The NOHEADING parameter suppresses the heading that is normally printed at the top of each page. This is the default for the Java device driver and is therefore not needed in our examples.
NOLEGEND The NOLEGEND parameter enables you to suppress the legend normally generated when you specify a SUBGROUP parameter.
proc gchart data=samples.fitness; block teacher / group=sex type=percent subgroup=teacher nolegend; run;
Chapter 10: Other Parameters 259
OTHER To lump many values or a value range into one group, use the OTHER parameter. This parameter determines if the value is less than or equal to that percentage of total. The default value is 4 percent. This slice or bar always appears last in the chart, regardless of any order specification.
proc gchart data=samples.fitness; donut teacher / sumvar=exer other=20; run;
PATTERNID The PATTERNID parameter specifies the way PATTERN statements are assigned to bars or slices. It can take values such as BY, GROUP, MIDPOINT, or SUBGROUP. This parameter tells the display to use a different PATTERN based on the value passed to the PATTERNID parameter. For example, if you want a different color for each group defined, use the PATTERNID=GROUP setting. proc gchart data=samples.grains; vbar country / sumvar=amount group=year patternid=group; run;
260 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
RAXIS/AXIS See the description for the AXIS parameter.
REF To draw a reference line at a specific point or points on the response axis, use the REF parameter. This parameter can take a value list that must be within the range of values in the data. If, however, the range specifies a point outside of this range, then a warning is written to the SAS log and no reference line is drawn for that point.
proc gchart data=samples.grains; vbar3d country / sumvar=amount group=year ref=200000; run;
Chapter 10: Other Parameters 261
SHAPE Bar charts can take different shapes for their bars. To specify the shape, use the SHAPE parameter with the following values: BLOCK (B), CYLINDER (C), HEXAGON (H), PRISM (P), or STAR (S).
proc gchart data=samples.grains; block country / sumvar=amount group=year shape=star; run;
SLICE The SLICE parameter controls the position and style of the slice name. Valid values are ARROW, INSIDE, NONE, and OUTSIDE (default).
proc gchart data=samples.fitness; pie3d teacher / sumvar=exer slice=inside; run;
262 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
SPACE To modify the amount of space between each bar, use the SPACE parameter. The SPACE parameter takes any non-negative number as its value. By default, the procedures calculate the best spacing to use based on the number of midpoints and the size of the output area. In our example using SPACE=0, there is no space between the country bars in each year group. proc gchart data=samples.grains; hbar country / sumvar=amount group=year space=0; run;
SUBGROUP To divide the bars into segments, use the SUBGROUP parameter to specify the variable to be subdivided. By default, each subgroup is assigned a different color, and a legend is shown for each discrete value in the subgroup variable. To make the bars all the same color and suppress the legend, use the PATTERNID parameter and specify anything other than the keyword SUBGROUP. You can suppress the legend with the NOLEGEND parameter.
Chapter 10: Other Parameters 263
proc gchart data=samples.fitness; block teacher / group=sex type=percent subgroup=age; run;
SUMVAR You can use the SUMVAR parameter to specify the numeric variable to use for sum or mean calculations.
proc gchart data=samples.fitness; vbar3d teacher / sumvar=exer; run;
TYPE The TYPE parameter specifies the statistic to produce for the chart. Valid values are FREQ, CFREQ, PERCENT/PCT, or CPERCENT/CPCT. If the SUMVAR parameter is used, then SUM and MEAN can also be used as values.
proc gchart data=samples.fitness; donut teacher / type=freq; run;
264 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
WIDTH The WIDTH parameter defines the width to use for each bar in a bar chart. By default, the procedure automatically calculates a good value to use to accommodate the midpoint values displayed. This parameter can take a numeric value, including decimal points, from numbers greater than 0. If the width is too wide to enable all bars to be displayed, the procedure will fall back to the calculated width and write an error to the SAS log. proc gchart data=samples.fitness; vbar3d teacher / width=5; run;
10.1.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
ACROSS
ANGLE
ASCENDING
3
3
3 3 3 3 3
3 3
3 3
3 3
AUTOREF
AXIS
3 3
3 3
3 3
3 3
Chapter 10: Other Parameters 265
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
CLIPREF
3
CLM
CLOCKWISE
DESCENDING
DETAIL
3
3 3 3 3 3
3
3 3 3 3
3
3 3
3
3 3
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
DETAIL_RADIUS
DETAIL_THRESHOLD
3
3
3
3
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
DOWN
DISCRETE
3 3 3 3 3 3
DONUTPCT
3
3 3 ERRORBAR
3
EXPLODE
FRAME
FREQ
3 3
3 3 3 3 3 3
3 3
3 3
3 3 3
3 3
3 3 3 3
266 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
FRONTREF
G100
GAXIS
GROUP
GSPACE
3
3
3 3
3 3
3 3
3 3 3 3 3 3
3 3
3 3
3 3
3 3
3 3
3 3
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
LAUTOREF
LEGEND
LEVELS
MAXIS
MIDPOINTS
3 3 3 3 3 3
3
3 3
3 3 3 3 3 3
3 3
3 3 3 3 3 3
3 3
3 3
3 3
3 3
3 3
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
MISSING
NOAXES
NOGROUPHEADING
3 3 3 3 3 3
3 3
3 3
3 3
3 3 3
NOLEGEND
3 3 3 3 3 3 3 3
Chapter 10: Other Parameters 267
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
OTHER
Chart Type BLOCK DONUT HBAR HBAR3D PIE PIE3D STAR VBAR VBAR3D
PATTERNID
REF
3
SHAPE
SLICE
3
3
3 3 3
3 3
3
3 3
3 3 3 3
3 3
SPACE
SUBGROUP
SUMVAR
TYPE
WIDTH
3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3 3 3 3 3
3 3
3 3
3 3
3 3
3 3
3 3
3
10.1.2 Non-supported parameters Some parameters are not supported by the Java device driver. BLOCKMAX
The BLOCKMAX parameter specifies the chart value of the tallest block.
LREF
The LREF and LR parameters specify the line types to use for reference lines.
NOBASEREF
The NOBASEREF parameter suppresses the zero reference line when the SUM or MEAN statistic contains negative values.
NOSTATS
The NOSTATS parameter suppresses the table of statistics.
NOZERO
The NOZERO parameter suppresses any midpoints where there are no corresponding values.
WOUTLINE
The WOUTLINE parameter specifies the width of the outline of bars.
268 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
10.2 PROC GCONTOUR In this section, we look at other parameters in PROC GCONTOUR that can modify the appearance of your graph.
HMINOR/HM To explicitly set the number of minor tick marks, use the HMINOR parameter.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 hminor=2; run;
Chapter 10: Other Parameters 269
JOIN The JOIN parameter combines adjacent grid cells displayed with the same pattern to form a single pattern area. This parameter is used with the PATTERN parameter.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 pattern join; run;
NLEVELS The NLEVELS parameter specifies the number of contour levels to display. Valid numeric values can range from 1 to 100. The default is 7.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 nlevels=10; run;
270 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
NOFRAME The NOFRAME parameter suppresses the frame drawn around the plot area. The output may be subtle on a Windows platform.
axis1 color=green; proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 noframe haxis=axis1; run;
PATTERN The PATTERN parameter tells the procedure to use fill patterns and colors for the contour areas. The levels then are represented by rectangles filled with patterns.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 pattern; run;
Chapter 10: Other Parameters 271
VMINOR/VM The VMINOR parameter is similar to the HMINOR parameter. This parameter specifies the number or minor tick marks along the vertical axis.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 vminor=2; run;
XTICKNUM The XTICKNUM parameter specifies the number of major tick marks located along the x axis. The value given for this parameter must be greater than 2. The default is 5.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 xticknum=3; run;
272 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
YTICKNUM Similar to the XTICKNUM parameter, the YTICKNUM parameter defines the number of major tick marks along the y axis. As with XTICKNUM, the value must be greater than 2. The default is 5.
proc gcontour data=work.clay; plot x*y=pct_clay / levels=10 to 90 by 5 yticknum=3; run;
10.2.1 Non-supported parameters Some parameters are not supported by the Java device driver. If an alternative is available, it is listed in the description. AUTOHREF
The AUTOHREF parameter displays reference lines at the major tick marks on the horizontal axis.
AUTOVREF
Similar to the AUTOHREF parameter, the AUTOVREF parameter draws the reference lines along the vertical axis.
GRID
As a shortcut to using both AUTOHREF and AUTOVREF, you can use the GRID parameter to display the reference lines on both the horizontal and vertical axes.
HREF
You can use the HREF parameter to draw reference lines perpendicular to the horizontal axis at points specified by a value list.
LAUTOHREF
The LAUTOHREF parameter defines the line type to use for reference lines drawn at the major tick marks along the horizontal axis.
LAUTOVREF
Similar to the LAUTOHREF parameter, the LAUTOVREF parameter defines the line type used with reference lines along the vertical axis at the major tick marks.
Chapter 10: Other Parameters 273
LHREF
Similar to the LAUTOHREF parameter, the LHREF parameter specifies the line type to use for reference lines along the horizontal axis.
LLEVELS
The LLEVELS parameter defines line types for contour lines.
LVREF
Like the LHREF parameter, the LVREF parameter specifies the line type for use with reference lines along the vertical axis.
VREF
The VREF parameter draws reference lines perpendicular to the vertical axis where specified by the value list.
10.3 PROC GMAP In this section, we look at other parameters in PROC GMAP that can modify the appearance of maps.
AREA The AREA parameter defines different map patterns to be used for the surface of each map area or group of areas. Numeric values that represent a variable in the ID statement can be used as the value set by the AREA parameter. If the ID statement has only one map area, then use AREA=1 to indicate that each map area should use a different pattern. If you have more than one variable, then the numeric value indicates which variable to use by position in the ID statement.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / area=1; run; quit;
274 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
BLOCKSIZE The BLOCKSIZE parameter specifies the width of the blocks in a BLOCK map. The unit for width is based on the character cell width for the Java device. By default, this width is 2.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / blocksize=5; run;
DISCRETE The DISCRETE parameter tells the mapping device to use the numeric response variable as though it has discrete values rather than continuous values. This means the response variable is not grouped into ranges.
proc gmap map=maps.us data=samples.rgnsites; id state; prism sites / discrete; run;
Chapter 10: Other Parameters 275
MIDPOINTS The MIDPOINTS parameter defines the response levels for the range of response values. This parameter can take a single numeric value or a value list. When you use this parameter with the Java device driver, only the midpoints that fall into a range are used. So in our example, the ranges are offset to start with 4 because there are no values for 1, 2, or 3.
proc gmap map=maps.us data=samples.rgnsites; id state; choro sites / midpoints=(1 to 100 by 20); run;
MISSING The MISSING parameter enables you to display and define missing values as a valid level for the response variable.
276 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gmap map=maps.us data=samples.rgnsites; id state; prism sites / missing; run;
SHAPE The SHAPE parameter specifies the shape of the blocks in a BLOCK map. The following are valid shapes: BLOCK (B), CYLINDER (C), HEXAGON (H), PRISM (P), and STAR (S).
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / shape=s; run;
Chapter 10: Other Parameters 277
XVIEW/YVIEW/ZVIEW The XVIEW, YVIEW, and ZVIEW parameters are used to define the viewing position for the map. The default values are XVIEW=0.5, YVIEW=2, and ZVIEW=3. When you use these parameters with the Java device driver, you are only able to use and change the values for XVIEW and YVIEW. ZVIEW is set to the default.
proc gmap map=maps.us data=samples.rgnsites; id state; block sites / xview=0 yview=.75; run;
10.3.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BLOCK CHORO PRISM SURFACE
AREA
BLOCKSIZE
DISCRETE
MIDPOINTS
MISSING
3
3
3 3 3
3 3 3
3 3 3
Chart Type BLOCK CHORO PRISM SURFACE
SHAPE
XVIEW/YVIEW/ZVIEW
3
3 3 3
3
278 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
10.3.2 Non-supported parameters Some parameters are not supported by the Java device driver. If an alternative is available, it is listed in the description. WOUTLINE
The WOUTLINE parameter defines the width to use for the outline of all block and map areas
XLIGHT YLIGHT
The XLIGHT and YLIGHT parameters specify the coordinates of the light source.
XSIZE YSIZE
The parameters XSIZE and YSIZE define the dimensions of the map.
10.4 PROC GPLOT In this section, we look at other parameters in PROC GPLOT that include ways to modify the axis, legend, reference lines, and other aspects of the plot.
AREAS The AREAS parameter fills all the areas below plot lines with a pattern. This parameter takes a numeric value that indicates which area to fill. The number 1 fills the first area. The number 2 fills both the first and second areas. To use a connected border line to define the area, use a SYMBOL statement with the INTERPOL option.
symbol1 interpol=join; proc gplot data=work.energyPrice; plot dollars*year / areas=2; plot2 yen*year /areas=2; run;
Chapter 10: Other Parameters 279
AUTOHREF The AUTOHREF parameter draws reference lines at all major tick marks along the horizontal axis.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autohref; bubble2 yen*year=energy / autohref; run;
AUTOVREF Similar to the AUTOHREF parameter, the AUTOVREF parameter draws reference lines at all the major tick marks along the vertical axis.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autovref; bubble2 yen*year=energy / autovref; run;
280 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
BSCALE The BSCALE parameter defines whether the bubbles in a bubble plot are proportioned based on AREA or RADIUS. When you use AREA, the larger bubble is twice the area of the smaller bubble. When you use RADIUS, the larger bubble is twice the radius of the smaller bubble, which makes the larger bubble four times the area of the smaller bubble.
proc gplot data=work.energyPrice; bubble dollars*year=energy / bscale=area; bubble2 yen*year=energy / bscale=radius; run;
BSIZE You can set the bubble size using the BSIZE parameter. The value to use with BSIZE is a numeric which represents the scaling factor. The default bubble size is 5.
proc gplot data=work.energyPrice; bubble dollars*year=energy / bsize=20; run;
Chapter 10: Other Parameters 281
FRAME/NOFRAME FR/NOFR The FRAME or FR parameter specifies that the frame is to be drawn around the axis area. To suppress the frame, use the NOFRAME or NOFR parameter.
proc gplot data=work.energyPrice; bubble dollars*year=energy / noframe; run;
GRID The GRID parameter specifies that reference lines appear at all major tick marks on both axes.
proc gplot data=work.energyPrice; bubble dollars*year=energy / grid; bubble2 yen*year=energy / grid; run;
282 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
HMINOR/HM The HMINOR or HM parameter enables you to define the number of minor tick marks to be drawn between each major tick mark along the horizontal axis.
proc gplot data=work.energyPrice; bubble dollars*year=energy / hminor=2 bcolor=black; run;
HREF The HREF parameter enables you to define the values to use for reference lines perpendicular to the horizontal axis.
proc gplot data=work.energyPrice; bubble dollars*year=energy / href=1980 bcolor=black; run;
Chapter 10: Other Parameters 283
HZERO The HZERO parameter sets the horizontal axis to begin with zero instead of using the first data value. This parameter is ignored if negative values exist in the data.
proc gplot data=work.energyPrice; bubble dollars*year=energy / hzero; run;
LAUTOHREF The LAUTOHREF parameter specifies a line type to use with reference lines drawn at major tick marks along the horizontal axis. This parameter can take numeric values within the range of 1 to 46, where 1 is a solid line.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autovref lautohref=10 bcolor=black; run;
284 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
LAUTOVREF Similar to the LAUTOHREF parameter, the LAUTOVREF parameter defines the line type to be used for reference lines along the vertical axis. These values can be any numeric between 1 and 46. Notice how the line types are different to help define visually which lines are reference lines for dollars and which are for yen.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autovref lautovref=15; bubble2 yen*year=energy / autovref lautovref=40; run;
LEGEND The LEGEND parameter enables you to apply a predefined LEGEND to the plot. In our testing we got unexpected results with SAS 9.1.3. This example uses PLOT2 in the form of x*y=z.
legend1 cborder=red; proc gplot data=work.energyPrice; plot dollars*year=dollars / legend=legend1; plot2 yen*year=yen /legend=legend1; run;
Chapter 10: Other Parameters 285
LHREF / LH The LHREF parameter is similar to the LAUTOHREF parameter in that it specifies the line types to be used for reference lines drawn perpendicular to the horizontal axis. The values can range from 1 to 46, where 1 is a solid line and is the default. Unlike the LAUTOHREF parameter, this parameter can also take a value list to specify a set of line types to use.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autohref lhref=15; run;
LVREF / LV Like the LHREF parameter, the LVREF parameter specifies the line types to use and can take a value list. However, LVREF is used to define the reference lines perpendicular to the vertical axis. It can take numeric values ranging from 1 to 46.
proc gplot data=work.energyPrice; bubble dollars*year=energy / autovref lvref=15 bcolor=black; bubble2 yen*year=energy / autovref lvref=40 bcolor=grey; run;
286 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
NOLEGEND The NOLEGEND parameter suppresses the legend that is automatically generated by plots in the form of x*y=z.
proc gplot data=work.energyPrice; plot dollars*year=energy / nolegend; run;
OVERLAY The OVERLAY parameter places all plots generated by the PLOT statement on one axis. In the tested release, this parameter did not work with plots in the form of x*y=z.
SKIPMISS The SKIPMISS parameter breaks a plot line or an area where there are missing values of the Y variable.
Chapter 10: Other Parameters 287
data a; input id x y; cards; 0 5 8 1 4 7 2 . 8.1 3 10 . 4 5 7.5 5 . 8 6 2 9 7 3 10 8 12 9 ; run; proc gplot data=a; symbol1 interpol=join v=dot; plot x*id=1 / skipmiss; plot2 y*id=1 / skipmiss; run;
VMINOR/VM The VMINOR or VM parameter is similar to the HMINOR parameter. It specifies the number of minor ticks drawn between the major tick marks along the vertical axis.
proc gplot data=work.energyPrice; bubble dollars*year=energy / vminor=2; run;
288 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
VREF The VREF parameter draws one or more reference lines perpendicular to the vertical axis at points specified in the value list.
proc gplot data=work.energyPrice; bubble dollars*year=energy / vref=2; run;
VZERO Similar to the HZERO parameter, the VZERO parameter redefines the vertical axis and sets it to start at 0.
proc gplot data=work.energyPrice; plot dollars*year / vzero; plot2 yen*year / vzero; run;
Chapter 10: Other Parameters 289
10.4.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type BUBBLE BUBBLE2 PLOT PLOT2
AREAS
AUTOREF
AUTOVREF
BSCALE
BSIZE
3 3 3 3
3 3
3 3
3 3
3 3 3 3
Chart Type BUBBLE BUBBLE2 PLOT PLOT2
FRAME
GRID
HMINOR
HREF
HZERO
3 3 3 3
3 3 3 3
3
3
3
3
3
3
LAUTOHREF
LAUTOVREF
LEGEND
3
3 3 3 3
3 3
OVERLAY
SKIPMISS
VMINOR
VREF
3 3
3 3 3 3
3 3 3 3
Chart Type BUBBLE BUBBLE2 PLOT PLOT2
3
Chart Type BUBBLE BUBBLE2 PLOT PLOT2
NOLEGEND
Chart Type BUBBLE BUBBLE2 PLOT PLOT2
VZERO
3 3
3 3
LHREF
LVREF
3
3 3 3 3
3
3 3 3 3
10.4.2 Non-supported parameters Some parameters are not supported by the Java device driver. If an alternative is available, it is listed in the description.
290 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
IFRAME
The IFRAME parameter specifies an image file to use on the chart frame. If you need to define something like this, consider using the ODS parameters such as BACKIMAGE, DRAWIMAGE, IMAGEPOSX, and IMAGEPOSY.
IMAGESTYLE
The IMAGESTYLE parameter helps to define how to display the image defined by IFRAME.
REGEQN
The REGEQN parameter displays the regression equation that is specified in the INTERPOL parameter of the SYMBOL statement.
10.5 PROC G3D This section covers the other parameters available with PROC G3D that you can use to control the graph image.
GRID The GRID parameter specifies whether to draw reference lines at the major tick marks on all axes.
data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / grid; run;
Chapter 10: Other Parameters 291
NONEEDLE The NONEEDLE parameter specifies that a scatter plot have no lines that connect the shape to the x-y plane. By definition, PILLER and PRISM shapes connect to the floor, so the NONEEDLE parameter has no effect when they are used.
data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / noneedle; run;
ROTATE The ROTATE parameter defines the angles used to rotate the plot about the z axis. The default value is 70, which represents an angle in degrees. You can also specify numeric values greater than 360 or negative numbers.
292 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
data work.hat ; do x = -5 to 5 ; do y = -5 to 5 ; z = sin(sqrt( x*x + y*y )) ; output ; end; end; run; proc g3d data=work.hat; plot y*x=z / rotate=15; run;
SHAPE The SHAPE parameter defines the symbol to use with a scatter plot. Valid values include BALLOON, CLUB, CROSS, CUBE, CYLINDER, DIAMOND, FLAG, HEART, PILLER, POINT, PRISM, PYRAMID, SPADE, SQUARE, and STAR. You can also use a variable as a valid value. This variable would contain one of the values of SHAPE listed above to use with the data point. This allows you to assign different shapes to different data points in the same graph.
data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / shape="balloon" size=2; run;
Chapter 10: Other Parameters 293
SIDE You can use the SIDE parameter to produce a surface graph with side walls.
data work.hat ; do x = -5 to 5 ; do y = -5 to 5 ; z = sin(sqrt( x*x + y*y )) ; output ; end; end; run; proc g3d data=work.hat; plot y*x=z / side; run;
SIZE The SIZE parameter enables you to specify the relative size of the shape on a scatter plot. The relative size is an order of magnitude greater than the default of SIZE=1.0. Therefore, if you specify SIZE=2 then the shapes will be two times larger than the default. As with the SHAPE parameter, you can also specify a variable to define the size of each shape depending on the data point.
294 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / shape="balloon" size=2; run;
TILT The TILT parameter specifies one or more angles used to tilt the graph towards the viewer. The default is 70. Unlike the values of the ROTATE parameter, these values must be between 0 and 90.
data work.hat ; do x = -5 to 5 ; do y = -5 to 5 ; z = sin(sqrt( x*x + y*y )) ; output ; end; end; run; proc g3d data=work.hat; plot y*x=z / tilt=15; run;
Chapter 10: Other Parameters 295
XTICKNUM The XTICKNUM parameter defines the number of major tick marks located on the x axis. The values must be 2 or greater. The default is 4.
data work.hat ; do x = -5 to 5 ; do y = -5 to 5 ; z = sin(sqrt( x*x + y*y )) ; output ; end; end; run; proc g3d data=work.hat; plot y*x=z / xticknum=3; run;
YTICKNUM The YTICKNUM parameter defines the number of major tick marks located on the y axis. The values must be 2 or greater. The default is 4.
296 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
data work.hat ; do x = -5 to 5 ; do y = -5 to 5 ; z = sin(sqrt( x*x + y*y )) ; output ; end; end; run; proc g3d data=work.hat; plot y*x=z / yticknum=3; run;
ZTICKNUM The ZTICKNUM parameter defines the number of major tick marks located on the z axis. The values must be 2 or greater. The default is 4.
data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / zticknum=3; run;
Chapter 10: Other Parameters 297
ZMAX/ZMIN The ZMAX and ZMIN parameters are used to specify the maximum and minimum values to display on the z axis. By default, these values are set based on the data. If you define the parameters to be outside of the minimum and maximum values, the z axis is extended. In this example, you can see that there are significantly fewer points than in the previous graph, which used the same data and did not set a ZMIN or ZMAX parameter. data work.giris; set samples.giris; do i=1 to _n_; if sepallen > 70 then datacolor="CX33FFFF"; else datacolor="CXFF3333"; output; end; run; proc g3d data=work.giris; scatter petallen*petalwid=sepallen / zmin=50 zmax=60; run;
298 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
10.5.1 Summary The following tables show which parameters can be used with specific types of charts. Chart Type PLOT SCATTER
GRID
NONEEDLE
ROTATE
SHAPE
3
3
Chart Type PLOT SCATTER
TILT
XTICKNUM
YTICKNUM
ZTICKNUM
ZMAX/ZMIN
3
3 3
3 3
3 3
3
3
SIDE
SIZE
3 3
3
10.5.2 Non-supported parameters Some parameters are not supported by the Java device driver. XYTYPE
The XYTYPE parameter defines which directional lines to use to represent the surface of a surface plot.
P a r t
3
Putting It Together Chapter 11 Final Reports 301 Appendix A SAS/GRAPH Samples and WORK Data Sets 313
300 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
C h a p t e r
11
Final Reports 11.1 Report 1: Using SAS AppDev Studio 3 Tags 301 11.2 Report 2: Using ODS 307 11.3 Conclusions 310
In this chapter, we show complete examples of both SAS AppDev Studio tags and ODS statements. We show the output and the complete code, and then break down the code to highlight specific areas.
11.1 Report 1: Using SAS AppDev Studio 3 Tags The objective of this example is to produce a report on energy production for the years 1985 through 1988. We also want to use a graph style to quickly enhance the look of the report and give it a standard color theme. There are also some items we need to enhance to ensure that the information is easily read.
302 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Here is the completed report, followed by the code that produced it.
Chapter 11: Final Reports 303
<%@taglib uri="http://www.sas.com/taglib/sas" prefix="sas"%> <% java.util.Properties jdbcProperties = new java.util.Properties(); jdbcProperties.setProperty("librefs", "samples 'c:/projects/BBU/data';" ); jdbcProperties.setProperty( "username", "sasdemo" ); jdbcProperties.setProperty( "password", "SAS1demo" ); session.setAttribute( "jdbcProperties", jdbcProperties ); %> <sas:JDBCConnection id="jdbcConn" databaseURL="jdbc:sasiom://localhost:8591" connectionInfo="jdbcProperties" driverName="com.sas.rio.MVADriver" scope="session" /> <jsp:useBean id="jdbcTableModelAdaptor" scope="session" class="com.sas.storage.jdbc.JDBCToTableModelAdapter"> <jsp:setProperty name="jdbcTableModelAdaptor" property="queryStatement" value="select * from samples.eprdcon2 where cptype='p'"/> <jsp:setProperty name="jdbcTableModelAdaptor" property="connection" value="<%=jdbcConn%>" /> <jsp:useBean id="report1_TableDataModel" scope="session" class="com.sas.graphics.components.piechart.PieChartTableDataModel"> <jsp:setProperty name="report1_TableDataModel" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% report1_TableDataModel.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("ENGYTYPE")); report1_TableDataModel.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); report1_TableDataModel.setSubgroupVariable( new com.sas.graphics.components.ClassificationVariable("YEAR")); %> Energy Production 1985- 1988
<sas:PieChart id="report1Pie" model="report1_TableDataModel" scope="session" appliedGraphStyleName="gears" height="500" width="500"> <sas:PieChartModel responseLabelVisiblePolicy="false"> <sas:SubgroupLabelModel> <sas:ValueTextStyle justification="right">
304 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<sas:Font bold="true"/> <sas:LabelTextStyle color="black"> <sas:Font bold="true" /> <sas:LegendModel label="Energy Type"> <sas:ValueTextStyle> <sas:Font bold="true"/> <sas:LabelTextStyle color="black"> <sas:Font bold="true" /> |
For a review, let’s break down the JSP file. <%@taglib uri="http://www.sas.com/taglib/sas" prefix="sas"%> <% java.util.Properties jdbcProperties = new java.util.Properties(); jdbcProperties.setProperty("librefs", "samples 'c:/projects/BBU/data';" ); jdbcProperties.setProperty( "username", "sasdemo" ); jdbcProperties.setProperty( "password", "SAS1demo" ); session.setAttribute( "jdbcProperties", jdbcProperties ); %> <sas:JDBCConnection id="jdbcConn" databaseURL="jdbc:sasiom://localhost:8591" connectionInfo="jdbcProperties" driverName="com.sas.rio.MVADriver" scope="session" />
This first section of the JSP file is merely the setup for the information needed later. First we need to make sure that the application knows where to find the tag library we need to produce the graph. Then we need to set some properties for the JDBC Connection object we create. Finally, we construct a JDBC Connection object and define its parameters. As a suggestion, you could place the connection information in a separate JSP file and use the <jsp:include..> tag to pull it into this JSP file. This will start you on the path of reuse and make the content of your JSP file more readable.
Chapter 11: Final Reports 305
<jsp:useBean id="jdbcTableModelAdaptor" scope="session" class="com.sas.storage.jdbc.JDBCToTableModelAdapter"> <jsp:setProperty name="jdbcTableModelAdaptor" property="queryStatement" value="select * from samples.eprdcon2 where cptype='p'"/> <jsp:setProperty name="jdbcTableModelAdaptor" property="connection" value="<%=jdbcConn%>" />
Now that we have a JDBC Connection object to use, we can set up our data by using the JDBCToTableModelAdapter. This adapter also needs to define only a portion of the data to use. In this case, we want only energy production values. We do not want to include any data that pertains to consumption. In the SQL statement, we add a WHERE clause to subset the data. <jsp:useBean id="report1_TableDataModel" scope="session" class="com.sas.graphics.components.piechart.PieChartTableDataModel"> <jsp:setProperty name="report1_TableDataModel" property="model" value="<%=jdbcTableModelAdaptor%>" /> <% report1_TableDataModel.setCategoryVariable( new com.sas.graphics.components.ClassificationVariable("ENGYTYPE")); report1_TableDataModel.setResponseVariable( new com.sas.graphics.components.AnalysisVariable("AMOUNT")); report1_TableDataModel.setSubgroupVariable( new com.sas.graphics.components.ClassificationVariable("YEAR")); %>
It’s time now to construct the data model. Here we use the PieChartTableDataModel. The graph needs to set a category variable, which is used to collect the values into their respective energy types. Then we need a response variable, which contains the variable values used for the statistics. To help us define the differences between the categories year by year, we use a subgroup variable.
306 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
Energy Production 1985- 1988
<sas:PieChart id="report1Pie" model="report1_TableDataModel" scope="session" appliedGraphStyleName="gears" height="500" width="500"> <sas:PieChartModel responseLabelVisiblePolicy="false"> <sas:SubgroupLabelModel> <sas:ValueTextStyle justification="right"> <sas:Font bold="true"/> <sas:LabelTextStyle color="black"> <sas:Font bold="true" /> <sas:LegendModel label="Energy Type"> <sas:ValueTextStyle> <sas:Font bold="true"/> <sas:LabelTextStyle color="black"> <sas:Font bold="true" /> |
Here comes the fun stuff. Let’s take a look at the actual HTML. There are minimal HTML tags. There is a title we have used for output, as well as code for setting the graph in a table so we can easily center it on the page. The pie chart is created using the sas:PieChart tag. As stated before, we want to provide a quick and easy graph style for consistency. We have chosen the Gears style. Also, instead of using the Response Label as the title, we have elected to not show it and use the HTML tags instead at the top of the page. We find, however, that there are fonts and styles we want to override from Gears. For instance, the values in the subgroup do not show up as well as we had hoped. So we make those bold. We also make adjustments to the legend label.
Chapter 11: Final Reports 307
11.2 Report 2: Using ODS Even though we use the same requirements as for the SAS AppDev Studio example, we do not get the same results. The graphs are similar but utilize different methods in ODS.
308 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
<%@taglib uri="http://www.sas.com/taglib/sasads" prefix="sasads"%> <%@ page import = "com.sas.servlet.util.SocketListener" %> <%@ page import = "com.sas.servlet.util.Util" %> <%@ page import = "com.sas.rmi.Connection" %> <sasads:Connection id="bbuConnection" scope="session" /> <% SocketListener socket = new SocketListener(); int port = socket.setup(); String host = (java.net.InetAddress.getLocalHost()).getHostAddress(); String archivePath="../../assets/graph/"; String libraryPath = "c:\\Projects\\BBU\\data"; socket.start(); %> <sasads:Submit id="smbStreamingBar" display="none" connection="bbuConnection"> libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400; ods listing close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("colorscheme"="fall") style=beige; legend1 label=('Energy Type'); title1 'Energy Production 1985 - 1988'; proc gchart data=samples.eprdcon2; pie engytype / sumvar=amount detail=year legend=legend1 ; run; ods html close; <% socket.write(out); socket.close(); %>
Chapter 11: Final Reports 309
Now let’s review the code. <%@taglib uri="http://www.sas.com/taglib/sasads" prefix="sasads"%> <%@ page import = "com.sas.servlet.util.SocketListener" %> <%@ page import = "com.sas.servlet.util.Util" %> <%@ page import = "com.sas.rmi.Connection" %>
As in previous chapters, we need to enable the browser to use the SAS AppDev Studio 2 tags, and we need to make available all Java classes we will need. <sasads:Connection id="bbuConnection" scope="session" />
The connection object is fairly easy to create, because we are running the SAS/CONNECT Spawner. <% SocketListener socket = new SocketListener(); int port = socket.setup(); String host = (java.net.InetAddress.getLocalHost()).getHostAddress(); String archivePath="../../assets/graph/"; String libraryPath = "c:\\Projects\\BBU\\data"; socket.start(); %>
If you remember from earlier, we also need to set up a socket and a few other Java variables to be used in streaming the SAS ODS statement back out to the browser. <sasads:Submit id="smbStreamingBar" display="none" connection="bbuConnection"> libname samples '<%=libraryPath%>'; filename sock SOCKET '<%=host%>:<%=port%>'; goptions reset=all device=java xpixels=600 ypixels=400; ods listing close; ODS HTML body=sock rs=none CODEBASE="<%=archivePath%>" parameters=("colorscheme"="fall") style=beige; legend1 label=('Energy Type'); title1 'Energy Production 1985 - 1988';
310 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System
proc gchart data=samples.eprdcon2; pie engytype / sumvar=amount subgroup=year legend=legend1 ; run; ods html close;
Then anything in the SubmitInterface block, as shown here, is written in SAS. So here we establish our library and filename. Then we need to set the options on the GOPTIONS statement to use the Java device driver. Then come the ODS statements. We modify the pie chart in several ways. We enable the chart to use the COLORSCHEME of FALL and a STYLE of BEIGE. The main difference that you can see is that the COLORSCHEME parameter affects the data elements (pie slices), whereas the STYLE parameter affects the text and labels. Then we create a legend and a title to use with the pie chart. Although the subgroup option in the PROC statement is not honored, it does, however, enable the legend to display. <% socket.write(out); socket.close(); %>