0% found this document useful (0 votes)
3K views1,454 pages

SAS 9.4 Graph Template Language Reference

Uploaded by

yue zhao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views1,454 pages

SAS 9.4 Graph Template Language Reference

Uploaded by

yue zhao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1454

SAS 9.

Graph Template Language


Reference
Fourth Edition

SAS® Documentation
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2015. SAS® 9.4 Graph Template Language: Reference, Fourth
Edition. Cary, NC: SAS Institute Inc.
SAS® 9.4 Graph Template Language: Reference, Fourth Edition
Copyright © 2015, SAS Institute Inc., Cary, NC, USA

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.
The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher is illegal and
punishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronic piracy of copyrighted
materials. Your support of others' rights is appreciated.
U.S. Government License Rights; Restricted Rights: The Software and its documentation is commercial computer software developed at private
expense and is provided with RESTRICTED RIGHTS to the United States Government. Use, duplication or disclosure of the Software by the
United States Government is subject to the license terms of this Agreement pursuant to, as applicable, FAR 12.212, DFAR 227.7202-1(a), DFAR
227.7202-3(a) and DFAR 227.7202-4 and, to the extent required under U.S. federal law, the minimum restricted rights as set out in FAR 52.227-19
(DEC 2007). If FAR 52.227-19 is applicable, this provision serves as notice under clause (c) thereof and no other notice is required to be affixed to
the Software or documentation. The Government's rights in Software and documentation shall be only those set forth in this Agreement.
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513-2414.
July 2015
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 trademarks of their respective companies.
Contents

What’s New in SAS 9.4 Graph Template Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

PART 1 Fundamentals 1

Chapter 1 • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Graph Template Language (GTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Basic Anatomy of an ODS Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Graphical Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Flexible Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
About the Examples in This Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Examples and Resources on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

PART 2 Graph Block 19

Chapter 2 • BEGINGRAPH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

PART 3 Layout Statements 39

Chapter 3 • Summary of Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Single-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Multi-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Data-driven Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Legend Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Chapter 4 • Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

PART 4 Plot Statements 173

Chapter 5 • Key Concepts for Using Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175


Minimum Requirements to Generate a Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
ODS Graphics Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Display Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Location and Position of Curve Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
iv Contents

Chapter 6 • Plot Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

PART 5 Plot Axes 873

Chapter 7 • Axis Features in Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875
How Axis Features Are Determined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875
Controlling Axis Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883

Chapter 8 • Axis Options in Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889

PART 6 Legend Statements 1087

Chapter 9 • Legend Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1089


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1089

PART 7 Text Statements 1135

Chapter 10 • Managing Text Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1137


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1137
Using Prefix Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1138
Using Text Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140
Reserved Keywords and Unicode Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142

Chapter 11 • Text Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147

PART 8 Custom Marker Definition Statements 1171

Chapter 12 • Custom Marker Definition Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173

PART 9 Draw Statements 1187

Chapter 13 • Key Concepts for Using Draw Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189
Types of Elements That Can Be Drawn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192
About the Drawing Space and Drawing Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1192
How the Drawn Elements Are Anchored . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1195
About Drawing Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1195
Contents v

Chapter 14 • Draw Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1199


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1199

PART 10 GTL Annotation Facility 1259

Chapter 15 • About the GTL Annotation Facility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1261


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1261
The Annotation Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1262
The ANNOTATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1266
The SGRENDER Statement SGANNO Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1266

Chapter 16 • The ANNOTATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267

PART 11 Attribute Maps 1275

Chapter 17 • Key Concepts for Using Attribute Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1277


About Attribute Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1277
Defining a Discrete Attribute Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1278
Defining a Range Attribute Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1281
Referencing an Attribute Map in Your Plot Statements . . . . . . . . . . . . . . . . . . . . . . . 1282

Chapter 18 • Discrete Attribute Map Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287

Chapter 19 • Range Attribute Map Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1301


Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1301

PART 12 Run-Time Programming Features 1311

Chapter 20 • Dynamics and Macro Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313


Template Types on PROC TEMPLATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313
DYNAMIC, MVAR, and NMVAR Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313
Dynamics Compared to Macro Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1315

Chapter 21 • Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1317


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1317
GTL Expressions Compared to WHERE Expressions . . . . . . . . . . . . . . . . . . . . . . . . 1318
An Expression in Statement Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318

Chapter 22 • Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321
SAS Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321
Functions Defined Only in GTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1324
GTL Summary Statistic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1328

Chapter 23 • Conditional Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333
Conditional Logic Determines Statement Rendering . . . . . . . . . . . . . . . . . . . . . . . . . 1334
vi Contents

GTL Does Not Provide ELSE IF Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1335

PART 13 Appendixes 1337

Appendix 1 • Syntax Conventions and Argument Value Types . . . . . . . . . . . . . . . . . . . . . . . . 1339


Syntax Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339
Value Types for Statement Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339

Appendix 2 • Reserved Keywords and Unicode Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343

Appendix 3 • Display Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347


General Syntax for Attribute Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347
Attributes Available for the Attribute Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1348
Available Line Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1352

Appendix 4 • SAS Formats Not Supported . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1353


Using SAS Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1353
Unsupported Numeric Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1353
Unsupported Date and Time Formats Related to ISO 8601 . . . . . . . . . . . . . . . . . . . . 1354
Other Unsupported Date and Time Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1354
Unsupported Currency Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1355
Unsupported User-Defined Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1355

Appendix 5 • Generalized Macro for BOXPLOTPARM Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 1357

Appendix 6 • Memory Management for ODS Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1363


SAS Options Affecting Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1363
Managing a Java Out of Memory Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1363

Recommended Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1367


Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1369
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1381
vii

What’s New in SAS 9.4 Graph


Template Language

Overview

New and enhanced statements for the Graph Template Language (GTL) extend the
versatility of the language and introduce new plot types. The following changes are
included in this release:
• new plot statements
• new features for general use
• enhancements to SAS 9.3 statements

Possible Changes Required for Your Existing


SAS GTL Programs

There are changes in GTL for SAS 9.4 and subsequent maintenance releases that might
require you to modify your existing SAS GTL programs. These changes can impact SAS
GTL programs that use the DENSITYPLOT or BARCHART statements. Review this
section carefully to determine whether you need to modify your existing SAS GTL
programs for SAS 9.4.

Programs That Use the BARCHART Statement


In SAS 9.4, the BARCHART statement STAT=PCT option now displays percentages in
the range 0–100 in order to be consistent with other GTL statements. In prior releases,
STAT=PCT displays proportional values in the range 0–1. To restore the proportional
values in SAS 9.4 and later releases, change STAT=PCT to STAT=PROPORTION.
In the third maintenance release of SAS 9.4, the COLORSTAT= option is added to the
BARCHART statement. It is enabled by the COLORRESPONSE= option. The
COLORSTAT= option specifies the statistic to be calculated for the data range of the
bar-color gradient. The default is SUM. For existing SAS programs that use the
BARCHART statement, if STAT= is used with COLORRESPONSE= in the
BARCHART statement and STAT= specifies a statistic other than SUM, then the bar-
chart colors and color statistic might change from those of previous releases. In that
case, to restore the original colors and color statistic, set COLORSTAT= in the
BARCHART statement to the same statistic that is specified in STAT=.
See BARCHART in “Plot Statement Enhancements” on page xiv.
viii Graph Template Language

Programs That Use the DENSITYPLOT Statement


In SAS 9.4, the WEIGHT= option of the KERNEL( ) distribution option in the
DENSITYPLOT statement is changed to WEIGHTFUNCTION=. This change enables
the addition of the WEIGHT= option in the DENSITYPLOT statement. Starting with
SAS 9.4, the WEIGHT= option is not valid in the KERNEL() distribution option and
results in a syntax error. If your existing SAS programs specify the WEIGHT= option in
the KERNEL( ) distribution option, then you must change it to WEIGHTFUNCTION=.
See DENSITYPLOT in “Plot Statement Enhancements” on page xiv.

Programs That Use the HEATMAPPARM Statement


In the third maintenance release of SAS 9.4, the DISCRETEX= and DISCRETEY=
options are added to the HEATMAPPARM statement. These options specify whether the
X or Y axis is discrete. The default is FALSE. For existing SAS programs that use the
HEATMAPPARM statement, if the X axis is discrete, the DISCRETEX=TRUE option
must be specified in the HEATMAPPARM statement. Likewise, if the Y axis is discrete,
the DISCRETEY=TRUE option must be specified in the HEATMAPPARM statement.
Otherwise, the heat map might not be drawn.

Programs That Use the WATERFALLCHART Statement


In the third maintenance release of SAS 9.4, the COLORSTAT= option is added to the
WATERFALLCHART statement. It is enabled by the COLORRESPONSE= option. The
COLORSTAT= option specifies the statistic to be calculated for the data range of the
color gradient. The default is SUM. For existing SAS programs that use the
WATERFALLCHART statement, if STAT= is used with COLORRESPONSE= in the
WATERFALLCHART statement and STAT= specifies a statistic other than SUM, then
the chart colors and color statistic might change from those of previous releases. In that
case, to restore the original colors and color statistic, set COLORSTAT= in the
WATERFALLCHART statement to the same statistic that is specified in STAT=. See
WATERFALLCHART in “Plot Statement Enhancements” on page xiv.

New Plot Statements

The following plot statements are new:


• ANNOTATE draws annotations from annotation instructions that are stored in a SAS
data set. It can draw all of the annotations in the data set or a subset only.
• AXISTABLE draws textual values (character or numeric) on the graph at locations
that are aligned with the X or Y axis.
• LINECHART creates a summarized line chart that is computed from input data.
In the first maintenance release of SAS 9.4, the following statement is new:
• POLYGONPLOT draws one or more polygons from data that is stored in a SAS data
set.
In the second maintenance release of SAS 9.4, the following statement is new:
Color-Priority Graph Data Attribute Rotation ix

• TEXTPLOT displays text values at specific X and Y locations in the graph. For
information about subsequent enhancements to this statement, see “Plot Statement
Enhancements” on page xiv.
In the third maintenance release of SAS 9.4, the following statement is new:
• HEATMAP creates a plot of color-coded rectangles for the response variable of a
pair of X and Y variables after it bins the data in two dimensions.

New Legend Statement

In the third maintenance release of SAS 9.4, the LEGENDTEXTITEMS statement is


new. This statement creates the definition for data-driven text items that can be included
in a discrete legend. The items and optional labels are stored in the plot data set.

New Marker Definition Statements

In the first maintenance release of SAS 9.4, the following statements are new:
• SYMBOLCHAR defines a marker symbol from a Unicode character value.
• SYMBOLIMAGE defines a marker symbol from a GIF, JPG, or PNG image that is
stored in a file.
You can use these statements to define custom marker symbols for your graphs. For
information about subsequent enhancements to these statements, see “Marker Definition
Statement Enhancements” on page xxxvii.

New Function

In the first maintenance release of SAS 9.4, the TYPEOF function is new. This function
returns the type (numeric or character) of a specified column at run time. You can use the
TYPEOF function to take specific actions in your template at run time based on the input
data type.

New Features for General Use

Color-Priority Graph Data Attribute Rotation


The GTL now supports a color-priority rotation pattern for cycling graph data attributes.
In the default rotation pattern, graph data attributes rotate as they are defined in the
GraphData1–GraphDataN style elements. The new color-priority rotation pattern first
cycles through all of the colors while holding the marker symbol, line pattern, or fill
x Graph Template Language

pattern constant. When all of the colors have been used, it increments to the next marker
symbol, line pattern, or fill pattern, and then repeats the colors.
Color-priority rotation is enabled in one of the following ways:
• the currently active style sets the Graph:attrPriority attribute to COLOR
• the ATTRPRIORITY=COLOR option is specified in the ODS GRAPHICS
statement, which overrides the Graph:attrPriority style attribute
• the ATTRPRIORITY=COLOR option is specified in the BEGINGRAPH statement
of the template, which overrides the ODS GRAPHICS ATTRPRIORITY= option for
all plots in that template
When none of these conditions are true, the default rotation pattern is used. For more
information, see “BEGINGRAPH Statement Enhancements” on page xi.

Template-Level Graph Data Attribute Overrides


The GTL provides new options that enable you to override GraphData1–GraphDataN
style attributes for all of the plots within a template. They provide an easy way to modify
group attributes without having to create a custom ODS style. These options are used in
the BEGINGRAPH statement of a template. By using these options, you can override
attributes in the GraphData1–GraphDataN style elements by specifying one or more of
the following lists for all of the plots within a template:
• a list of colors that replace the graph data colors (fill) in the current style
• a list of contrast colors that replace the graph data contrast colors in the current style
• a list of marker symbols that replace the graph data marker symbols in the current
style
• a list of line patterns that replace the graph data line patterns in the current style
In addition, you can specify a priority for the group value attribute cycling. For more
information, see “BEGINGRAPH Statement Enhancements” on page xi.

Outer Padding
The GTL provides a new OUTERPAD= option that enables you to control the padding
around the outside of layouts, legends, titles, footnotes, and text entries. You can use this
option to modify the outer padding when the default padding is not sufficient. You can
specify a single padding value for all four sides, or you can specify different values for
each side.

Unicode Values in User-Defined Formats


Starting with the third maintenance release of SAS 9.4, ODS Graphics supports Unicode
values in user-defined formats. The Unicode value must be escaped with the (*ESC*)
escape sequence, as shown in the following example.
"(*ESC*){unicode beta}"

ODS Graphics does not support the use of a user-defined ODS escape character to
escape Unicode values in user-defined formats.
BEGINGRAPH Statement Enhancements xi

General Enhancements Supported by Many of the Plots


The following new features that are supported by many of the plot statements are worth
highlighting. The individual plot statements that support these features are identified in
“Plot Statement Enhancements” on page xiv.
• The algorithm that is used to place data labels has been improved to more effectively
position the data labels in the vicinity of their data markers while avoiding label
collisions.
• In certain cases, you can rotate or split data labels, curve labels, and discrete-axis tick
values in order to fit them in the available space.
• Subpixel rendering is now supported, which produces smoother curves and more
precise bar spacing in plots.
• You can now suppress tips and URLs from individual plots.

Enhancements to SAS 9.4 Statements

BEGINGRAPH Statement Enhancements


• ATTRPRIORITY= specifies a priority for cycling of the attributes for group
attributes.
• DATACOLORS= specifies the list of fill colors that replaces the graph data colors
from the GraphData1–GraphDataN style elements.
• DATACONTRASTCOLORS= specifies the list of contrast colors that replaces the
graph data contrast colors from the GraphData1–GraphDataN style elements.
• DATALINEPATTERNS= specifies the list of line patterns that replaces the graph
data line patterns from the GraphData1–GraphDataN style elements.
• DATASKIN= enhances the visual appearance of all plots in the template that support
data skins.
• DATASYMBOLS= specifies the list of marker symbols that replaces the graph data
marker symbols from the marker symbols that are defined in the GraphData1–
GraphDataN style elements.
• SUBPIXEL= specifies whether subpixel rendering is used for drawing smooth
curved lines or for spacing bars more precisely.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• AXISBREAKSYMBOL= specifies a symbol to use on the axis lines to indicate a
break in the axis.
• AXISBREAKTYPE= specifies whether the axis break is indicated in the full
display or only on the axis line.
• AXISLINEEXTENT= specifies the extent of the axis line for all axes.
xii Graph Template Language

• DISCRETEAXISOFFSETPAD= specifies whether additional padding is added


to the minimum and maximum axis offsets for discrete axes.
• OPAQUE= specifies whether the graph background is opaque or transparent.

Layout Statement Enhancements


LAYOUT DATALATTICE and LAYOUT DATAPANEL:
• For cell insets, match-merging is now supported for merging the inset and analysis
data. The DATASCHEME= suboption of the INSETOPTS= option specifies whether
one-to-one merging or match merging was used to merge the data.
• HEADERLABELDISPLAY= now supports NONE, which suppresses the row and
column headings, or the cell headings.
• SORTORDER= specifies the order of the cells along the columns and rows.
• LAYOUT DATALATTICE only:
• COLUMNDATARANGE=, ROWDATARANGE=, COLUMN2DATARANGE=,
and ROW2DATARANGE= now support AUTO, which selects the range
automatically, based on the column weight or row weight, and the axis type.
• COLUMNWEIGHT= specifies how to assign weights to the columns widths.
• ROWWEIGHT= specifies how to assign weights to the row heights.
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• HEADERPACK= specifies whether the values listed in the cell headers are
displayed as a delimited list in a single header cell in order to save space.
• HEADERSEPARATOR= specifies a separator to place between each value in the
cell header.
• HEADERSPLITCOUNT= specifies the number of class variables in the cell
header after which the cell header wraps to a separate line.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• For the INSETOPTS= option:
• CONTENTDISPLAY= specifies whether the variable information displayed
in the inset includes the column label and value, or the column value only.
• SEPARATOR= specifies a new separator for the column label and value.
• Starting with the third maintenance release of SAS 9.4, HEADERBORDER=
specifies whether a border is drawn around the header cells.
LAYOUT GLOBALLEGEND:
• Starting with the first maintenance release of SAS 9.4, the default padding between
the global legend and the plot area (including the axes) is 10 pixels. The
OUTERPAD= option can be used to adjust the padding if necessary.
LAYOUT OVERLAY:
• INNERMARGIN statement:
• ALIGN= now supports LEFT and RIGHT in addition to TOP and BOTTOM.
• BACKGROUNDCOLOR= specifies the color of the inner margin background.
Legend Statement Enhancements xiii

• OPAQUE= specifies whether the inner margin's background is opaque.


• Starting with the first maintenance release of SAS 9.4, the following
enhancements are valid:
• SEPARATOR= specifies whether a separating line is drawn between the
inner margin and the rest of the layout content.
• SEPARATORATTRS= specifies the attributes of the inner margin separating
line.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• GUTTER= specifies the gap between stacked items in the inner margin.
• PAD= specifies the amount of extra space that is added inside the inner
margin border.
LAYOUT OVERLAYEQUATED:
• The HEATMAPPARM statement is now supported.
• EQUATETYPE= now supports SQUAREDATA, which specifies that both the X and
Y axes have the same range, but can have different tick values.
LAYOUT PROTOTYPE:
• The HEATMAPPARM statement is now supported.
• Starting with the first maintenance release of SAS 9.4, the INNERMARGIN
statement is now supported in a LAYOUT PROTOTYPE block.

Legend Statement Enhancements


AXISLEGEND:
• Starting with the second maintenance release of SAS 9.4, the BORDER= option
defaults to style reference GraphLegendBackground:FrameBorder.
DISCRETELEGEND:
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• The default padding between the legend and the plot area (including the axes) is
10 pixels, depending on the context. You can use the OUTERPAD= option to
adjust the padding if necessary.
• ITEMSIZE= specifies the size of specific types of items in a discrete legend.
• Starting with the second maintenance release of SAS 9.4, the BORDER= option
defaults to style reference GraphLegendBackground:FrameBorder.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• FILLITEMOUTLINE= specifies whether the fill swatches are outlined only
when enabled by the contributing statements or are always outlined.
• The ITEMSIZE= option now supports the following suboptions:
• FILLASPECTRATIO= specifies the aspect ratio for the fill swatches.
• FILLHEIGHT= specifies the height of the fill swatches.
xiv Graph Template Language

• HEIGHTSCALE= specifies a scaling factor that is to be applied to the fill


swatch height.
• SORTBY= specifies whether text legend items are sorted by label or by text.
CONTINUOUSLEGEND:
• EXTRACTSCALE= specifies whether to extract a scale factor from the tick values
and use it to reduce the tick value width.
• EXTRACTSCALETYPE= specifies whether to extract a named scale or a scientific-
notation scale.
• Starting with the second maintenance release of SAS 9.4, the BORDER= option
defaults to style reference GraphLegendBackground:FrameBorder.
• Starting with the third maintenance release of SAS 9.4, INTEGER= specifies
whether only integer tick values are used in the continuous legend.
LEGENDITEM:
• FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
• Starting with the third maintenance release of SAS 9.4, FILLDISPLAY= specifies
whether the fill swatch for this legend item displays fill only or displays fill and
outline.
MERGEDLEGEND:
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• ADDITIONALNAMES= specifies the name of one or more sources for legend
items that are to be added to the merged legend after merging takes place.
• ITEMSIZE= specifies the size of specific types of items in a merged legend.
• Starting with the second maintenance release of SAS 9.4, the BORDER= option
defaults to style reference GraphLegendBackground:FrameBorder.

Plot Statement Enhancements


AXISTABLE:
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• CLASSDISPLAY= specifies how the class values are displayed.
• CLASSORDER= specifies the order in which the class values are displayed.
• CLUSTERWIDTH= specifies the width of the group clusters as a fraction of the
midpoint spacing.
• DISPLAY= now supports VALUES, which displays the table values.
• DROPONMISSING= specifies whether the entire axis table is dropped when all
of the VALUE= column values are missing.
• GUTTER= specifies the gap between rows when a class variable is used.
• INCLUDEMISSINGCLASS= specifies whether missing class values are
represented in the table.
• LABEL= specifies the text for the table label.
Plot Statement Enhancements xv

• LABELHALIGN= specifies the horizontal alignment of the column labels


relative to the column width in a Y-axis table.
• LABELJUSTIFY= specifies the justification of the column label, when
displayed.
• PAD= specifies the amount of extra space that is added inside the table border.
• SHOWMISSING= specifies whether missing values are represented in the table.
• TITLE= specifies the text for the table title.
• TITLEATTRS=specifies the color and font attributes of the table title.
• TITLEHALIGN= specifies the horizontal alignment of the axis table header label
relative to the table width for a Y-axis table.
• TITLEJUSTIFY= specifies the justification of the title string.
• VALUEFORMAT= specifies a SAS format or a user-defined format for the table
values.
• VALUEHALIGN= specifies the horizontal alignment of the column values
relative to the column width in a Y-axis table.
• VALUEJUSTIFY= specifies the justification of the values in the axis table.
• The following options are replaced and considered deprecated:
• HEADERLABEL= is replaced with TITLE=.
• HEADERLABELATTRS= is replaced with TITLEATTRS=.
The deprecated options are still honored, but the new options are the preferred
options.
• Starting with the third maintenance release of SAS 9.4, TITLEHALIGN= specifies
the horizontal alignment of the axis table header label relative to the table width for
Y-axis tables and X-axis tables.
BANDPLOT:
• TIP= now supports NONE, which suppressed data tips from the plot.
• Starting with the second maintenance release of SAS 9.4:
• ANTIALIAS= specifies whether anti-aliasing is turned off for a band plot.
BARCHART:
• X= is changed to CATEGORY= in order to be consistent with the other GTL plot
statements. The X= option is still valid for backward compatibility. However, you
should change the X= option to CATEGORY= in your BARCHART statements.
Note: If you specify X as a data tip role when you change X= to CATEGORY=, then
you must also change X to CATEGORY in your data tip options.
• Y= is changed to RESPONSE= in order to be consistent with the other GTL plot
statements. The Y= option is still valid for backward compatibility. However, you
should change the Y= option to RESPONSE= in your BARCHART statements.
Note: If you specify Y as a data tip role when you change Y= to RESPONSE=, then
you must also change Y to RESPONSE in your data tip options.
• BARLABELFITPOLICY= specifies a policy for avoiding collisions among the bar
labels when bar labels are displayed.
• BASELINEATTRS= specifies the appearance of the baseline.
xvi Graph Template Language

• The baseline is now drawn by default. To suppress the baseline, use the
BASELINEATTRS= option to set the line thickness to 0.
• DATALABELFITPOLICY= specifies a policy for avoiding collisions among the bar
labels when bar labels are displayed.
• STAT= now supports PROPORTION, which displays proportions in the range 0–1.
• STAT=PCT now displays percentages in the range 0–100 in order to be consistent
with other GTL statements.
Note: In prior SAS releases, the BARCHART statement STAT=PCT option displays
proportional values in the range 0–1. To restore the original STAT=PCT results in
SAS 9.4 and later releases, specify STAT=PROPORTION in your BARCHART
statements instead.
• TIP= now supports NONE, which suppressed data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• GROUPORDER= supports REVERSEDATA, which orders the groups within a
category in the reverse group-column data order.
• FILLTYPE= specifies whether the fill color is solid or is a gradient that
transitions from fully opaque to fully transparent.
• SEGMENTLABEL= specifies whether a label is displayed inside each bar
segment.
• SEGMENTLABELATTRS= specifies the text properties of the bar segment label
text.
• SEGMENTLABELFITPOLICY= specifies a policy for fitting the bar segment
labels within the bar segments.
• SEGMENTLABELFORMAT= specifies the text format used to display the bar
segment labels.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• The BARCHART statement now supports a linear category axis or a time
category axis.
• COLORBYFREQ= specifies whether the bar colors are based on the frequency
of the category variable.
• COLORMODEL= specifies a color ramp that is to be used with the
COLORRESPONSE= option or the COLORBYFREQ= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the bar colors.
• COLORSTAT= specifies the statistic to use for computing the response colors.
• DISPLAYZEROLENGTHBAR= specifies whether zero-length bars are drawn.
• GROUP100= displays the computed response values (FREQ, SUM, or MEAN),
normalized to 100%.
• INTERVALBARWIDTH= specifies the width of the bars in an interval bar chart
as a ratio of the interval width.
BARCHARTPARM:
Plot Statement Enhancements xvii

• X= is changed to CATEGORY= in order to be consistent with the other GTL plot


statements. The X= option is still valid for backward compatibility. However, you
should change the X= option to CATEGORY= in your BARCHARTPARM
statements.
• Y= is changed to RESPONSE= in order to be consistent with the other GTL plot
statements. The Y= option is still valid for backward compatibility. However, you
should change the Y= option to RESPONSE= in your BARCHARTPARM
statements.
• BASELINEATTRS= specifies the appearance of the baseline.
• The baseline is now drawn by default. To suppress the baseline, use the
BASELINEATTRS= option to set the line thickness to 0.
• DATALABELFITPOLICY= specifies a policy for avoiding collisions among the bar
labels when bar labels are displayed.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• ERRORBARCAPSHAPE= specifies whether the error bars have a serif cap. Starting
with the second maintenance release of SAS 9.4, this option defaults to style
reference GraphError:CapStyle.
• TIP= now supports NONE, which suppressed data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• DATALABELTYPE= specifies whether the data labels display the RESPONSE
values or the values of the column specified by the DATALABEL= option.
• FILLTYPE= specifies whether the fill color is solid or is a gradient that
transitions from fully opaque to fully transparent.
• GROUPORDER= supports REVERSEDATA, which orders the groups within a
category in the reverse group-column data order.
• SEGMENTLABELATTRS= specifies the text properties of the bar segment label
text.
• SEGMENTLABELFITPOLICY= specifies a policy for fitting the bar segment
labels within the bar segments.
• SEGMENTLABELFORMAT= specifies the text format used to display the bar
segment labels.
• SEGMENTLABELTYPE= specifies whether a label is displayed inside each bar
segment.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• The BARCHARTPARM statement now supports a linear category axis or a time
category axis.
• COLORMODEL= specifies a color ramp that is to be used with the
COLORRESPONSE= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the bar colors.
xviii Graph Template Language

• DISPLAYZEROLENGTHBAR= specifies whether zero-length bars are drawn.


• GROUP100= displays the computed values normalized to 100%.
• INTERVALBARWIDTH= specifies the width of the bars as a ratio of the interval
width.
BLOCKPLOT:
• BLOCKLABEL= specifies alternative text to display for the internal block text
values.
• VALUEFITPOLICY= now supports the SPLIT, SPLITALWAYS, and NONE
policies.
• VALUESPLITCHAR= specifies one or more characters on which the values can be
split if needed.
• VALUESPLITCHARDROP= specifies whether the split characters are included in
the displayed values.
BOXPLOT:
• CAPSHAPE= now supports NONE, which specifies that no shape is displayed at the
ends of the box whiskers.
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the visual appearance of the filled boxes.
• DISPLAYSTATS= specifies the statistics that are displayed for each box.
• TIP= now supports NONE, which suppressed data tips from the plot.
• WEIGHT= specifies a column that contains a statistics calculation a priori weight for
each observation of the input data object.
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• WHISKERPERCENTILE= specifies the whisker length in percentile units.
• DISPLAYSTATS= now displays the DATAMAX, DATAMIN, and SUMWGT
statistics.
• LEGENDLABEL= now defaults to the Y= column label or name.
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
• Starting with the third maintenance release of SAS 9.4, when DISPLAY= includes
MEAN, the BOXPLOT statement contributes its mean markers to a discrete legend
when TYPE=MARKER is specified in the DISCRETELEGEND statement.
BOXPLOTPARM:
Plot Statement Enhancements xix

• CAPSHAPE= now supports NONE, which specifies that no shape is displayed at the
ends of the box whiskers.
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the visual appearance of the filled boxes.
• TIP= now supports NONE, which suppresses data tips from the plot.
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• DISPLAYSTATS= now displays the DATAMAX, DATAMIN, and SUMWGT
statistics.
• LEGENDLABEL= now defaults to the Y= column label or name.
• URL= specifies an HTML page that is displayed when a box or an outlier marker
is selected.
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
• Starting with the third maintenance release of SAS 9.4, when DISPLAY= includes
MEAN, the BOXPLOTPARM statement contributes its mean markers to a discrete
legend when TYPE=MARKER is specified in the DISCRETELEGEND statement.
BUBBLEPLOT:
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the third maintenance release of SAS 9.4, DRAWORDER= specifies
whether the bubbles are drawn according to bubble size or according to data order.
CONTOURPLOTPARM:
• LEVELS= specifies a list of contour level values.
DENDROGRAM:
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
DENSITYPLOT:
xx Graph Template Language

• CURVELABELSPLIT= specifies whether to split the curve label at the specified


split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the curve
label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the curve label block.
• WEIGHT= specifies a column that contains a density-curve calculation a priori
weight for each observation of the input data object.
• The KERNEL() distribution option WEIGHT= is changed to
WEIGHTFUNCTION=. This change enables the addition of the WEIGHT= option
in the DENSITYPLOT statement.
Note: The WEIGHT= option is not valid in the KERNEL() distribution option in
SAS 9.4. If you used the WEIGHT= option in the KERNEL() distribution option
in prior SAS releases, then you must change it to WEIGHTFUNCTION= in SAS
9.4 and later releases.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• GROUP= creates a separate density curve for each unique group value of the
specified column.
• INCLUDEMISSINGGROUP= specifies whether missing values of the group
variable are included in the plot.
DROPLINE:
• DATASKIN= enhances the appearance of the drop line.
• Starting with the first maintenance release of SAS 9.4, DROPTO= now supports
BOTH, which draws one or more drop lines to both the X and Y axes.
ELLIPSE:
Starting with the second maintenance release of SAS 9.4, the following enhancements
are valid:
• GROUP= creates a separate ellipse for each unique group value of the specified
column.
• INCLUDEMISSINGGROUP= specifies whether missing values of the group
variable are included in the plot.
FRINGEPLOT:
• GROUP= creates a distinct set of lines for each unique group value in the specified
column.
• INCLUDEMISSINGGROUP= specifies whether missing values in the group column
are included in the plot.
• INDEX= specifies indices for mapping line attributes (color and line pattern) to one
of the GraphData1–GraphDataN style elements.
• TIP= now supports NONE, which suppresses data tips from the plot.
HEATMAPPARM:
• URL= specifies an HTML page to display when a rectangle is selected.
Plot Statement Enhancements xxi

• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the
INCLUDEMISSINGCOLOR= option specifies whether missing values of the color-
group variable or the color-response variable are included in the plot.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• DISCRETEX= specifies whether the X axis is discrete when X= specifies a
numeric column.
• DISCRETEY= specifies whether the Y axis is discrete when Y= specifies a
numeric column.
HIGHLOWPLOT:
• CLIPCAP= specifies whether a special clip cap is displayed to indicate where
clipping occurred.
• CLIPCAPSHAPE= specifies the shape of the arrowhead on the clipped end of a line.
• DATASKIN= enhances the visual appearance of the high-low chart filled bars or
lines.
• ENDCAPDISPLAYPOLICY= specifies the policy for displaying end caps when end
caps are present.
• TIP= now supports NONE, which suppresses data tips from the plot.
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• COLORMODEL= specifies a color ramp that is used with the
COLORRESPONSE= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the bar or line colors.
HISTOGRAM:
• DATALABELTYPE= specifies the statistic to display at the end of each bar.
• DATASKIN= enhances the visual appearance of the filled bars.
• WEIGHT= specifies a column that contains a bin-width calculation a priori weight
for each observation of the input data object.
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• The number of bins is limited to approximately 10,000. When the limit is
exceeded, SAS automatically adjusts the NBINS= or BINWIDTH= value to set
the number of bins to about 10,000.
• DISPLAY= now supports FILLPATTERN.
• FILLPATTERNATTRS= specifies the appearance of the pattern-filled bar area.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• FILLTYPE= specifies whether the fill color is solid or is a gradient that
transitions from fully opaque to fully transparent.
xxii Graph Template Language

• GROUP= creates a separate bar segment or bar for each unique group value of
the specified column.
• INCLUDEMISSINGGROUP= specifies whether missing values of the group
variable are included in the plot.
• The OUTLINEATTRS= option defaults are now consistent with that of
BARCHART.
HISTOGRAMPARM:
• DATALABELFITPOLICY= specifies a policy for avoiding collisions among the bin
labels when bin labels are displayed.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATASKIN= enhances the visual appearance of the filled bars.
• TIP= now supports NONE, which suppresses data tips from the plot.
• Starting with the first maintenance release of SAS 9.4, the following enhancements
are valid:
• DISPLAY= now supports FILLPATTERN.
• FILLPATTERNATTRS= specifies the appearance of the pattern-filled bar area.
• Starting with the second maintenance release of SAS 9.4, the FILLTYPE= option
specifies whether the fill color is solid or is a gradient that transitions from fully
opaque to fully transparent.
LINECHART:
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• COLORMODEL= specifies a color ramp that is used with the
COLORRESPONSE= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the line, marker, and fill colors.
LINEPARM:
• CURVELABELSPLIT= specifies whether to split the line label at the specified split
characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the line
label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the line label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the line label block.
LOESSPLOT:
• CURVELABELSPLIT= specifies whether to split the curve label at the specified
split characters.
Plot Statement Enhancements xxiii

• CURVELABELSPLITCHAR= specifies one or more characters on which the curve


label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the curve label block.
MODELBAND:
• Starting with the second maintenance release of SAS 9.4:
• ANTIALIAS= specifies whether anti-aliasing is turned off for a model band plot.
• A confidence band that depicts confidence limits for individual predicted values
(CLI) for a weighted spline plot or regression plot is now displayed as a high-low
chart instead of a band.
NEEDLEPLOT:
• BASELINEATTRS= specifies the appearance of the baseline. This option enables
you to suppress the baseline by setting the line thickness to 0.
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the appearance of the needle plot lines.
• MARKERATTRS= now supports transparency.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
PBSPLINEPLOT:
• CURVELABELSPLIT= specifies whether to split the curve label at the specified
split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the curve
label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the curve label block.
• Starting with the second maintenance release of SAS 9.4, the DEGREE= PBSPLINE
regression option range is 0–10 instead of 0–174.
PIECHART:
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
xxiv Graph Template Language

• Starting with the first maintenance release of SAS 9.4, CENTERFIRSTSLICE=


specifies whether the first pie slice is centered on the starting angle or starts on it.
• Starting with the third maintenance release of SAS 9.4, suboption
TRANSPARENCY= in the PIECHART statement FILLATTRS= option sets the
transparency of the other slice unless transparency is specified in the
OTHERSLICEOPTS= option.
POLYGONPLOT:
• Starting with the second maintenance release of SAS 9.4:
• ANTIALIAS= specifies whether anti-aliasing is turned off for a polygon plot.
• BACKLIGHT= specifies a back-light effect for the polygon label text.
REFERENCELINE:
• CURVELABELSPLIT= specifies whether to split the reference line label at the
specified split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the
reference line label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the reference line label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the reference line label block.
• DATASKIN= enhances the visual appearance of the reference line.
REGRESSIONPLOT:
• CURVELABELSPLIT= specifies whether to split the regression line label at the
specified split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the
regression line label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the regression line label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the regression line label block.
• Starting with the second maintenance release of SAS 9.4, the DEGREE= regression
option range is 1–10 instead of 0–174.
SCATTERPLOT:
• CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
Plot Statement Enhancements xxv

• ERRORBARCAPSHAPE= specifies whether the error bars have a serif cap. Starting
with the second maintenance release of SAS 9.4, this option defaults to style
reference GraphError:CapStyle.
• FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
• JITTER= specifies whether to jitter data markers.
• JITTEROPTS= specifies options for managing jittering.
• LABELSTRIP= specifies whether leading and trailing blanks are stripped from
marker characters or fixed-position data labels before they are displayed in the plot.
• MARKERATTRS= now supports transparency.
• MARKERCHARACTERPOSITION= specifies the justification of the marker
characters.
• MARKERFILLATTRS= specifies the appearance of the filled markers.
• MARKEROUTLINEATTRS= specifies the appearance of the marker outlines.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the first maintenance release of SAS 9.4,
OUTLINEDMARKERCHARACTERS= specifies whether backlighting or a drop
shadow is applied to the characters that are used as marker symbols in order to
enhance their appearance in the graph.
• Starting with the second maintenance release of SAS 9.4:
• CONTRIBUTEOFFSETS= specifies whether the plot's space requirements
contribute to the calculation of the axis offsets.
• The GROUPORDER= option supports REVERSEDATA, which orders the
groups within a category in the reverse group-column data order.
• The following options are replaced and considered deprecated:
• MARKERCOLORGRADIENT= is replaced with COLORRESPONSE=.
• MARKERSIZERESPONSE= is replaced with SIZERESPONSE=.
• MARKERSIZEMAX= is replaced with SIZEMAX=.
• MARKERSIZEMIN= is replaced with SIZEMIN=.
The new options are functionally the same as the deprecated options and are
more consistent with the other plot statements. The deprecated options are still
honored, but the new options are the preferred options.
• The OUTLINEDMARKERCHARACTERS= option is deprecated. It is still
honored, but the TEXTPLOT statement is now the preferred method for creating
scatter plots using text markers.
• Starting with the third maintenance release of SAS 9.4, SUBPIXEL= specifies
whether subpixel rendering is used for image output when the scatter plot is
rendered.
SCATTERPLOTMATRIX:
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
xxvi Graph Template Language

• DATALABELSPLITCHARDROP= specifies whether the split characters are


included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the visual appearance of the plot markers.
• ELLIPSE= now supports the CLIP= option, which specifies whether clipped
confidence ellipses are included in the plot.
• LABELSTRIP= specifies whether leading and trailing blanks are stripped from
marker characters or fixed-position data labels before they are displayed in the plot.
• MARKERATTRS= now supports transparency.
• MARKERCHARACTERPOSITION= specifies the justification of the marker
characters.
• MATRIXTYPE= specifies whether to display the full matrix, or just the upper or
lower triangle of the matrix.
• TIP= now supports NONE, which suppresses data tips from the plot.
• Starting with the second maintenance release of SAS 9.4, the
MARKERCOLORGRADIENT= option is replaced with the COLORRESPONSE=
option and is considered deprecated. The new option is more consistent with the
other plot statements. The MARKERCOLORGRADIENT= option is still honored,
but the COLORRESPONSE= option is the preferred option.
• Starting with the third maintenance release of SAS 9.4, SUBPIXEL= specifies
whether subpixel rendering is used for image output when the scatter plots are
rendered.
SERIESPLOT:
• CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• CURVELABELSPLIT= specifies whether to split the series line label at the
specified split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the series
line label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the series line label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the series line label block.
• DATASKIN= enhances the visual appearance of the series plot lines.
• FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
Plot Statement Enhancements xxvii

• MARKERATTRS= now supports transparency.


• MARKERFILLATTRS= specifies the appearance of the filled markers.
• MARKEROUTLINEATTRS= specifies the appearance of the marker outlines.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the following
enhancements are valid:
• The GROUPORDER= option supports REVERSEDATA, which orders the
groups within a category in the reverse group-column data order.
• LINECOLORGROUP= specifies a column that determines the line colors for a
grouped plot independently of the GROUP= column.
• LINEPATTERNGROUP= specifies a column that determines the line patterns for
a grouped plot independently of the GROUP= column.
• MARKERCOLORGROUP= specifies a column that determines the marker
colors for a grouped plot independently of the GROUP= column.
• MARKERSYMBOLGROUP= specifies a column that determines the marker
symbols for a grouped plot independently of the GROUP= column.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• ARROWHEADPOSITION= specifies a position for arrowheads.
• ARROWHEADSCALE= specifies an arrowhead scale factor based on the
thickness of the arrow line.
• ARROWHEADSHAPE= specifies a shape for arrowheads.
• COLORMODEL= specifies a color ramp that is to be used with the
COLORRESPONSE= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the line and marker colors.
• LINETHICKNESSMAX= specifies the maximum line thickness when a
response variable is used to determine the line thickness.
• LINETHICKNESSMAXRESPONSE= specifies the response value that
corresponds to the maximum line thickness.
• LINETHICKNESSMIN= specifies the minimum line thickness when a response
variable is used to determine the line thickness.
• LINETHICKNESSRESPONSE= specifies a response column or range attribute
variable that is used to map a line thickness to each group value.
• SPLINEPOINTS= specifies a multiplier to apply to the time interval that is in
effect for the INTERVAL= axis option.
• SPLINETYPE= specifies the type of spline interpolation that is used to draw the
series line.
• The LINECOLORGROUP=, LINEPATTERNGROUP=,
MARKERCOLORGROUP=, and MARKERSYMBOLGROUP= options now
support a discrete attribute map variable.
STEPPLOT:
• CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
xxviii Graph Template Language

• DATALABELSPLIT= specifies whether to split the data labels at specified split


characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the appearance of the step plot lines.
• ERRORBARCAPSHAPE= specifies whether the error bars have a serif cap. Starting
with the second maintenance release of SAS 9.4, this option defaults to style
reference GraphError:CapStyle.
• CURVELABELSPLIT= specifies whether to split the step line label at the specified
split characters.
• CURVELABELSPLITCHAR= specifies one or more characters on which the step
line label can be split if needed.
• CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the step line label text.
• CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the step line label block.
• FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
• MARKERATTRS= now supports transparency.
• MARKERFILLATTRS= specifies the appearance of the filled markers.
• MARKEROUTLINEATTRS= specifies the appearance of the marker outlines.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
• Starting with the second maintenance release of SAS 9.4, the GROUPORDER=
option supports REVERSEDATA, which orders the groups within a category in the
reverse group-column data order.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• ARROWHEADPOSITION= specifies a position for arrowheads.
• ARROWHEADSCALE= specifies an arrowhead scale factor based on the
thickness of the arrow line.
• ARROWHEADSHAPE= specifies a shape for arrowheads.
• LINETHICKNESSMAX= specifies the maximum line thickness when a
response variable is used to determine the line thickness.
• LINETHICKNESSMAXRESPONSE= specifies the response value that
corresponds to the maximum line thickness.
• LINETHICKNESSMIN= specifies the minimum line thickness when a response
variable is used to determine the line thickness.
• LINETHICKNESSRESPONSE= specifies a response column or range attribute
variable that is used to map a line thickness to each group value.
SURFACEPLOTPARM:
Plot Statement Enhancements xxix

• Starting with the second maintenance release of SAS 9.4, the


SURFACECOLORGRADIENT= option is replaced with the COLORRESPONSE=
option and is considered deprecated. The new option is more consistent with the
other plot statements. The SURFACECOLORGRADIENT= option is still honored,
but the COLORRESPONSE= option is the preferred option.
TEXTPLOT:
Starting with the third maintenance release of SAS 9.4, the following experimental
options are available:
• OUTFILE= specifies a file for storing information about the text bounding-box for
each text value in the column specified in the OUTID= option.
• OUTID= specifies a column that contains text values to write to the file specified in
the OUTFILE= option.
VECTORPLOT:
• DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
• DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
• DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
• DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
• DATASKIN= enhances the appearance of the vector plot lines.
• TIP= now supports NONE, which suppresses data tips from the plot.
• Starting with the third maintenance release of SAS 9.4, the following enhancements
are valid:
• COLORMODEL= specifies a color ramp that is used with the
COLORRESPONSE= option.
• COLORRESPONSE= specifies the column or range attribute variable that is
used to map the line colors.
• LINETHICKNESSMAX= specifies the maximum line thickness when a
response variable is used to determine the line thickness.
• LINETHICKNESSMAXRESPONSE= specifies the response value that
corresponds to the maximum line thickness.
• LINETHICKNESSMIN= specifies the minimum line thickness when a response
variable is used to determine the line thickness.
• LINETHICKNESSRESPONSE= specifies a response column or range attribute
variable that is used to map a line thickness to each group value.
WATERFALLCHART:
• BARLABELFITPOLICY= specifies a policy for avoiding collisions among the bar
labels when bar labels are displayed.
• BASELINEATTRS= specifies the appearance of the baseline. This option enables
you to suppress the baseline by setting the line thickness to 0.
• TIP= now supports NONE, which suppresses data tips and URLs from the plot.
xxx Graph Template Language

• Starting with the third maintenance release of SAS 9.4, COLORSTAT= specifies the
statistic to use for computing the response colors.

Text Statement Enhancements


ENTRY:
• Starting with the first maintenance release of SAS 9.4, the 512-character limit on the
length of the entry text is removed.
ENTRYFOOTNOTE:
• HALIGNCENTER= specifies whether the footnote is centered automatically by the
system or is always centered in the graph area.
• Starting with the first maintenance release of SAS 9.4, the 512-character limit on the
length of the footnote text is removed.
ENTRYTITLE:
• HALIGNCENTER= specifies whether the title is centered automatically by the
system or is always centered in the graph area.
• Starting with the first maintenance release of SAS 9.4, the 512-character limit on the
length of the title text is removed.

Draw Statement Enhancements


Starting with the first maintenance release of SAS 9.4, for the BEGINPOLYGON,
BEGINPOLYLINE, DRAWTEXT, DRAWLINE, DRAWARROW,
DRAWRECTANGLE, DRAWIMAGE, and DRAWOVAL statements, URL= specifies
an HTML page that is displayed when the output of this draw statement is selected.

Axis Statement Enhancements


LAYOUT OVERLAY:
• LABELFITPOLICY= specifies a policy for fitting axis labels in the available space.
• LABELPOSITION= specifies the position of the axis label.
• LABELSPLITCHAR= specifies one or more characters on which the axis labels can
be split if needed.
• LABELSPLITCHARDROP= specifies whether the split characters are included in
the axis labels.
• LABELSPLITJUSTIFY= specifies the justification of the strings that are inside the
axis label blocks.
• TICKVALUEHALIGN= specifies the horizontal alignment for all of the tick values
that are displayed on the Y and Y2 axes.
• TICKVALUEVALIGN= specifies the vertical alignment for all of the tick values that
are displayed on the X and X2 axes.
• Starting with the third maintenance release of SAS 9.4, LINEEXTENT= specifies
the extent of the axis line.
• DISCRETEOPTS= supports the following new features for discrete axes:
Axis Statement Enhancements xxxi

• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATELAWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, SPLITTHIN, and SPLITROTATE.
• TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• TICKVALUESPLITCHAR= specifies a list of characters on which the tick
values can be split if needed.
• TICKVALUESPLITJUSTIFY= specifies justification of the strings that are
inside the tick value block.
• TICKVALUESPLITCHARDROP= specifies whether the split characters are
included in the displayed tick values.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• LINEAROPTS= supports the following new features for linear axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
• MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which
enables you to specify the type of scale that you want to extract.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• Starting with the first maintenance release of SAS 9.4, INCLUDERANGES=
specifies the ranges for a broken axis.
• Starting with the second maintenance release of SAS 9.4:
• The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
• The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
• The MINORTICKCOUNT= option for linear axes defaults to one minor tick
and two intervals.
• LOGOPTS= supports the following new features for log axes:
xxxii Graph Template Language

• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
• TICKVALUELIST= specifies the tick values for a log axis as a space-separated
list.
• TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
• VALUETYPES= specifies how the VIEWMIN=, VIEWMAX=, and
TICKVALUELIST= option values are interpreted.
• Starting with the second maintenance release of SAS 9.4:
• The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
• The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• TIMEOPTS= supports the following new features for time axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKINTERVAL= specifies the time interval between minor ticks.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• Starting with the first maintenance release of SAS 9.4, INCLUDERANGES=
specifies the ranges for a broken axis.
• Starting with the second maintenance release of SAS 9.4:
• The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
• The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
• Starting with the third maintenance release of SAS 9.4,
INTERVALMULTIPLIER= specifies a multiplier to apply to the time interval
that is in effect for the axis.
LAYOUT OVERLAY3D:
• LINEAROPTS= supports the following new features for linear axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
Axis Statement Enhancements xxxiii

• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on


the axis.
• MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which
enables you to specify the type of scale that you want to extract.
• TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
• Starting with the second maintenance release of SAS 9.4, the
MINORGRIDATTRS= option defaults to style element GraphMinorGridLines in
order to visually contrast the major and minor grid lines.
• TIMEOPTS= supports the following new features for time axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKINTERVAL= specifies the time interval between minor ticks.
• Starting with the second maintenance release of SAS 9.4, the
MINORGRIDATTRS= option defaults to style element GraphMinorGridLines in
order to visually contrast the major and minor grid lines.
• Starting with the third maintenance release of SAS 9.4,
INTERVALMULTIPLIER= specifies a multiplier to apply to the time interval
that is in effect for the axis.
LAYOUT OVERLAYEQUATED:
• MINORGRID= specifies whether grid lines are displayed at the minor tick values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on the
axis.
• MINORTICKS= specifies whether the minor tick marks are displayed on the axis.
• TICKVALUEFITPOLICY= now supports policies NONE and ROTATEALWAYS.
• TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which enables
you to specify the type of scale that you want to extract.
• VIEWMAX= specifies the maximum data value to include in the display (the value
might be adjusted by the threshold calculation).
• VIEWMIN= specifies the minimum data value to include in the display (the value
might be adjusted by the threshold calculation).
• Starting with the third maintenance release of SAS 9.4, LINEEXTENT= specifies
the extent of the axis lines.
LAYOUT LATTICE:
• LABELFITPOLICY= specifies a policy for fitting axis labels in the available space.
• LABELPOSITION= specifies the position of the axis label.
xxxiv Graph Template Language

• LABELSPLITCHAR= specifies one or more characters on which the axis labels can
be split if needed.
• LABELSPLITCHARDROP= specifies whether the split characters are included in
the axis labels.
• LABELSPLITJUSTIFY= specifies the justification of the strings that are inside the
axis label blocks.
• TICKVALUEHALIGN= specifies the horizontal alignment for all of the tick values
that are displayed on the Y and Y2 axes.
• TICKVALUEVALIGN= specifies the vertical alignment for all of the tick values that
are displayed on the X and X2 axes.
• DISCRETEOPTS= supports the following new features for discrete axes:
• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATEALWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, and SPLITTHIN.
• TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• TICKVALUESPLITCHAR= specifies a list of characters on which the tick
values can be split if needed.
• TICKVALUESPLITJUSTIFY= specifies justification of the strings that are
inside the tick value block.
• TICKVALUESPLITCHARDROP= specifies whether the split characters are
included in the displayed tick values.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• LINEAROPTS= supports the following new features for linear axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
• MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which
enables you to specify the type of scale that you want to extract.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
Axis Statement Enhancements xxxv

• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=


specifies how to format the values for major tick marks.
• LOGOPTS= supports the following new features for log axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
• TICKVALUELIST= specifies the tick values for a log axis as a space-separated
list.
• TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
• VALUETYPES= specifies how the VIEWMIN=, VIEWMAX=, and
TICKVALUELIST= option values are interpreted.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• TIMEOPTS= supports the following new features for time axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKINTERVAL= specifies the time interval between minor ticks.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• Starting with the third maintenance release of SAS 9.4:
• TICKVALUEFORMAT= specifies how to format the values for major tick
marks.
• INTERVALMULTIPLIER= specifies a multiplier to apply to the time interval
that is in effect for the axis.
LAYOUT DATALATTICE and LAYOUT DATAPANEL:
• LABELFITPOLICY= specifies a policy for fitting axis labels in the available space.
• LABELPOSITION= specifies the position of the axis label.
• LABELSPLITCHAR= specifies one or more characters on which the axis labels can
be split if needed.
• LABELSPLITCHARDROP= specifies whether the split characters are included in
the displayed axis labels.
• LABELSPLITJUSTIFY= specifies the justification of the strings that are inside the
axis label blocks.
• TICKVALUEHALIGN= specifies the horizontal alignment for all of the tick values
that are displayed on the Y and Y2 axes.
• TICKVALUEVALIGN= specifies the vertical alignment for all of the tick values that
are displayed on the X and X2 axes.
xxxvi Graph Template Language

• DISCRETEOPTS= supports the following new features for discrete axes:


• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATEALWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, and SPLITTHIN.
• TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• TICKVALUESPLITCHAR= specifies a list of characters on which the tick
values can be split if needed.
• TICKVALUESPLITJUSTIFY= specifies justification of the strings that are
inside the tick value block.
• TICKVALUESPLITCHARDROP= specifies whether the split characters are
included in the displayed tick values.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• LINEAROPTS= supports the following new features for linear axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
• MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
• TICKDISPLAYLIST= specifies the text that is displayed for the tick values that
are defined in the TICKVALUELIST= option.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which
enables you to specify the type of scale that you want to extract.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• Starting with the second maintenance release of SAS 9.4, the
MINORGRIDATTRS= option defaults to style element GraphMinorGridLines in
order to visually contrast the major and minor grid lines.
• LOGOPTS= supports the following new features for log axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKCOUNT= specifies the number of minor ticks that are displayed on
the axis.
Discrete Attribute Map Enhancements xxxvii

• TICKVALUELIST= specifies the tick values for a log axis as a space-separated


list.
• TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
• VALUETYPES= specifies how the VIEWMIN=, VIEWMAX=, and
TICKVALUELIST= option values are interpreted.
• Starting with the second maintenance release of SAS 9.4, the
MINORGRIDATTRS= option defaults to style element GraphMinorGridLines in
order to visually contrast the major and minor grid lines.
• Starting with the third maintenance release of SAS 9.4, TICKVALUEFORMAT=
specifies how to format the values for major tick marks.
• TIMEOPTS= supports the following new features for time axes:
• MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
• MINORGRIDATTRS= specifies the attributes of the minor grid lines.
• MINORTICKINTERVAL= specifies the time interval between minor ticks.
• TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
• TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
• Starting with the second maintenance release of SAS 9.4, the
MINORGRIDATTRS= option defaults to style element GraphMinorGridLines in
order to visually contrast the major and minor grid lines.
• Starting with the third maintenance release of SAS 9.4,
INTERVALMULTIPLIER= specifies a multiplier to apply to the time interval
that is in effect for the axis.

Marker Definition Statement Enhancements


SYMBOLCHAR:
Starting with the third maintenance release of SAS 9.4, the following enhancements are
valid:
• HOFFSET= and VOFFSET= now move the marker character within the marker
character bounding box. The bounding box position remains centered on the data
point.
• Offsets applied to the marker character with HOFFSET= and VOFFSET= are also
applied to the marker character that is displayed in the legend.

Discrete Attribute Map Enhancements


The following enhancements have been made to discrete attribute maps:
VALUE statement:
• TEXTATTRS= specifies the text attributes to use when an attribute map is applied to
text in a plot.
xxxviii Graph Template Language

Starting with the first maintenance release of SAS 9.4, the following enhancements are
valid:
• You can now specify the attribute mapping information for a discrete attribute map in
a SAS data set. You now have an alternative to coding your mapping information in
a DISCRETEATTRMAP block in your template. For more information, see SAS
ODS Graphics: Procedures Guide.
• DISCRETEATTRMAP statement:
• DISCRETELEGENDENTRYPOLICY= specifies whether the items that the
associated plot contributes to a discrete legend are items that appear only in the
data or items that are defined only in the attribute map.
• DISCRETEATTRVAR statement:
• ATTRMAP= now accepts a name that is specified in the ID column in a discrete
attribute map data set. This feature enables you to create a discrete attribute map
variable for a discrete attribute map that is defined in a SAS data set. To resolve
the attribute map name in that case, you must specify the name of the attribute
map data set in the DATTRMAP= option in the SGRENDER statement that
renders the graph. For information about discrete attribute map data sets and the
SGRENDER statement DATTRMAP= option, see SAS ODS Graphics:
Procedures Guide.
• VALUE statement:
• FILLATTRS= now supports the TRANSPARENCY= fill option.
• LINEATTRS= now supports the THICKNESS= line option.
• MARKERATTRS= now supports the SIZE=, TRANSPARENCY=, and
WEIGHT= marker options.

Documentation Enhancements

In the second maintenance release of SAS 9.4, SAS Graph Template Language: User's
Guide is reorganized to make it easier to find information about how to use the Graph
Template Language.
1

Part 1

Fundamentals

Chapter 1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2
3

Chapter 1
Overview

Graph Template Language (GTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


GTL and the Output Delivery System (ODS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
A Quick Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Template Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Run-Time Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Basic Anatomy of an ODS Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Graphical Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Flexible Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Expressions and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Dynamics and Macro Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Conditional Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
ODS GRAPHICS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
ODS Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
About the Examples in This Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Examples and Resources on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Graph Template Language (GTL)

GTL and the Output Delivery System (ODS)


The SAS Graph Template Language (GTL) is an extension to the Output Delivery
System (ODS) that enables you to create sophisticated graphics. For example, using the
GTL, you can generate Model-Fit plots, Distribution Plots, Comparative plots,
Prediction Plots, and more.
The graphics produced by the GTL are generated by template definitions that control the
graph format and appearance and specify the variable roles to represent in the graph
display. The graph can then be rendered by associating the templates with a data source.
4 Chapter 1 • Overview

• The GTL templates are defined with PROC TEMPLATE. The GTL includes
conditional statements that can be used to determine what graph features are
rendered. It also includes layout statements that specify the arrangement of graph
features, plot statements that request specific plot types (such as histograms and
scatter plots), and text and legend statements that specify titles, footnotes, legends,
and other text-based graph elements.
• The GTL templates are rendered using the SGRENDER procedure, which specifies a
data source that contains appropriate data values and the template to use for
rendering the graph.
• You can also modify predefined GTL templates that the SAS System delivers for use
on the SAS statistical procedures. For information about modifying existing
templates, refer to SAS/STAT user’s guide.
This manual provides a complete reference to the Graph Template Language. For
detailed usage information, consult the SAS Graph Template Language: User's Guide.
Note: If you are also a SAS/GRAPH user, then you might want to consult the SAS
Graph Template Language: User's Guide to learn about some of the distinctions
between ODS Graphics and SAS/GRAPH.

A Quick Example
The data set Sashelp.Class is delivered with the SAS System. It includes data columns
named Height and Weight, which store height and weight measures for a small sample of
subjects. The Graph Template Language can be used to generate a histogram that shows
the distribution of weight recorded in that data set:

The following SAS program produces the graph:


proc template;
define statgraph histogram;
begingraph;
layout overlay;
Graph Template Language (GTL) 5

histogram weight;
endlayout;
endgraph;
end;
run;

ods graphics / width=450px;


proc sgrender data=sashelp.class
template=histogram;
run;

• The DEFINE STATGRAPH statement on PROC TEMPLATE opens a definition


block for defining a graphics template named HISTOGRAM. The HISTOGRAM
template is stored in the template folder (also called the “template store,” by default
located in Sasuser.Templat).
• The template definition for HISTOGRAM specifies two GTL statements within a
BEGINGRAPH/ENDGRAPH block: LAYOUT OVERLAY and HISTOGRAM.
• The LAYOUT OVERLAY statement is one of the most fundamental layout
statements. It can overlay the results of one or more plot statements, each of which
shares the same plot area, axes, and legends. The layout in this example specifies
only a single element: a HISTOGRAM with bars showing the distribution of
observations of the data column named Weight.
• The ENDLAYOUT statement ends the layout block, the ENDGRAPH statement
ends the graph definition, and the END statement ends the template definition.
• The ODS GRAPHICS statement uses the WIDTH= option to set a width for the
output graph. Because the HEIGHT= option is not specified, GTL manages the
graph’s aspect ratio and set an appropriate height.
• The DATA= option on PROC SGRENDER specifies Sashelp.Class as the data
source for the graph. TEMPLATE= specifies HISTOGRAM as the template
definition to use for rendering the graph.

Template Compilation
A GTL template describes the structure and appearance of a graph to be produced,
similar to how a TABLE template describes the organization and content of a table.
All templates are stored, compiled programs. The following source program produces a
simple GTL template named SCATTER:
proc template;
define statgraph scatter;
begingraph;
layout overlay;
scatterplot x=height y=weight;
endlayout;
endgraph;
end;
run;

When this code is submitted, the statement keywords and options are parsed, just as with
any other procedure. If no syntax error is detected, then an output template named
SCATTER is created and stored in the default template folder Sasuser.Templat. No graph
is produced. Note the following:
6 Chapter 1 • Overview

• Any required arguments in the template must be specified. In this example, X= and
Y= in the SCATTERPLOT statement must specify variables for the analysis, but no
checking for the existence of these variables is done at compile time. (Unlike other
SAS procedures, PROC TEMPLATE does not perform a compile and then run
sequence, which includes variable validation.)
• No reference to an input data set appears in the template.

Run-Time Actions
To produce a graph, a GTL template must be bound to a data source using the
SGRENDER procedure. The following example uses SGRENDER to bind the
SCATTER template to the SAS data set Sashelp.Class, which is delivered with the SAS
system:
proc sgrender data=sashelp.class
template=scatter;
run;

Generally, an ODS data object is constructed by comparing the template references to


column names with columns that exist in the current data set. In the current example,
Sashelp.Class contains columns named Height and Weight. Because these column names
match the columns that are named in template SCATTER, columns Height and Weight
are added to the data object. The other columns in Sashelp.Class are ignored. (It is
possible for a template to define new computed columns based on existing columns.)
After all the observations have been read, the data object and template definition are
passed to a graph renderer, which produces the graph image. The image is then
automatically integrated into the ODS destination. The visual properties of the graph are
determined by the ODS style that is in effect.
Note: Template SCATTER is a restrictive definition: it can create a plot only with
columns named Height and Weight. A GTL template can be made more flexible by
introducing dynamics or macro variables that supply variables and other information
at run time. For more information, see “Flexible Templates” on page 12.
Basic Anatomy of an ODS Graph 7

Basic Anatomy of an ODS Graph


The GTL is flexible and able to produce many different types of graphs with varying
layout features. The following figure shows the basic anatomy of an ODS graph:

Graph
the output produced from all of the statements that are nested in a BEGINGRAPH
statement block. The graph comprises all of the graphics elements in the template
definition.
Title Area
area for one or more titles. This area is always displayed above all cells in the graph.
Footnote Area
area for one or more footnotes. This area is always displayed below all cells in the
graph.
Cell
refers collectively to the area containing the plot areas. In this diagram, there are two
cells, each of which contains two axes for the plot area. A cell can also contain
descriptive text and legends. Graphs are often described as single-cell or multi-cell.
Plot Area
the display area for plot-statement results. This area is bounded by the axes (when
present) and can also contain data labels and other text that annotates the graph.
Axis
refers collectively to the axis line, the major and minor tick marks, the major tick
values, and the axis label.
8 Chapter 1 • Overview

Plots
refers collectively to all plot statements that can be overlaid in the plot area. This
includes graphical items such as fit lines, scatter plots, reference lines, and many
others.
Legend
refers collectively to one or more legend entries, each made up of a graphical value
and a text label. The legend can also have a title and border. Legends can also
display a color ramp corresponding to a continuous response range.

Graphical Layouts
[ˌhaɪəˈr :rkɪkl]:分层
One of most powerful features of the GTL is the syntax built around hierarchical
statement blocks called “layouts.” The outermost layout block determines
• The overall organization of the graph—whether it uses a single-cell or a multi-cell
display.
• What statements are allowed in the block. Generally, layout blocks can contain plots,
lines of text, a legend, or even another layout.
• How the contained statements interact.

Table 1.1 Outermost Layouts in GTL

Layout Description

OVERLAY General purpose layout for displaying 2-D plots in a single-cell.

OVERLAY3D Layout for displaying 3-D plots in a single-cell.

OVERLAYEQUATED Specialized OVERLAY with equated axes.


等同

REGION General purpose layout for displaying single-cell graphs that does
not use axes.

GRIDDED Basic grid of plots. All cells are independent.

LATTICE Advanced multi-cell layout. Axes can be shared across columns


or rows and be external to grid. Many grid labeling and alignment
features.

DATALATTICE Generates a classification panel from the values of 1 or 2


classifiers.

DATAPANEL Generates a classification panel from the values of n classifiers.

GLOBALLEGEND Specialized layout for creating a compound legend that contains


multiple discrete legends.

For example, the following graph is a two-cell graph produced using the LAYOUT
LATTICE statement as the outermost template in the layout.
Graphical Layouts 9

The LAYOUT LATTICE statement is typically used to create a multi-cell layout of plots
that are aligned across columns and rows. In the following template, which produced the
graph, plot statements are specified within nested LAYOUT OVERLAY statements.
Thus, the LATTICE automatically aligns the plot areas and tick display areas in the
plots. The LATTICE layout is a good layout to choose when you want to compare the
results of related plots.
proc template;
define statgraph lattice;
begingraph;
entrytitle "Car Performance Profile";
layout lattice / border=true pad=10 opaque=true
rows=1 columns=2 columngutter=3;
layout overlay;
scatterplot x=horsepower y=mpg_city /
group=origin name="cars";
regressionPlot x=horsepower y=mpg_city / degree=2;
endlayout;

layout overlay;
scatterplot x=weight y=mpg_city / group=origin;
regressionPlot x=weight y=mpg_city / degree=2;
endlayout;

sidebar;
discretelegend "cars";
endsidebar;
endlayout;
endgraph;
end;
run;

For detailed information about each layout, see the chapter for that layout type.
10 Chapter 1 • Overview

Plots
The plots in the GTL are classified in different ways, depending on the context of the
discussion.
Within layout blocks, plots are often classified according to graphical dimension:
whether they are projected in two or three visual dimensions. Thus, plots in the GTL are
often referred to as 2-D or 3-D plots, based on their graphical dimensions, not their data
dimensions.
Relative to their input data, plots are classified according to the statements that calculate
summary statistics from raw input data, and those that use calculated statistics as input
parameters on the plot statement. Thus, many GTL plot statements have two versions:
BARCHART and BARCHARTPARM, HISTOGRAM and HISTOGRAMPARM, and so
on. The main distinction between such plots is the nature of the input data that they
accept:
• The “non-parm” version (for example, BARCHART) computes its values from raw,
unsummarized data. For example, a BARCHART computes the summary values it
needs for the bars in the chart. Such plots are often referred to as “computed plots.”
• The “parm” version (for example, BARCHARTPARM) does not summarize or
compute values from the input data but instead simply renders the input data it is
given. Thus, the input data must be pre-summarized, perhaps by a SAS procedure.
The “parm” version of plots, often referred to as “parameterized plots,” produce the
same result as the non-parm version. However, they do not perform the calculations
or data summarizations needed to achieve the result.
Chapter 5, “Key Concepts for Using Plots,” on page 175 discusses general concepts that
apply across plot types. For detailed information about a particular plot, see the chapter
for that plot.

Axes
The GTL uses various criteria to determine the displayed axis features for a graph.
Generally, axis features are based on the layout type, the order of plot statements in the
layout and the options specified on those statements, the use of “primary” and
“secondary” axes on the plots (when secondary axes are supported), the plot type, the
column(s) of data that contribute to defining the axis range, and the data formats for the
contributing data columns.
Depending on the layout type, 2-D plots can have up to four independent axes that can
be displayed: X, Y, X2, and Y2. The X and Y axes are considered the primary axes, and
the X2 and Y2 axes are considered the secondary axes. By default, the X2 and Y2 axes
are not displayed. When requested, the secondary axes can be displayed as copies of the
primary axes, or data can be mapped separately to them. The following figure identifies
the X, Y, X2, and Y2 axes.
Legends 11

All 3-D plots display the standard X, Y, and Z axes.

For more information about axis features in GTL, see Chapter 7, “Axis Features in
Layouts,” on page 875.

Legends
Many plot statements support a GROUP= option that partitions the data into unique
values, performs separate analysis, if necessary, and automatically assigns distinct visual
properties to each group value. The visual properties of group values are defined by the
style in effect.
Legends are not automatically displayed for plots with group values. Rather, an
appropriate legend statement must be added to the template to generate the desired
legend. In the following example, a legend is added to display markers and line patterns
that show the association between the group values from a scatter plot and corresponding
linear regression lines. The example shows the mechanism that GTL uses to associate a
legend with its corresponding plot(s): a name is assigned to each plot that must be
represented in the legend, and these names are then used as arguments for the legend
statement (in this case, MERGEDLEGEND).
proc template;
define statgraph scatterfit;
begingraph;
12 Chapter 1 • Overview

entrytitle "Linear Regression By Gender";


layout overlay;
scatterplot x=height y=weight / group=sex name="scat";
regressionplot x=height y=weight/ group=sex name="reg";
mergedlegend "scat" "reg" / border=true;
endlayout;
endgraph;
end;
run;

For more information about managing legends in GTL, see SAS Graph Template
Language: User's Guide.

Flexible Templates
特征 限制性的
Several features in the GTL can make template definitions less restrictive on input data
and more general in nature. These features enable a single compiled template to produce
many output variations.
变化

Expressions and Functions


In the GTL, expressions can be used to compute constants and data columns. The
expressions must be enclosed in an EVAL construct. Within the expression, you can use
DATA step functions, arithmetic operators, and other special functions supported by the
GTL. 算术
Expressions are also useful in text statements like ENTRY and ENTRYTITLE. Both of
these statements support rich text and have special text commands such as {SUP},
{SUB}, and {UNICODE}, which enable subscripting, superscripting, and Unicode
characters.
The following template shows how the ± symbol is included in the title line using its
十六进制hexadecimal Unicode value. Also, new data columns are computed for the upper and
lower error bars of the scatter plot, based on the input columns MeanWeight and
STDERR.
proc template;
define statgraph expression;
begingraph;
entrytitle "Errorbars show " {unicode "00B1"x} "2 SE";
Flexible Templates 13

layout overlay;
scatterplot x=age y=meanweight /
yerrorlower=eval(meanweight - 2*stderr)
yerrorupper=eval(meanweight + 2*stderr);
seriesplot x=age y=meanweight;
endlayout;
endgraph;
end;
run;

For more information about using expressions, see Chapter 21, “Expressions,” on page
1317. For more information about using functions, see Chapter 22, “Functions,” on page
1321.

Dynamics and Macro Variables


An extremely useful technique for generalizing templates is to define dynamics, macro
variables, or both. The dynamics and macro variables resolve when the template is
executed. The following PROC TEMPLATE statements can be used in a DEFINE
STATGRAPH block:

Template Statement Purpose Value supplied by...

DYNAMIC defines one or more dynamic either of the following:


variables
• DYNAMIC= suboption of
ODS= option of FILE
PRINT
• DYNAMIC statement of
PROC SGRENDER

MVAR defines one or more macro %LET or CALL SYMPUT( )


variables

NMVAR defines one or more macro %LET or CALL SYMPUT( )


variables that resolve to a
number or numbers

NOTES provides information about user-supplied text


the graph definition

The following example defines a template named DYNAMICS that can create a
histogram and density plot for any variable. It defines both macro variables and
dynamics for run-time substitution. No data-dependent information is hard coded in the
template.
Note: You can initialize macro variables with %LET statements and dynamics with
SGRENDER’s DYNAMIC statement.
proc template;
define statgraph dynamics;
mvar SYSDATE9 SCALE;
nmvar BINS;
dynamic VAR VARLABEL;
begingraph;
entrytitle "Histogram of " VAR;
14 Chapter 1 • Overview

entrytitle "with Normal Distribution";


layout overlay / xaxisopts=(label=VARLABEL);
histogram VAR / scale=SCALE nbins=BINS;
densityplot VAR / normal();
endlayout;
entryfootnote halign=right "Created: " SYSDATE9 /
textattrs=GraphValueText;
endgraph;
end;
run;

%let bins=6;
%let scale=count;
proc sgrender data=sashelp.class
template=dynamics;
dynamic var="Height" varlabel="Height in Inches";
run;

For more information about using dynamics and macro variables, see Chapter 20,
“Dynamics and Macro Variables,” on page 1313.

Conditional Logic
Using conditional logic, you can create templates that have multiple visual results or
output representations, depending on existing conditions. The evaluation of a logical
expression must generate one or more complete statements (not portions of statements).
All conditional logic uses one of the following constructs:

if (condition) if (condition)
statement(s); statement(s);
endif; else
statement(s);
endif;

In the IF statement, condition must be enclosed in parentheses. The condition can be any
standard SAS expression involving arithmetic, logical operators, comparison operators,
Boolean operators, or concatenation operators. The expression can also use SAS DATA
step functions. The expression resolves to a single numeric value, which is true or false.
Output 15

In the following example, a histogram is conditionally overlaid with a normal


distribution curve, a Kernel Density Estimate distribution curve, both, or neither:
proc template;
define statgraph conditional;
dynamic VAR VARLABEL BINS CURVE;
begingraph;
entrytitle "Histogram of " VAR;
layout overlay / xaxisopts=(label=VARLABEL);
histogram VAR / nbins=BINS;

if (upcase(CURVE) in ("ALL" "KERNEL"))


densityplot VAR / kernel() name="k"
legendlabel="Kernel"
lineattrs=(pattern=dash);
endif;

if (upcase(CURVE) in ("ALL" "NORMAL"))


densityplot VAR / normal() name="n"
legendlabel="Normal";
endif;

discretelegend "n" "k";


endlayout;
endgraph;
end;
run;

Note that the legend syntax does not have to be made conditional. At run time, each plot
name in the legend is checked. If the plot does not exist, then its name is removed from
the legend name list. If no names appear in the DISCRETELEGEND statement, then the
legend “drops out” and the histogram size is adjusted to fill the remaining space.
For more information about using conditional logic, see Chapter 23, “Conditional
Logic,” on page 1333.

Output
When using the GTL, you focus primarily on defining template definitions that produce
specific graphs and generate a particular output layout. Ultimately, you must also
customize the graphical environment to get the exact output that you desire. The ODS
GRAPHICS statement is available for customizing the graphical environment, and ODS
styles enable you to manage the output appearance.

ODS GRAPHICS Statement


The ODS GRAPHICS statement is used to modify the environment in which graphics
templates are executed. The ODS GRAPHICS statement is used to control
• whether ODS graphics is enabled
• the type and name of the image created
• the size of the image
• whether features such as scaling and anti-aliasing are used.
16 Chapter 1 • Overview

The following ODS GRAPHICS statement uses the HEIGHT= and WIDTH= options to
set an aspect ratio for the output image.
ods graphics on / height=175px width=200px;
proc sgrender data=sashelp.class
template=scatter;
run;
ods graphics off;

For more information about using the ODS GRAPHICS statement in GTL, see SAS
Graph Template Language: User's Guide. For a more complete discussion of the ODS
GRAPHICS statement, see “ODS GRAPHICS Statement” in SAS ODS Graphics:
Procedures Guide.

ODS Styles
When any graphics template is executed, there is always an ODS style in effect that
governs the appearance of the output. The following ODS statement sends graphics
output to the RTF output destination using the LISTING style:
ods rtf style=listing;

ods graphics on / height=175px width=200px border=off;


proc sgrender data=sashelp.class
template=scatter;
run;
ods graphics off;

ods rtf close;

Support for ODS styles is highly integrated into GTL syntax. By default, the graphical
appearance features of most plot and text statements are mapped to corresponding style
elements and associated attributes. Because of this, your output tables and graphs always
have a reasonable overall appearance. Moreover, output for a given ODS destination has
a consistent look (for example, table colors and graph colors do not clash).
The following figures show how a graph’s appearance can be changed by using
references to style elements to set the graph’s appearance options. This technique
permits changes in graph appearance by style modification instead of graphical template
modification. The graphs in the figures are generated with the following GTL statement:
contourplotparm x=x y=y z=density /
contourtype=fill nhint=9
colormodel=ThreeColorRamp ;

The following style template shows the definition for the ThreeColorRamp style
element:
style ThreeColorRamp /
endcolor = GraphColors("gramp3cend")
neutralcolor = GraphColors("gramp3cneutral")
startcolor = GraphColors("gramp3cstart");
About the Examples in This Documentation 17

For more information about the use of ODS styles in GTL, see SAS Graph Template
Language: User's Guide. For a more complete discussion of ODS styles, see SAS Output
Delivery System: User's Guide.

About the Examples in This Documentation


The example programs that are shown in this document often provide all of the code that
you need to generate the graphs that are shown in the figures. We encourage you to copy
and paste the example code into your SAS session and generate the graphs for yourself.
The examples are written to be runnable in the SAS windowing environment and in SAS
Studio. Unless otherwise noted, the examples use the default ODS destination. In the
SAS windowing environment, the default ODS destination is ODS HTML. For
information about the default ODS output in SAS Studio, see “SAS Studio and ODS” in
SAS Output Delivery System: User's Guide. For information about using SAS Studio, see
SAS Studio: User's Guide.
If you generate the example graphs using an HTML destination, they are typically
rendered as 640 pixel by 480 pixel images using the HTMLBlue style. Because of size
limitations, the graphs in this document are not shown in their default size. They are
scaled down to meet the size requirements of our documentation production system.
When graphs that are produced with ODS graphics are reduced in size, several automatic
processes take place to optimize the appearance of the output. Among the differences
between default size graphs and smaller graphs are that the smaller graphs have scaled
18 Chapter 1 • Overview

down font sizes. Also, their numeric axes might display a reduced number of ticks and
tick values. Thus, the graphs that you generate from the example programs will not
always look identical to the graphs that are shown in the figures. However, both graphs
will accurately represent the data.
When you produce your own graphical output, you can change the graph size and
attributes, if needed. The SAS Graph Template Language: User's Guide explains how to
set fonts, DPI, anti-aliasing, and other features that contribute to producing professional-
looking graphics of any size in any output format.

Examples and Resources on the Web


The SAS website contains a large number of examples that can help you visualize and
code your graphs. The examples cover a range of SAS technologies including the ODS
Graphics procedures.
• Graphically Speaking is a blog by Sanjay Matange focused on using ODS Graphics
for data visualization in SAS. The blog covers topics related to the ODS Graphics
procedures, the SAS Graph Template Language, and the SAS ODS Graphics
Designer.
http://blogs.sas.com/content/graphicallyspeaking/
• The Graphics Samples Output Gallery is a collection of graphs organized by SAS
procedure. The graphs link to the source code in SAS Samples & Notes. The gallery
is maintained by SAS Technical Support.
http://support.sas.com/sassamples/graphgallery/index.html
• The Focus Area Graphics site provides a simple interface to business and analytical
graphs. The site is maintained by the SAS Data Visualization team.
http://support.sas.com/rnd/datavisualization/index.htm
• Samples & SAS Notes contains an abundance of searchable examples. You can
browse by topic, search for a particular note, search for a particular technology such
as SGPLOT, and conduct other searches.
http://support.sas.com/notes/index.html
In addition, you can share your questions, suggestions, and experiences related to
graphics on the SAS/GRAPH and ODS Graphics community site. See https://
communities.sas.com/community/support-communities/sas_graph_and_ods_graphics.
19

Part 2

Graph Block

Chapter 2
BEGINGRAPH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
20
21

Chapter 2
BEGINGRAPH Statement

Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
BEGINGRAPH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Dictionary

BEGINGRAPH Statement
Defines the outermost container for a graph template that is defined with GTL-statements.
Requirements: All STATGRAPH template definitions must start with a BEGINGRAPH statement and
end with an ENDGRAPH statement.
The BEGINGRAPH block must contain one and only one layout block.
The layout block and its nested layouts, if any, must contain at least one plot.

Syntax
BEGINGRAPH </option(s)>;
<GTL-global-statements>
GTL-layout-block
<GTL-global-statements>
ENDGRAPH;

Summary of Optional Arguments

Appearance options
ATTRPRIORITY=AUTO | COLOR | NONE
specifies a priority for cycling the group attributes.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the graph background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the graph.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the graph.
DATACOLORS=(color-list)
22 Chapter 2 • BEGINGRAPH Statement

specifies the list of fill colors that will replace the graph data colors from the
GraphData1–GraphDataN style elements.
DATACONTRASTCOLORS=(color-list)
specifies the list of contrast colors that will replace the graph data contrast
colors from the GraphData1–GraphDataN style elements.
DATALINEPATTERNS=(line-pattern-list)
specifies the list of line patterns that will replace the graph data line patterns
from the GraphData1–GraphDataN style elements.
DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN
enhances the visual appearance of all plots in the template that support data
skins.
DATASYMBOLS=(marker-symbol-list)
specifies the list of marker symbols that will replace the graph data marker
symbols from the marker symbols that are defined in the GraphData1–
GraphDataN style elements.
DESIGNHEIGHT=DEFAULTDESIGNHEIGHT | dimension
specifies the design height of the graph.
DESIGNWIDTH=DEFAULTDESIGNWIDTH | dimension
specifies the design width of the graph.
DRAWSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT |
LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT |
DATAPIXEL | DATAVALUE
specifies a global drawing space and drawing units for all of the draw
statements within this BEGINGRAPH block.
OPAQUE=TRUE | FALSE
specifies whether the graph background is opaque or transparent. 不透明或透明
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the graph border.
SUBPIXEL=AUTO | OFF | ON
specifies whether subpixel rendering is used for drawing smooth curved lines
or for spacing bars more precisely.

Axis options
AXISBREAKSYMBOL=BRACKET | NOTCH | SLANTEDLEFT |
SLANTEDRIGHT | SQUIGGLE | SPARK | Z
specifies a symbol to use on the axis lines to indicate a break in the axis.
AXISBREAKTYPE=FULL | AXIS
specifies whether the axis break is indicated in the full display or only on the
axis line.
AXISLINEEXTENT=FULL | DATA | number
specifies the extent of the axis line for all axes.
DISCRETEAXISOFFSETPAD=TRUE | FALSE
specifies whether additional padding is added to the minimum and maximum
axis offsets for discrete axes.

Label options
LABELPLACEMENT=AUTO | GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in the
graphs.
SAPLACEMENTOPTS=(placement-options)
specifies the options for the label-placement algorithm when
LABELPLACEMENT=SA.
BEGINGRAPH Statement 23

Midpoint options
INCLUDEMISSINGDISCRETE=TRUE | FALSE
specifies whether missing values are displayed on a discrete axis.

Optional Arguments
ATTRPRIORITY=AUTO | COLOR | NONE
specifies a priority for cycling the group attributes.
AUTO
honors the current state of the attribute priority rotation pattern as specified in the
active style or in the ODS GRAPHICS statement.
COLOR
changes the current setting of attribute priority rotation pattern to the color-
priority pattern by cycling through the list of colors while holding the marker
symbol, line pattern, or fill pattern constant. When all of the colors are exhausted,
the marker symbol, line style, or fill pattern attribute increment to the next
element, and then the colors in the list are repeated. This pattern repeats as
needed.
NONE
changes the current setting of attribute priority rotation pattern to the default
pattern, which cycles progressively through the attribute lists.

Default The attribute priority pattern that is specified in the active style or in
the ODS GRAPHICS statement.

Interactions This option overrides the attribute priority rotation pattern that is
specified in the current style and the ATTRPRIORITY= option in the
ODS GRAPHICS statement.

The default lists of data colors, contrast colors, marker symbols, and
line patterns are set in the active style’s GraphData1–GraphDataN
elements.

The individual attributes in these lists can be overridden with the


BEGINGRAPH options DATACOLORS=,
DATACONTRASTCOLORS=, DATALINEPATTERNS=, and
DATASYMBOLS=.

The ATTRPRIORITY= option affects the cycling of the style


attributes for GROUP=, CYCLEATTRS=TRUE, and explicit style
references such as MARKERATTRS=GraphData2.

See “Attribute Rotation Patterns” in SAS Graph Template Language:


User's Guide

AXISBREAKSYMBOL=BRACKET | NOTCH | SLANTEDLEFT |


SLANTEDRIGHT | SQUIGGLE | SPARK | Z
specifies a symbol to use on the axis lines to indicate a break in the axis.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
24 Chapter 2 • BEGINGRAPH Statement

The following figure shows an example of each symbol on a horizontal linear axis for
ranges 1–4 and 6–10.

Default SQUIGGLE

Restriction This option applies to linear and time axes only.

Requirements The AXISBREAKTYPE= option must be set to AXIS for this


option to have any effect.

You must use the INCLUDERANGES= option to specify ranges for


the axis for this option to have any effect.

The DISPLAY= option for the axis must include the axis line for
this option to have any effect.

AXISBREAKTYPE=FULL | AXIS
specifies whether the axis break is indicated in the full display or only on the axis
line.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
The following figure shows an example of each type for ranges 50–52 and 56–73 on a
linear horizontal axis.
Figure 2.1 Axis Break Types FULL and AXIS

Default FULL

Requirements You must use the INCLUDERANGES= axis option to specify


ranges for the axis for this option to have any effect.

The axis line or the plot wall outline must be displayed for AXIS to
have any effect. Otherwise, FULL is used.

Interaction When AXIS is specified, if the secondary axis line or the plot wall
outline is displayed, then the axis break symbol is displayed on both
the primary and the secondary axis. Otherwise, the break symbol is
BEGINGRAPH Statement 25

displayed only on the primary axis, as shown in Figure 2.1 on page


24.

Notes The axis break indicators pass through inner margin areas.

No attempt is made to avoid collisions between the axis break


indicators and other graphical elements.

Tip When you use AXIS, use the AXISBREAKSYMBOL= option to


change the break symbol.

AXISLINEEXTENT=FULL | DATA | number


specifies the extent of the axis line for all axes.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
FULL
specifies axis lines that extend along the entire length of the axis.
DATA
specifies axis lines that extend through the data range from the minimum offset
to the maximum offset.
number
specifies, as a decimal proportion, how much the axis line extends from DATA
toward FULL. A value of 0 is equivalent to DATA, and a value of 1 is equivalent
to FULL.

Range 0–1

Tip A numeric value is useful for bar charts when DATA terminates the axis
line at the midpoint positions of the minimum and maximum bars. In
that case, you can specify a numeric value to lengthen the axis line so
that it extends to the full width of both bars.

The following figure shows a simple example of each value for the X and Y axis lines.
The light-blue dashed lines depict the minimum and maximum offsets that are set on the
axes.

Default FULL

Restriction This option is valid only in OVERLAY and OVERLAYEQUATED


layouts.

Tips The graph wall outline might appear to be an axis line. In that case, use
the WALLDISPLAY=NONE or WALLDISPLAY=(FILL) option in the
layout statement to suppress the wall outline.
26 Chapter 2 • BEGINGRAPH Statement

Use the LINEEXTENT= axis option to control the axis line extent on a
per-axis basis.

BACKGROUNDCOLOR=style-reference | color
specifies the color of the graph background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction This option has no effect when OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the graph.

Default The ODS GRAPHICS statement BORDER= option setting, which is


TRUE by default.

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the graph.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element .

“Line Options” on page 1349 for available line-options.

DATACOLORS=(color-list)
specifies the list of fill colors that will replace the graph data colors from the
GraphData1–GraphDataN style elements.
(color-list)
a space-separated list of colors, enclosed in parentheses. You can use a style
attribute reference such as GraphData3:color, a color name, or an RGB, CMYK,
HLS, or HSV (HSB) color code to specify a color. The list can contain a mix of
style attribute references, color names, and color codes.

Requirement The list of colors must be enclosed in parentheses.

Example datacolors=(CXFF0000 green blue)

When this option is specified, the fill colors rotate through this color list rather than
through the colors that are defined in the GraphData1–GraphDataN style elements.
For information about the attribute rotation patterns, see “Attribute Rotation
Patterns” in SAS Graph Template Language: User's Guide.

Default The colors that are defined in the GraphData1–GraphDataN style


elements.
BEGINGRAPH Statement 27

Interaction Where applicable, the COLOR= suboption of the FILLATTRS= option


overrides the DATACOLORS= option.

DATACONTRASTCOLORS=(color-list)
specifies the list of contrast colors that will replace the graph data contrast colors
from the GraphData1–GraphDataN style elements.
(color-list)
a space-separated list of contrast colors, enclosed in parentheses. You can use a
style attribute reference such as GraphData3:color, a color name, or an RGB,
CMYK, HLS, or HSV (HSB) color code to specify a color. The list can contain a
mix of style attribute references, color names, and color codes.

Requirement The list of colors must be enclosed in parentheses.

Example datacontrastcolors=(orange cyan #FF0000)

When this option is specified, the contrast colors cycle through this color list rather
than through the contrast colors that are defined in the GraphData1–GraphDataN
style elements. For information about the attribute rotation patterns, see “Attribute
Rotation Patterns” in SAS Graph Template Language: User's Guide.

Default The contrast colors that are defined in the GraphData1–GraphDataN


style elements.

Interaction Where applicable, the COLOR= suboption of the MARKERATTRS=


option or the LINEATTRS= option overrides the
DATACONTRASTCOLORS= option.

DATALINEPATTERNS=(line-pattern-list)
specifies the list of line patterns that will replace the graph data line patterns from the
GraphData1–GraphDataN style elements.
(line-pattern-list)
a space-separated list of line patterns, enclosed in parentheses. You can use a
style attribute reference such as GraphData3:lineStyle, a line pattern number, or a
line pattern name (where applicable) to specify a pattern. The list can contain a
mix of style attribute references, line pattern numbers, and line pattern names.

Requirement The list of line patterns must be enclosed in parentheses.

When this option is specified, the line patterns cycle through this line-pattern list
rather than through the line patterns that are defined in the GraphData1–GraphDataN
style elements. When the patterns in line-pattern-list are exhausted, the patterns
repeat.

Default The line patterns that are defined in the GraphData1–GraphDataN style
elements.

Interaction Where applicable, the PATTERN= suboption of the LINEATTRS=


option overrides the DATALINEPATTERNS= option.

Example datalinepatterns=(solid dash 16 26)

DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN


enhances the visual appearance of all plots in the template that support data skins.
The following plot statements support data skins:
28 Chapter 2 • BEGINGRAPH Statement

BARCHART HISTOGRAM SCATTERPLOT


BARCHARTPARM HISTOGRAMPARM SCATTERPLOTMATRIX
BOXPLOT LINECHART SERIESPLOT
BOXPLOTPARM NEEDLEPLOT STEPPLOT
BUBBLEPLOT PIECHART VECTORPLOT
DROPLINE POLYGONPLOT WATERFALLCHART
HIGHLOWPLOT REFERENCELINE

Default The GraphSkins:DataSkin style attribute, if it is specified in the current


style. If the current style does not specify the GraphSkins:DataSkin
style attribute, then the default is NONE.

Restriction Starting with the first maintenance release of SAS 9.4, the maximum
number of skinned graphical elements is limited to 200 per plot in an
overlay or prototype layout. When this limit is exceeded for a plot, the
specified data skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.

Interaction This option is overridden by the DATASKIN= option in the individual


plot statements.

Note Applying data skins to a graph that has a very large number of markers
can negatively impact performance.

DATASYMBOLS=(marker-symbol-list)
specifies the list of marker symbols that will replace the graph data marker symbols
from the marker symbols that are defined in the GraphData1–GraphDataN style
elements.
(marker-symbol-list)
a space-separated list of marker symbols, enclosed in parentheses. You can use a
style attribute reference such as GraphData5:markerSymbol or a marker symbol
name to specify a marker. The list can contain a mix of style attribute references
and marker symbol names.

Requirement The list of marker symbols must be enclosed in parentheses.

When this option is specified, the marker symbols cycle through this marker symbol
list rather than through the line patterns that are defined in the GraphData1–
GraphDataN style elements. When the symbols in marker-symbol-list are exhausted,
the symbols repeat.

Default The marker symbols that are defined in the GraphData1–GraphDataN


style elements.

Interaction Where applicable, the SYMBOL= suboption of the MARKERATTRS=


option overrides the DATASYMBOLS= option.

Example datasymbols=(circle square triangle star)

DESIGNHEIGHT=DEFAULTDESIGNHEIGHT | dimension
specifies the design height of the graph.
BEGINGRAPH Statement 29

Default DEFAULTDESIGNHEIGHT. This value is obtained from the SAS


Registry key ODS ð ODS Graphics ð Design Height when the
graph is rendered. The initial value of this registry key is 480px.

Restriction The minimum dimension value that you can set is 2 pixels. If a smaller
setting is specified, then the default design height is used.

Interactions The design height can be overridden at run time with a render height
that is specified with the HEIGHT= option in the ODS GRAPHICS
statement (external to the template). Also, the ODS destination
statement’s IMAGE_DPI= option can affect the height.

You can change the value of the Design Height registry key in the
SAS registry. However, doing so affects the design height of all
templates that do not include an explicit dimension for the design
height. You can also change the height setting in the graph style, but
doing so affects the height of all templates that use that style.

See “dimension” on page 1340

DESIGNWIDTH=DEFAULTDESIGNWIDTH | dimension
specifies the design width of the graph.

Default DEFAULTDESIGNWIDTH. This value is obtained from the SAS


Registry key ODS ð ODS Graphics ð Design Width when the
graph is rendered. The initial value of this registry key is 640px.

Restriction The minimum dimension value that you can set is 2 pixels. If a smaller
setting is specified, then the default design width is used.

Interactions The design width can be overridden at run time with a render width
that is specified with the WIDTH= option in the ODS GRAPHICS
statement (external to the template). Also, the ODS destination
statement’s IMAGE_DPI= option can affect the width.

You can change the value of the Design Width registry key in the SAS
registry. However, doing so affects the design width of all templates
that do not include an explicit dimension for the design width. You can
also change the width setting in the graph style, but doing so affects
the width of all templates that use that style.

See “dimension” on page 1340

DISCRETEAXISOFFSETPAD=TRUE | FALSE
specifies whether additional padding is added to the minimum and maximum axis
offsets for discrete axes. When set to TRUE, an additional 5 pixels of padding is
added to the minimum and maximum axis offsets.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.

Default TRUE

Restriction This option applies only to discrete axes.

Tip This option is useful for heat maps when you want the heat map to
occupy the entire plot area. In that case, in addition to setting this
30 Chapter 2 • BEGINGRAPH Statement

option to FALSE, set OFFSETMIN= and OFFSETMAX= to 0 for the


discrete axes.

DRAWSPACE= GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT |


LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT |
DATAPIXEL | DATAVALUE
specifies a global drawing space and drawing units for all of the draw statements
within this BEGINGRAPH block.

Default LAYOUTPERCENT

Tip Individual draw statements within this BEGINGRAPH block can override
this global setting.

See “About the Drawing Space and Drawing Units” on page 1192

INCLUDEMISSINGDISCRETE=TRUE | FALSE
specifies whether missing values are displayed on a discrete axis.

Default FALSE

Interaction This option affects all charts and plots within the template.

See “boolean ” on page 1339 for other Boolean values that you can use.

LABELPLACEMENT=AUTO | GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in the graphs.
The following labels are affected:
• data labels for needle plots, scatter plots, series plots, step plots, and vector plots
• vertex labels for line charts
• curve labels when the curve label is positioned at the start or end of the curve
AUTO
always selects GREEDY.
GREEDY
specifies the Greedy method for managing label collision. The Greedy method
tries different placement combinations in order to find an optimal approximation
that avoids collisions. Label placement using this method is often less optimal
than label placement using the Simulated Annealing (SA) method. However,
depending on the number of data points and the potential for label collisions, the
Greedy process can be significantly faster.
SA
specifies the Simulated Annealing method for managing label collision. The SA
method attempts to determine the global minimization-of-cost function, which is
based on a simulated annealing algorithm. The resulting label placement is
usually better than placement using the Greedy method. However, depending on
the number of data points and the potential for label collisions, the SA method
can be significantly slower.

Restriction For BANDPLOT and LINECHART, the SA method has no effect


on the curve labels when the CURVELABELPOSITION= option
specifies START or END.
BEGINGRAPH Statement 31

Default The value specified by the ODS GRAPHICS statement


LABELPLACEMENT= option, which is AUTO by default.

Restriction The data label placement algorithm is not aware of bar labels, curve
labels, box plot outlier labels, and marker characters. Collisions
between these elements and data labels might occur regardless of the
LABELPLACEMENT= setting.

Interactions This option overrides the ODS GRAPHICS statement


LABELPLACEMENT= option.

This option affects a plot’s labels only when


DATALABELPOSITION=AUTO is in effect for that plot.

The data label font size might be reduced in order to avoid


overlapping labels and markers. Starting with the third maintenance
release of SAS 9.4, when a broken axis is used, the data-label font size
is not scaled during label placement.

OPAQUE=TRUE | FALSE
specifies whether the graph background is opaque or transparent.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
When this option is set to FALSE, the graph background is transparent.

Default TRUE

Restriction A transparent background is supported only by the PNG, EMF, PDF,


and SVG output formats. The PS output format supports a transparent
background when the graph is rendered as a PNG image. It does not
support a transparent background when the graph is rendered as vector-
graphics output.

Interaction When this option is set to FALSE, the BACKGROUNDCOLOR=


option has no effect.

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the graph border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space added to the left


side.
RIGHT=dimension specifies the amount of extra space added to the
right side.
TOP=dimension specifies the amount of extra space added to the
top.
BOTTOM=dimension specifies the amount of extra space added to the
bottom.
32 Chapter 2 • BEGINGRAPH Statement

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default Padding for all sides is 10 pixels.

Note The default units for dimension are pixels.

See “dimension” on page 1340

SAPLACEMENTOPTS=(placement-options)
specifies the options for the label-placement algorithm when
LABELPLACEMENT=SA. Placement options can be any of the following:
MAXITERATIONS=positive-integer
specifies the maximum number of iterations for the SA label-placement
algorithm.

Default 100

WEIGHTS=(keyword-number-list)
specifies the relative weight to give to a particular cost when determining the best
label position. The keyword number list is a space-separated list of keyword =
number pairs.
The following keywords can be used:

LABEL assigns a weight to the overlapping of labels


MARKER assigns a weight to the overlapping of markers and
labels
OUTOFBOUND assigns a weight to labels that are out-of-bounds or
clipped
PRIORITY assigns a weight to the priority of each potential label
position
OBSTACLE assigns a weight to the overlapping of labels with drop
lines, needles, reference lines, series lines, step lines,
and vector lines
The higher the number, the more weight is assigned to the specified cost. For
example, if MARKER is given more weight than OBSTACLE, avoiding marker
collisions is given a higher priority than avoiding line collisions.

Default A weight of 1.0 is assigned to each keyword

Example saplacementopts=(maxiterations=100
weights=(LABEL=2.0 OBSTACLE=10.0))

SEED=positive-integer
specifies a random number seed for the Simulated Annealing algorithm.

Default 1234567

Range 0–2147483646 (2 31–1), where 0 specifies the current Java time as the
seed value
BEGINGRAPH Statement 33

Restriction This option applies only when LABELPLACEMENT=SA.

SUBPIXEL=AUTO | OFF | ON
specifies whether subpixel rendering is used for drawing smooth curved lines or for
spacing bars more precisely.
Note: Starting with the third maintenance release of SAS 9.4, this option controls
subpixel rendering only for image output. For vector-graphics output, subpixel
rendering is always enabled.
AUTO
the system determines whether to use subpixel rendering. In the second
maintenance release of SAS 9.4 and in earlier releases, the system uses the
default rendering for the rendering technology. Starting with the third
maintenance release of SAS 9.4, for image output, if the SUBPIXEL= option is
explicitly set in an ODS GRAPHICS statement, the system honors its setting.
Otherwise, the system determines whether to use subpixel rendering based on the
following criteria:
• If a SCATTERPLOT or SCATTERPLOTMATRIX statement is used,
subpixel rendering is OFF for the graph.
• If neither a SCATTERPLOT nor a SCATTERPLOTMATRIX statement is
used, subpixel rendering is turned ON for the graph if one or more of the
following statements is also used:

BANDPLOT DENSITYPLOT LOESSPLOT


BARCHART HEATMAP PARETOLINE
BARCHARTPARM HEATMAPPARM PBSPLINEPLOT
BOXPLOT HIGHLOWPLOT POLYGONPLOT
BOXPLOTPARM HISTOGRAM REGRESSIONPLOT
BUBBLEPLOT HISTOGRAMPARM SERIESPLOT
CONTOURPLOTPARM LINECHART WATERFALLCHART
• For all other cases, subpixel rendering is turned OFF.
OFF
never uses subpixel rendering.

Note OFF is valid starting with the third maintenance release of SAS 9.4.

ON
always uses subpixel rendering, when applicable, for image output when
rendering graphs.

Default AUTO

Restrictions In the second maintenance release of SAS 9.4 and in earlier releases,
subpixel rendering can be used only for the following statements:
BANDPLOT, BARCHART, BARCHARTPARM, DENSITYPLOT,
LINECHART, LOESSPLOT, PBSPLINEPLOT,
REGRESSIONPLOT, and SERIESPLOT. Starting with the third
maintenance release of SAS 9.4, subpixel rendering can be used for
all plots and charts.

Starting with the third maintenance release of SAS 9.4, this option is
ignored for vector-graphics output.
34 Chapter 2 • BEGINGRAPH Statement

Requirement Anti-aliasing must be enabled for this option to have any effect.

Interaction Starting with the third maintenance release of SAS 9.4, this option
overrides the SUBPIXEL= option in the ODS GRAPHICS statement.

Tips If anti-aliasing is disabled, use the ANTIALIAS=ON option in the


ODS GRAPHICS statement to enable it.

Anti-aliasing is disabled automatically when the resources required


for anti-aliasing exceed a preset threshold. When anti-aliasing is
disabled for all or part of a graph, subpixel rendering is disabled for
the entire graph. A note is written to the SAS log that provides
information about how to use the ANTIALIASMAX= option in an
ODS GRAPHICS statement to re-enable anti-aliasing.

See “Using Subpixel Rendering” in SAS Graph Template Language:


User's Guide

“ODS GRAPHICS Statement” in SAS ODS Graphics: Procedures


Guide for information about the ANTIALIAS= and
ANTIALIASMAX= options.

Details

About the BEGINGRAPH Statement


All template definitions in the Graphics Template Language must start with a
BEGINGRAPH statement and end with an ENDGRAPH statement. Within a
BEGINGRAPH block, one and only one GTL layout block is required. It can be a
LATTICE, GRIDDED, OVERLAY, OVERLAYEQUATED, OVERLAY3D, REGION,
DATALATTICE, or DATAPANEL layout block. This layout block and its nested
layouts, if any, must contain at least one plot statement. It can contain other nested
layout blocks.
The GTL global statements apply to the entire template and can include ENTRYTITLE
and ENTRYFOOTNOTE statements, attribute maps, draw statements, conditional
statements, and so on. Any of these global statements can precede or follow the GTL
layout block.

Changing the Size of Your Graph


By default, graphs are rendered at 640px by 480px (4:3 aspect ratio). To change the
output size for a single graph, use the DESIGNWIDTH= and DESIGNHEIGHT=
options in the BEGINGRAPH statement for that graph. For example, the template in the
“Example Program” on page 36 uses DESIGNHEIGHT= to change the graph height to
320px. To prevent the graph width from automatically scaling to preserve the 4:3 aspect
ratio, it uses DESIGNWIDTH= to maintain the 640px width. In this instance, the setting
renders each graph cell as a 320px by 320px square. (The cells are square in this case,
but the resulting cell size depends on the graph definition and would not be the same for
all graphs.)
Note: To change the graph sizes for all templates in the current SAS session, you can
use the WIDTH= and HEIGHT= options in the ODS GRAPHICS statement. Size
settings in the ODS GRAPHICS statement override size settings in the
BEGINGRAPH statement and remain in effect unless they are changed in another
ODS GRAPHICS statement. You can also use WIDTH= and HEIGHT= settings in
the graph style to modify the graphs sizes across template definitions. Be aware,
BEGINGRAPH Statement 35

however, that if you explicitly manage the graph output size, then the graph elements
might be scaled so that the size specification is honored.
The following template defines a square graph (equal height and width, 1:1 aspect ratio)
by setting the design width equal to the internal default height (480px). The setting is
made with DESIGNWIDTH=DEFAULTDESIGNHEIGHT:
Note: A “square graph” means that the output graph’s width and height are equal. That
does not imply that the X and Y axis lengths are equal if the graph contains only one
cell.
proc template;
define statgraph squareplot;
dynamic title xvar yvar;
begingraph / designwidth=defaultDesignHeight;
entrytitle title;
layout overlayequated / equatetype=square;
scatterplot x=xvar y=yvar;
regressionplot x=xvar y=yvar;
endlayout;
endgraph;
end;
run;

If this template is executed with the following GRENDER procedure statement, then a
480px by 480px graph is created:

proc sgrender data=mydata template="squareplot" ;


dynamic title="Square Plot" xvar="time1" yvar="time2";
run;

If the ODS GRAPHICS statement’s WIDTH= or HEIGHT= options change the render
width or render height, then the squareplot template’s 1:1 aspect ratio would still be
honored. Thus, both of the following GRENDER procedure statements would create a
550px by 550px graph:
ods graphics / width=550px;
proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;

ods graphics / height=550px;


proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;
36 Chapter 2 • BEGINGRAPH Statement

Example: BEGINGRAPH Statement

The following graph was generated by the “Example Program” on page 36:

Example Program
The BEGINGRAPH statement block is a required outermost container for any graph
template. One of its purposes is to support options that apply to the entire graph. For
example, the default graph size that a template produces is typically 640x480 pixels. If
you need a different size, then you can declare the alternative size on this statement. To
do so, use the DESIGNWIDTH= option, or the DESIGNHEIGHT= option, or both. This
program shows one way to set the width and height of two graph cells to be equal.
proc template;
define statgraph begingraph;
dynamic XVAR YVAR;
begingraph / designwidth=640px designheight=320px;
layout lattice / columns=2;
layout overlayequated / equatetype=square;
entry "Linear Regression Fit" /
valign=top texttattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=0.5;
regressionplot x=XVAR y=YVAR;
endlayout;
layout overlayequated / equatetype=square;
entry "Loess Fit" /
valign=top texttattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=0.5;
loessplot x=XVAR y=YVAR;
endlayout;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.iris template=begingraph;


Example: BEGINGRAPH Statement 37

dynamic title="Square Plot"


xvar="SepalLength" yvar="SepalWidth";
run;
38 Chapter 2 • BEGINGRAPH Statement
39

Part 3

Layout Statements

Chapter 3
Summary of Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Chapter 4
Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
40
41

Chapter 3
Summary of Layout Statements

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Single-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Multi-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Data-driven Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Legend Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Overview
Layout blocks always begin with the LAYOUT keyword followed by a keyword
indicating the purpose of the layout. All layout blocks end with an ENDLAYOUT
statement.
The following sections summarize the available layouts. To learn more about a layout,
see the chapter devoted to that layout.
42 Chapter 3 • Summary of Layout Statements

Single-cell Layouts

Graphics Allowed
Layout and Cells
(Description) Produced Comments Example

OVERLAY (Single 2-D (1 cell) General purpose


Cell) layout for
superimposing 2-D
plots

OVERLAYEQUATE 2-D (1 cell) Specialized


D (Single Cell) OVERLAY with
equated axes

PROTOTYPE 2-D (1 cell) Specialized


(Single Cell) LAYOUT used only
as child layout of
DATAPANEL or
DATALATTICE

REGION (Single 2-D (1 cell) General purpose


Cell) layout for displaying
a single-cell plot that
does not use axes

OVERLAY3D 3-D (1 cell) General purpose 3-D


(Single Cell) layout for
superimposing 3-D
plots.
Data-driven Layouts 43

Multi-cell Layouts

Graphics Allowed
Layout and Cells
(Description) Produced Comments Example

LATTICE (Advanced 2-D (1 or more cells) All cells must be


Multi-cell) predefined. Axes can
be shared across
columns or rows and
be external to grid.
Many grid labeling
and alignment
features.

GRIDDED (Simple 2-D (1 or more cells) All cells must be


Multi-cell) predefined. Axes
independent for each
cell. Very simple
multi-cell container.

Data-driven Layouts

Graphics Allowed
Layout and Cells
(Description) Produced Comments Example

DATAPANEL 2-D (1 or more cells) Displays a panel of


(Classification Panel) similar graphs based
on data subsets by
classification
variable(s). Number
of cells is based on
crossings of n
classification
variable(s).

DATALATTICE 2-D (1 or more cells) Displays a panel of


(Classification Panel) similar graphs based
on data subsets by
classification
variable(s). Number
of cells is based on
crossings of 1 or 2
classification
variables.
44 Chapter 3 • Summary of Layout Statements

Legend Layout

Layout Cells Produced Comments

GLOBALLEGEND 1 cell for a legend Specialized layout for creating a compound


legend that contains multiple discrete legends.
45

Chapter 4
Layout Statements

Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
LAYOUT DATALATTICE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
LAYOUT DATAPANEL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
LAYOUT GLOBALLEGEND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
LAYOUT GRIDDED Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
LAYOUT LATTICE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
LAYOUT OVERLAY Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
LAYOUT OVERLAYEQUATED Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
LAYOUT OVERLAY3D Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
LAYOUT PROTOTYPE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
LAYOUT REGION Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
INNERMARGIN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

Dictionary

LAYOUT DATALATTICE Statement


Creates a grid of graphs based on one or two classification variables and a graphical prototype. By default,
a separate instance of the prototype (a data cell) is created for each possible combination of the
classification variables.
Restriction: You can specify only one LAYOUT PROTOTYPE block in the LAYOUT
DATALATTICE block. If you specify more than one, then only the last prototype block
specified is honored. The remaining prototype blocks are ignored.
Requirement: You must specify at least one ROWVAR= option or one COLUMNVAR= option. You
can specify both.
46 Chapter 4 • Layout Statements

Syntax
LAYOUT DATALATTICE ROWVAR=class-variable
COLUMNVAR=class-variable </option(s)>;
LAYOUT PROTOTYPE </options>;
GTL-statements;
ENDLAYOUT;
<SIDEBAR </options>;
GTL-statements;
ENDSIDEBAR;>
ENDLAYOUT;
LAYOUT DATALATTICE COLUMNVAR=class-variable </option(s)>;
layout-prototype-block ;
<sidebar-block(s)> ;
ENDLAYOUT;
LAYOUT DATALATTICE ROWVAR=class-variable </option(s)>;
layout-prototype-block ;
<sidebar-block(s)> ;
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid.
CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid.
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
COLUMNHEADERS=TOP | BOTTOM | BOTH
specifies where to position the outside column heading.
HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
HEADERLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the data labels.
HEADERLABELLOCATION=OUTSIDE | INSIDE
indicates whether the cell header is placed within each cell (INSIDE) or as
row and column headers external to the lattice (OUTSIDE).
HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or
transparent (FALSE).
LAYOUT DATALATTICE Statement 47

HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated
list in order to save space.
HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell
header when HEADERPACK=TRUE.
HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before
splitting the text to the next line.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting
levels of the layouts that are used.
SORTORDER=(role-sort-list)
specifies the order of the cells along the columns and rows.

Axis options
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
COLUMN2DATARANGE=AUTO | UNIONALL | UNION
specifies how the X2-axes of instances of the graph-prototype are scaled.
COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.
COLUMNDATARANGE=AUTO | UNIONALL | UNION
specifies how the X-axes of instances of the graph-prototype are scaled.
ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
ROW2DATARANGE=AUTO | UNIONALL | UNION
specifies how the Y2-axes of instances of the graph-prototype are scaled.
ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.
ROWDATARANGE=AUTO | UNIONALL | UNION
specifies how the Y-axes of instances of the graph-prototype are scaled.

Inset options
INSET=(variable-list)
specifies what information is displayed in an inset.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information.

Layout options
COLUMNS=integer
specifies the number of columns in the layout.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
48 Chapter 4 • Layout Statements

HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE


specifies the content of the cell headers.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the ROWVAR and
COLUMNVAR variables that contain a missing value.
PANELNUMBER=positive-integer
specifies the number of the panel to produce.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
ROWHEADERS=RIGHT | LEFT | BOTH
specifies where to position the outside row heading.
ROWS=integer
specifies the number of rows in the layout.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled
grid.
START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid from the top left or bottom left
corner.

Required Arguments
You must specify at least one of the following arguments. You can specify both.
ROWVAR=class-variable
specifies the classification variable for the rows. One row of cells is created for each
unique value of the row class variable.

See ROWS= option and “Managing Rows and Columns” on page 67

COLUMNVAR=class-variable
specifies the classification variable for the columns. One column is created of each
unique value of the column class variable.

See COLUMNS= option and “Managing Rows and Columns” on page 67

Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
LAYOUT DATALATTICE Statement 49

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid. Use this option in conjunction
with the CELLWIDTHMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH= options
in the ODS GRAPHICS statement. As the number of cells in the grid increases, the
size of each cell decreases. At some point the cell becomes so small that a
meaningful graph cannot be rendered. This option sets the minimum height threshold
for all cells. If the actual cell height becomes smaller, then no panel is drawn.

Default 100px

See “dimension” on page 1340

CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid. Use this option in conjunction with
the CELLHEIGHTMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH= options
in the ODS GRAPHICS statement. As the number of cells in the grid increases, the
size of each cell decreases. At some point the cell becomes so small that a
meaningful graph cannot be rendered. This option sets the minimum width threshold
for all cells. If the actual cell width becomes smaller, then no panel is drawn.

Default 100px

See “dimension” on page 1340

COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.

Restriction Axis options must be enclosed in parentheses and separated by spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” for a list of options..

COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
50 Chapter 4 • Layout Statements

Restriction This option is needed only if you use a plot statement that supports a
secondary X2 axis. If you do not use that statement’s XAXIS= option
to map data to the X2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data
Are Mapped to a Designated Axis” on page 876

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” for a list of options.

COLUMNDATARANGE=AUTO | UNIONALL | UNION


specifies how the X-axes of instances of the graph-prototype are scaled.
AUTO
selects the X-axis scale based on the COLUMNWEIGHT= option and the
column axis type, as follows:
• When COLUMNWEIGHT=EQUAL (default), UNIONALL is selected.
• When COLUMNWEIGHT=PROPORTIONAL and the column axis is
discrete, UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the X-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X-axis data ranges separately for each column on a per-panel basis.
The scaling does not span multiple panels.

Default AUTO

Tip Use the COLUMNAXISOPTS= option to control shared axis features.

See The COLUMNWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

COLUMN2DATARANGE=AUTO | UNIONALL | UNION


specifies how the X2-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the X2-axis scale based on the COLUMNWEIGHT= option
and the column axis type, as follows:
• When COLUMNWEIGHT=EQUAL (default), UNIONALL is selected.
• When COLUMNWEIGHT=PROPORTIONAL and the column axis is
discrete, UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the X2-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X2-axis data ranges separately for each column on a per-panel basis.
The scaling does not span multiple panels.
LAYOUT DATALATTICE Statement 51

Default AUTO

Interaction This option is needed only if you use a plot statement that supports a
secondary X2 axis. If you do not use that statement’s XAXIS= option
to map data to the X2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data Are
Mapped to a Designated Axis” on page 876

Tip Use the COLUMN2AXISOPTS= option to control shared axis features.

See The COLUMNWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.

Default 0

Note If there are n columns, then there are n-1 gutters.

See “dimension” on page 1340

COLUMNHEADERS=TOP | BOTTOM | BOTH


specifies where to position the outside column heading.
TOP
specifies that column heading text appears at the top of the layout.
BOTTOM
specifies that column heading text appears at the bottom of the layout.
BOTH
specifies that column heading text alternates between the top and bottom of the
layout column by column.

Default TOP

Interaction HEADERLABELLOCATION= OUTSIDE must be set for this


option to have any effect.

COLUMNS=integer
specifies the number of columns in the layout.

Defaults If this option is not specified, then the number of columns is


dynamically adjusted to equal the number of classifier values for the
COLUMVAR= variable.

If this option is specified, that many columns are created. If the


number of COLUMNVAR classifier values is greater than the
specified number of columns, then no graph is created for some
classifier values. If the number of classifier values is smaller than the
specified number of columns, then extra empty columns are created.

Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows, the
52 Chapter 4 • Layout Statements

cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.

The START= option affects the how the columns are populated.

The PANELNUMBER= option enables you to create multiple smaller


grids that completely partition the classifier values.

COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
EQUAL
all columns have equal width.
PROPORTIONAL
each column has a width that is proportional to the number of discrete midpoint
values that it contains.

Restriction At least one column axis must be discrete in order for


PROPORTIONAL to have any effect. Otherwise, EQUAL is used.

Interactions When COLUMNDATARANGE=UNIONALL, PROPORTIONAL


is ignored and EQUAL is used.

When PROPORTIONAL is in effect,


COLUMNDATARANGE=AUTO is interpreted as UNION.

If all of the following conditions are true, then the discrete axis is
used to proportion the columns: PROPORTIONAL is in effect,
both the X and X2 axes are used, and only one of the two axes is
discrete. If both axes are discrete, then the X axis is used to
proportion the columns.

When PROPORTIONAL is in effect, the OFFSETMIN= and


OFFSETMAX= axis options are ignored in
COLUMNAXISOPTS= and COLUMN2AXISOPTS=. The axis
offsets are always set to one-half of the midpoint spacing
regardless of plot type.

Default EQUAL

HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphHeaderBackground:Color style reference.

Interaction HEADEROPAQUE= TRUE must be in effect for the color to be seen.

HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
LAYOUT DATALATTICE Statement 53

Default TRUE

Tip The border attributes are controlled by the GraphBorderLines style


element.

See “boolean ” for other Boolean values that you can use.

HEADERLABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the color and font attributes of the data labels.

Default The GraphValueText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE


specifies the content of the cell headers.
NAMEVALUE
displays the classification variable name and value as a name=value pair in each
cell header.

Example If the classification variables are Country and Product, then


HEADERLABEL=NAMEVALUE produces cell headers such as the
following:

Country=CANADA
Product=TABLE

VALUE
displays the classification variable value only in each cell header.

Example If the classification variables are Country and Product, then


HEADERLABEL=VALUE produces cell headers such as the
following:

CANADA
TABLE

NONE
suppresses the cell headers.

Default NAMEVALUE

HEADERLABELLOCATION=OUTSIDE | INSIDE
indicates whether the cell header is placed within each cell (INSIDE) or as row and
column headers external to the lattice (OUTSIDE).

Default OUTSIDE

HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or transparent
(FALSE).

Default TRUE
54 Chapter 4 • Layout Statements

Interaction When this option is set to FALSE, the background color for cell headers
is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated list in
order to save space.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.
The following figure shows the effect of HEADERPACK= on the cell headers in one
row of a data lattice. The data lattice contains classification variables Country and Year.

Default FALSE

Note If the length of the cell header text exceeds the available width, then the
text is truncated.

Tip If truncation occurs, then use the HEADERSPLITCOUNT= option to split


the cell header text into multiple lines.

See “boolean ” on page 1339 for other Boolean values that you can use.

HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell header when
HEADERPACK=TRUE.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.

Default A comma followed by a space

Interaction This option is ignored when HEADERPACK=FALSE.

HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before splitting the
text to the next line.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.
LAYOUT DATALATTICE Statement 55

Default The cell header text is not split

Interaction This option is ignored when HEADERPACK=FALSE.

Note If the length of the cell header text exceeds the available width, then the
text is truncated.

Tip Use the HEADERSEPARATOR= option to specify a different


separator.

INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the ROWVAR and
COLUMNVAR variables that contain a missing value.
TRUE
any crossing of the class variables that includes a missing value produces a row
or column of cells in the grid.
FALSE
any crossing of the class variables that includes a missing value does not produce
a row or columns of cells in the grid.
By default, missing class values are included in the classification. When the data
contains missing classification values, cells are created for the missing classes. The
classification headers for the missing values are blank for missing string values or a
dot for missing numeric values. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing values. If you
want to keep the missing values, then you can create a format that specifies more
meaningful headings for the missing classes. For an example, see “Missing Class
Values” in SAS Graph Template Language: User's Guide.
Note: ODS Graphics does not support Unicode values in user-defined formats in the
second maintenance release of SAS 9.4 and in earlier releases. Starting with the
third maintenance release of SAS 9.4, ODS Graphics supports Unicode values in
user-defined formats only if they are preceded by the (*ESC*) escape sequence.
Example: "(*ESC*){unicode beta}". ODS Graphics does not support an
escape character that is defined in an ODS ESCAPECHAR statement in user-
defined formats.

Default TRUE

See “boolean ” on page 1339 for other Boolean values that you can use.

INSET=(variable-list)
specifies what information is displayed in an inset. The variable-list defines one or
more variables whose names and values appear as a small table in the data cells. The
variables can be either numeric or character. Variable names are separated by spaces.

Requirement No predefined information is available for the inset. You must create
the desired inset information as part of your input data. See “Creating
Your Inset Data” on page 68.

Note The variable values are associated with the data cells by data order.
That is, the first observation from all the variables in variable-list are
used in the first data cell, the second observation from all variables in
variable-list are used in the second data cell, and so on. If a value is
missing for an observation, then the corresponding name-value pair is
skipped in the affected data cell.
56 Chapter 4 • Layout Statements

Tip The location and appearance of the inset is controlled by the


INSETOPTS= option.

See “Adding Insets to Your Graph” in SAS Graph Template Language:


User's Guide

INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information. The appearance
options can be any one or more of the following values:
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the inset is automatically aligned within the layout.
NONE
does not automatically align the inset. This inset’s position is set by the
HALIGN= and VALIGN=appearance-options.
AUTO
attempts to center the inset in the area that is farthest from any surrounding
markers. Data cells might have different inset placements.
(location-list)
restricts the inset’s possible locations to those locations in the specified
location-list, and uses the location-list position that least collides with the
data cell’s other graphics features. The location-list is a space-separated list
that can contain any of these locations: TOPLEFT, TOP, TOPRIGHT, LEFT,
CENTER, RIGHT, BOTTOMLEFT, BOTTOM, and BOTTOMRIGHT.

Example AUTOALIGN=(TOPRIGHT TOPLEFT)

Default NONE

Interaction When AUTOALIGN=AUTO or (location-list), the HALIGN= and


VALIGN= options are ignored.

BACKGROUNDCOLOR=style-reference | color
specifies the color of the inset background.
style-reference
specifies a style reference in the form style-element : style-attribute. Only the
COLOR and CONTRASTCOLOR style attributes are valid.

Default The background is transparent. No color is assigned.

BORDER=TRUE | FALSE
specifies whether a border is displayed around the inset.

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

CONTENTDISPLAY=LABELVALUE | VALUE
specifies whether the variable information that is displayed in the inset includes
the column label and value, or only the column value.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.
If a label is not assigned to a column, then the column name is used as the label
for that column. Consider the following inset data:
LAYOUT DATALATTICE Statement 57

F
Obs _TYPE_ Value Pr > F
1 SS1 94.359 <.0001

The following figure shows the effect that the CONTENTDISPLAY= option has
on the content of an inset that displays this data.

Default LABELVALUE

Tip Use the SEPARATOR= option to specify a separator other than the
default blank space.

DATASCHEME=LIST | MATCHED
specifies the scheme that was used to merge the inset information into the
analysis data.
LIST
one-to-one merging (no BY statement) was used to merge the inset and
analysis data. The variable values are associated with the cells of the data
lattice by using data order. That is, the inset variable values in the first
observation are used in the inset for the first cell, the inset variable values in
the second observation are used in the inset for the second cell, and so on.
MATCHED
match-merging (using a BY statement) was used to merge the inset and
analysis data.

Default LIST

Tip MATCHED is the preferred data scheme for merging the inset and
analysis data.

See “Adding Insets to Classification Panels” in SAS Graph Template


Language: User's Guide

HALIGN=LEFT | CENTER | RIGHT


specifies the horizontal alignment of the inset.

Default LEFT

Interaction This option has an effect only when this layout is nested within a
region layout or when this layout is nested in an overlay-type layout
and AUTOALIGN=NONE.

OPAQUE=TRUE | FALSE
specifies whether the inset background is opaque (TRUE) or transparent
(FALSE).

Default FALSE

Interaction When OPAQUE=FALSE, the background color is not used.


58 Chapter 4 • Layout Statements

See “boolean ” on page 1339 for other Boolean values that you can use.

SEPARATOR="string"
specifies a new separator for the column label and value.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.

Default A blank space

Interaction This option is ignored when CONTENTDISPLAY=VALUE.

TEXTATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the entire inset, excluding the title.

Default The GraphDataText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

TITLE="string"
specifies a title for the inset. The title is added at the top of the inset and spans
the full inset width.

Note Space is not reserved for the title when this value is not specified.

Tip Text properties for the title string can be specified with TITLEATTRS=.

TITLEATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the inset’s title string.

Default The GraphValueText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

VALIGN=TOP | CENTER | BOTTOM


specifies the vertical alignment of the inset.

Default TOP

Interaction This option has effect only when this layout is nested within a
region layout or when this layout is nested in an overlay-type layout
and AUTOALIGN=NONE.

Requirements The options must be enclosed in parentheses.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE
LAYOUT DATALATTICE Statement 59

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0
60 Chapter 4 • Layout Statements

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

PANELNUMBER=positive-integer
specifies the number of the panel to produce. This option enables you to partition a
large grid into a number of smaller grids under these conditions:
• You set a grid size explicitly (ROWS= and COLUMNS= when ROWVAR and
COLUMNVAR variables are specified; ROWS= when only a ROWVAR variable
is specified; COLUMNS= when only a COLUMNVAR variable is specified)
• The grid size is smaller in one or both of the dimensions of the default
dynamically generated grid.
• You execute the template N times and increment the panel number each time. N
is determined by CEIL(all rows * all columns / grid rows * grid columns).

Default 1

Example Suppose ROWVAR=R (R has 10 unique values) and COLUMNVAR=C


(C has 11 unique values). The dynamic grid has 10 rows and 11 columns
and you would have to make the HEIGHT=and WIDTH= quite large to
enable 110 plots to be displayed. By setting some smaller grid size, say
ROWS=3 and COLUMNS=4, and by making the value of
PANELNUMBER= a dynamic or macro variable, you can create 10
panels (9 with 12 data cells and 1 with 2 data cells) that collectively
display all 110 possible crossings. You simply invoke PROC
SGRENDER or a DATA step 10 times, incrementing the dynamic value
for PANELNUMBER each time.

ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” on page 1032 for a list of options..

ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
LAYOUT DATALATTICE Statement 61

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

Interaction This option is needed only if you use a plot statement that supports a
secondary Y2 axis. If you do not use that statement’s YAXIS= option
to map data to the Y2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data
Are Mapped to a Designated Axis” on page 876

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” on page 1032 for a list of options..

ROWDATARANGE=AUTO | UNIONALL | UNION


specifies how the Y-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the Y-axis scale based on the ROWWEIGHT= option and
the column axis type, as follows:
• When ROWWEIGHT=EQUAL (default), UNIONALL is selected.
• When ROWWEIGHT=PROPORTIONAL and the row axis is discrete,
UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the Y-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y-axis data ranges separately for each row in the layout on a per-panel
basis. The scaling does not span multiple panels.

Default AUTO

Tip Use the ROWAXISOPTS= option to control shared axis features.

See The ROWWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

ROW2DATARANGE=AUTO | UNIONALL | UNION


specifies how the Y2-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the Y2-axis scale based on the ROWWEIGHT= option and
the column axis type, as follows:
• When ROWWEIGHT=EQUAL (default), UNIONALL is selected.
• When ROWWEIGHT=PROPORTIONAL and the row axis is discrete,
UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the Y2-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y2-axis data ranges separately for each row in the layout on a per-
panel basis. The scaling does not span multiple panels.
62 Chapter 4 • Layout Statements

Default AUTO

Interaction This option is needed only if you use a plot statement that supports a
secondary Y2 axis. If you do not use that statement’s YAXIS= option to
map data to the Y2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data Are
Mapped to a Designated Axis” on page 876

Tip Use the ROW2AXISOPTS= option to control shared axis features.

See The ROWWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Default 0

Note If there are n rows, then there are n-1 gutters.

See “dimension” on page 1340

ROWHEADERS=RIGHT | LEFT | BOTH


specifies where to position the outside row heading.
RIGHT
specifies that row heading appears at the right of the layout.
LEFT
specifies that row heading appears at the left of the layout.
BOTH
specifies that row heading alternates between the right and left of the layout row
by row.

Default RIGHT

Requirement HEADERLABELLOCATION= OUTSIDE must be set for this


option to have any effect.

ROWS=integer
specifies the number of rows in the layout.

Defaults If this option is not specified, then the number of rows is dynamically
adjusted to equal the number of classifier values for the ROWVAR=
variable.

If this option is specified, then the specified number of rows is created.


If the number of ROWVAR classifier values is greater than the
specified number of rows, then no graph is created for some classifier
values. If the number of classifier values is smaller than the specified
number of rows, then extra empty rows are created.

Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows, the
LAYOUT DATALATTICE Statement 63

cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.

The START= option affects how the rows are populated.

Tip The PANELNUMBER= option enables you to create multiple smaller


grids that completely partition the classifier values.

ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
EQUAL
all rows have equal height.
PROPORTIONAL
each row has a height that is proportional to the number of discrete midpoint
values that it contains.

Restriction At least one row axis must be discrete in order for


PROPORTIONAL to have any effect. Otherwise, EQUAL is used.

Interactions When ROWDATARANGE=UNIONALL, PROPORTIONAL is


ignored and EQUAL is used.

When PROPORTIONAL is in effect, ROWDATARANGE=AUTO


is interpreted as UNION.

If all of the following conditions are true, then the discrete axis is
used to proportion the rows: PROPORTIONAL is in effect, both
the Y and Y2 axes are used, and only one of the two axes is
discrete. When both axes are discrete, the Y axis is used to
proportion the rows.

When PROPORTIONAL is in effect, the OFFSETMIN= and


OFFSETMAX= axis options are ignored in ROWAXISOPTS= and
ROW2AXISOPTS=. The axis offsets are always set to one-half of
the midpoint spacing regardless of plot type.

Default EQUAL

SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting levels of
the layouts that are used.

Default FALSE

Note Fonts maintain their size regardless of the specifications in the nested
layouts.

See “boolean ” on page 1339 for other Boolean values that you can use.

SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled grid.
TRUE
skips empty cells and "snaps" the external axes to the nearest data cell, both
vertically and horizontally. Though the empty cells are not displayed, the data
cells in the grid are not enlarged to fill the area.
64 Chapter 4 • Layout Statements

FALSE
displays external axes at their normal locations, even if there are empty cells at
one or more of the locations.
Whenever the number of unique COLUMNVAR= classifier values (data cells) is not
evenly divisible by the COLUMNS= value, or the number of unique ROWVAR=
classifier values (data cells) is not evenly divisible by the ROWS= value, then one or
more panels is partially filled with data cells and padded with empty cells to
complete the grid.
Here is an example of a data lattice that consists of 4 column-data cells and 3 row-
data cells arranged in a 4-column, 2-row grid. The following figure shows the default
appearance of the last panel:

When SKIPEMPTYCELLS=TRUE, the empty padding cells of all panels are


removed and external axis ticks and tick values snap to the data cells:

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

SORTORDER=(role-sort-list)
specifies the order of the cells along the columns and rows. The role sort list is a list
of rolename=sort-order-keyword pairs, enclosed in parentheses.
rolename
a role name, which must be one of the following:

COLUMNVAR the column role.


ROWVAR the row variable role.
LAYOUT DATALATTICE Statement 65

sort-order-keyword
a sort-order keyword, which must be one of the following:

AUTO sorts using DATA for character data and


ascending unformatted for numeric data.
DATA retains the data order.
ASCENDINGFORMATTED sorts in ascending order, using the
formatted values.
DESCENDINGFORMATTED sorts in descending order, using the
formatted values.

Default AUTO for all roles.

Tip The placement of the cells within the layout also depends on the starting
location, which is controlled by the START= option.

START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid from the top left or bottom left corner.
If ROWVAR=R has values in the sort order 1 and 2 and COLUMNVAR=C has
values in the sort order a and b, then START=BOTTOMLEFT is populated as
follows:

START=TOPLEFT is populated as follows:

Default TOPLEFT

SIDEBAR Statement Options


ALIGN=BOTTOM | TOP | LEFT | RIGHT
specifies the sidebar’s location within the layout. You can specify up to four
SIDEBAR blocks in a LAYOUT DATALATTICE, one for each of the bottom, top,
left, and right sidebar positions.
• The LAYOUT DATALATTICE automatically aligns a sidebar with the layout
columns or rows.
• Only one statement (such as ENTRY or DISCRETELEGEND) or one layout
block (such as LAYOUT GRIDDED) is allowed in a SIDEBAR block. To create
multi-line text in a sidebar, nest ENTRY statements within a LAYOUT
GRIDDED block.

Default BOTTOM
66 Chapter 4 • Layout Statements

SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.

Default TRUE

Tip To prevent a layout block within the sidebar from expanding to the sidebar
boundaries, set this option to FALSE.

See “boolean ” on page 1339 for other Boolean values that you can use.

Details

Statement Description
The LAYOUT DATALATTICE statement makes it easy to create a grid of graphs, based
on the values of one or two classifications variables. To create a grid that is based on
more than two classification variables, or to have more control over the grid layout, use
LAYOUT DATAPANEL instead.
By default, the number of cells in the layout is determined by the number of value
pairings that are possible for the classification values plus any empty cells needed to
complete the last row or column of the grid. The contents of each data cell are based on a
graph prototype that you specify in the graph-prototype-block. You can enhance the
display using one or more sidebar-statement-blocks. For classification variables that
have many values, you can use the COLUMNS= and or ROWS= options and the
PANELNUMBER= option to generate multiple panel displays.
Classification variables for the layout are specified on the ROWVAR= argument (to
specify a row variable), or the COLUMNVAR= argument (to specify a column), or both
arguments to specify both a column and a row variable. The graph prototype for each
data cell’s contents is specified within a “LAYOUT PROTOTYPE Block” on page 68
block, and sidebars are specified within SIDEBAR blocks. The LAYOUT PROTOTYPE
and SIDEBAR blocks are nested within the LAYOUT DATALATTICE block.
By default, the first data cell to be filled is in the layout’s top left corner. Use the
START= option to change the starting data cell to the bottom left corner.
Rather than display the header labels outside the grid, you can set
HEADERLABELLOCATION= INSIDE to display them inside the grid, as shown in the
following figure:
LAYOUT DATALATTICE Statement 67

Note: The DATALATTICE layout is designed to be the outermost layout in the


template.

Managing Rows and Columns


If you do not explicitly manage columns and rows using the COLUMNS= and ROWS=
options, then the default layout behavior is as follows:
• If both ROWVAR= and COLUMNVAR= are specified, then a data cell is created for
each of the value pairings that are possible for the classification values of the
specified variables. If the ROWVAR variable has R distinct values and the
COLUMNVAR variable has C distinct values, then the dimension of grid produced
is R x C.
• If only the ROWVAR variable is used, then an R x 1 grid is produced.
• If only the COLUMNVAR variable is used, then a 1 x C grid is produced.
If the class variable is of type character, then its values are returned in data order. To
control the ordering of the values, you can sort the input data by the classification
variables. If the class variable is of type numeric, then the values are displayed in ordinal
order.
Formats can be assigned to class variables to create classification levels (for example, an
AGEGROUPFMT. format for numeric AGE). In this case, the classification is
performed after the format is applied. For numeric data, the order is ordinal, based on the
first value in each class.
Use the INCLUDEMISSINGCLASS option to control whether cells are displayed when
any value crossing contains a missing value.
The output size does not grow automatically as the number of cells increases. To set a
panel size for the current template, use the DESIGNHEIGHT= and DESIGNWIDTH=
options in the BEGINGRAPH statement. To set a panel size for all templates in the
current SAS session, use the HEIGHT= and WIDTH= options in the ODS GRAPHICS
statement. Size settings in the ODS GRAPHICS statement override size settings in the
68 Chapter 4 • Layout Statements

BEGINGRAPH statement. The default output width is 640px, and the default output
height is 480px.
As the number of cells in the grid increases, the size of each cell decreases. At some
point the cells might become so small that a meaningful graph cannot be rendered. The
CELLHEIGHTMIN= and CELLWIDTHMIN= options set a threshold for the smallest
cell. If the actual cell height or width becomes smaller, then no panel is drawn. The
default minimum cell size is CELLHEIGHTMIN=100px and
CELLWIDTHMIN=100px.
Using the default panel size and cell size, the DATALATTICE layout accommodates a
grid of about 24 cells (6 columns by 4 rows). If you know that the number of cells is
larger, then you should increase the overall panel size, or decrease the minimum cell
size, or both. You can also use ROWS= , COLUMNS= , and PANELNUMBER= options
to partition your data so that a number of smaller grids are produced that cumulatively
show all of the value crossings.

Creating Your Inset Data


When you use the INSET= option to insert an inset, no predefined information is
available for the inset. You must create the desired inset information as part of your input
data. This is most typically done as follows:
• Create a separate data set for the inset columns making sure that the column names
are different from the other columns used in graph. The number observations of inset
data should match the number of cells in the classification panel. The ordering of the
inset observations should be the same as the population order of the classification
panel’s cells, taking into account the ROWVAR= and COLUMNVAR= arguments
and the START= option. Typically, the number of observations for the inset data is
smaller than the other input data for the graph.
• Merge the inset data set with the data set for the graph using a DATA or PROC SQL
step. Do not match-merge the observations of the two data sets (no BY processing).
The resulting data set typically has the inset columns padded with missing values.
• Use the merged data set to produce the graph, specifying the inset column names in
this option’s variable-list.

LAYOUT PROTOTYPE Block


You must specify a single LAYOUT PROTOTYPE block within the LAYOUT
DATALATTICE block, using the following syntax:
LAYOUT PROTOTYPE </option(s)>;
GTL-statement(s);
ENDLAYOUT;
The LAYOUT PROTOTYPE block determines the graphical content of each data cell
and is repeated within each data cell, based on the subsets of the classification variables.
For more information about the LAYOUT PROTOTYPE block and the list of available
options, see “LAYOUT PROTOTYPE Statement” on page 159.

SIDEBAR Blocks
A LAYOUT DATALATTICE enables you to display one or more sidebars outside of the
axes. A sidebar spans across columns or rows and is useful for displaying information
that applies to all of the columns or all of the rows. For example, sidebars are useful for
displaying a legend.
A SIDEBAR statement has the following syntax:
Example: LAYOUT DATALATTICE 69

SIDEBAR </ option(s)>;


GTL-statement(s);
ENDSIDEBAR;
The following example shows a SIDEBAR block that displays a legend at the top of the
layout grid.

sidebar / align=top;
discretelegend 'p' 'a' / across=2;
endsidebar;

Example: LAYOUT DATALATTICE

This example shows the result of using row and column classification variables. In this
case, a four-column, three-row data lattice is created:
• The classification values are placed as row or column labels by default.
• The ROWDATARANGE=UNION option assures that an axis range is computed
separately for each row using the data ranges of all Y= columns in that row. This
facilitates the visual comparison of the data cells.
• A SIDEBAR block is used to place the legend at the bottom of the lattice.
The following graph was generated by the “Example Program” on page 69:

Example Program
proc template;
70 Chapter 4 • Layout Statements

define statgraph layoutdatalattice;


begingraph;
entrytitle "Annual Furniture Sales Comparisons";
layout datalattice rowvar=country columnvar=year /
rowdatarange=union
headerlabeldisplay=value
headerbackgroundcolor=GraphAltBlock:color
rowaxisopts=(display=(tickvalues) griddisplay=on
linearopts=(tickvalueformat=dollar12.))
columnaxisopts=(display=(tickvalues)
timeopts=(tickvalueformat=monname3.));
layout prototype / cycleattrs=true;
seriesplot x=month y=TotalActual / name="Actual";
seriesplot x=month y=TotalPredict / name="Predict";
endlayout;
sidebar / align=bottom;
discretelegend "Actual" "Predict" / border=false;
endsidebar;
endlayout;
endgraph;
end;
run;

proc summary data=sashelp.prdsal2 nway;


class country year month;
var actual predict;
output out=prdsal2 sum=TotalActual TotalPredict;
run;

proc sgrender data=prdsal2 template=layoutdatalattice;


run;

LAYOUT DATAPANEL Statement


Creates a grid of graphs based on one or more classification variables and a graphical prototype. By
default, a separate instance of the prototype (a data cell) is created for each actual combination of the
classification variables.
Restriction: You can specify only one LAYOUT PROTOTYPE block in the LAYOUT DATAPANEL
block. If you specify more than one, then only the last prototype block specified is
honored. The remaining prototype blocks are ignored.
Tip: The DATAPANEL layout should be the outermost layout in the template.
LAYOUT DATAPANEL Statement 71

Syntax
LAYOUT DATAPANEL CLASSVARS=(class-var1…class-varN) </option(s)> ;
LAYOUT PROTOTYPE </option(s)>;
GTL-statements;
ENDLAYOUT;
<SIDEBAR </ option(s) >;
GTL-statement(s);
ENDSIDEBAR;
<… more-sidebar-statement-blocks …> >
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid.
CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid.
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
HEADERLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the data labels.
HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or
transparent (FALSE).
HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated
list in order to save space.
HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell
header when HEADERPACK=TRUE.
HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before
splitting the text to the next line.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
72 Chapter 4 • Layout Statements

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting
levels of the layouts that are used.
SORTORDER=(role-sort-list)
specifies the order of the cells along the columns and rows.

Axis options
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
COLUMN2DATARANGE=AUTO | UNIONALL | UNION
specifies how the X2-axes of instances of the graph-prototype are scaled.
COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.
COLUMNDATARANGE=AUTO | UNIONALL | UNION
specifies how the X-axes of instances of the graph-prototype are scaled.
ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
ROW2DATARANGE=AUTO | UNIONALL | UNION
specifies how the Y2-axes of instances of the graph-prototype are scaled.
ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.
ROWDATARANGE=AUTO | UNIONALL | UNION
specifies how the Y-axes of instances of the graph-prototype are scaled.

Inset options
INSET=(variable-list)
specifies what information is displayed in an inset.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information.

Layout options
COLUMNS=integer
specifies the number of columns in the layout.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE
specifies the content of the cell headers.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the CLASSVARS
variables that contain a missing value.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
ROWS=integer
specifies the number of rows in the layout.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.

Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
LAYOUT DATAPANEL Statement 73

specifies whether data cells are populated by column priority or by row


priority.
PANELNUMBER=positive-integer
specifies the number of the panel to produce.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled
grid.
SPARSE=TRUE | FALSE
specifies whether crossings of the class variables include only the crossings
in the data or all possible crossings.
START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid cells from the top left or bottom
left corner.

Role options
ROLENAME=(role-name-list)
specifies user-defined roles for information contained in data columns.

Required Argument
CLASSVARS=(column-list)
specifies a list of classification variables. By default, a data cell is created for each
crossing of these variables in the input data. The total number of grid cells created is
the result of a crosstabulation table of all the classification variables plus any empty
cells needed to complete the last row or column of the grid. You can request that data
cells be generated for all possible crossings, even when the class variables have no
values at those crossings. For more information, see the SPARSE= option.
If the class variable is of type character, then its values are returned in data order. To
control the ordering of the values, you can sort the input data by the classification
variables. If the class variable is of type numeric, then the values are displayed in
ordinal order.
Formats can be assigned to class variables to create classification levels (for
example, an AGEGROUPFMT. format for numeric AGE). In this case, the
classification is performed after the format is applied. For numeric data, the order is
ordinal, based on the first value in each class.
Use the INCLUDEMISSINGCLASS option to control whether cells are displayed
when any value crossing contains a missing value.
The output size does not grow automatically as the number of cells increases. To set
a panel size for the current template, use the DESIGNHEIGHT= and
DESIGNWIDTH= options in the BEGINGRAPH statement. To set a panel size for
all templates in the current SAS session, use the HEIGHT= and WIDTH= options in
the ODS GRAPHICS statement. Size settings in the ODS GRAPHICS statement
override size settings in the BEGINGRAPH statement. The default output width is
640px, and the default output height is 480px.
As the number of cells in the grid increases, the size of each cell decreases. At some
point the cells might become so small that a meaningful graph cannot be rendered.
The CELLHEIGHTMIN= and CELLWIDTHMIN= options set a threshold for the
smallest cell. If the actual cell height or width becomes smaller, then no panel is
drawn. The default minimum cell size is CELLHEIGHTMIN=100px and
CELLWIDTHMIN=100px.
Using the default panel size and cell size, the DATAPANEL layout accommodates a
grid of about 24 cells (6 columns by 4 rows). If you know that the number of cells is
74 Chapter 4 • Layout Statements

larger, then you should increase the overall panel size, or decrease the minimum cell
size, or both. You can also use ROWS= , COLUMNS= , and PANELNUMBER=
options to partition your data so that a number of smaller grids are produced that
cumulatively show all of the value crossings.

Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.

Default TRUE

Tip The border attributes are controlled by the GraphBorderLines style


element.

See “boolean ” for other Boolean values that you can use.

CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid. Use this option in conjunction
with the CELLWIDTHMIN= option to set the minimum cell size.
LAYOUT DATAPANEL Statement 75

The overall size of the panel is constrained by the HEIGHT= and WIDTH= options
in the ODS GRAPHICS statement. As the number of cells in the grid increases, the
size of each cell decreases. At some point the cell becomes so small that a
meaningful graph cannot be rendered. This option sets the minimum height threshold
for all cells. If the actual cell height becomes smaller, then no panel is drawn.

Default 100px

See “dimension” on page 1340

CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid. Use this option in conjunction with
the CELLHEIGHTMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH= options
in the ODS GRAPHICS statement. As the number of cells in the grid increases, the
size of each cell decreases. At some point the cell becomes so small that a
meaningful graph cannot be rendered. This option sets the minimum width threshold
for all cells. If the actual cell width becomes smaller, then no panel is drawn.

Default 100px

See “dimension” on page 1340

COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.

Restriction Axis options must be enclosed in parentheses and separated by spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” for a list of options..

COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.

Restriction This option is needed only if you use a plot statement that supports a
secondary X2 axis. If you do not use that statement’s XAXIS= option
to map data to the X2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data
Are Mapped to a Designated Axis” on page 876

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” for a list of options.

COLUMNDATARANGE=AUTO | UNIONALL | UNION


specifies how the X-axes of instances of the graph-prototype are scaled.
AUTO
selects the X-axis scale based on the COLUMNWEIGHT= option and the
column axis type, as follows:
• When COLUMNWEIGHT=EQUAL (default), UNIONALL is selected.
• When COLUMNWEIGHT=PROPORTIONAL and the column axis is
discrete, UNION is selected. Otherwise, UNIONALL is selected.
76 Chapter 4 • Layout Statements

UNIONALL
scales the X-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X-axis data ranges separately for each column on a per-panel basis.
The scaling does not span multiple panels.

Default AUTO

Tip Use the COLUMNAXISOPTS= option to control shared axis features.

See The COLUMNWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

COLUMN2DATARANGE=AUTO | UNIONALL | UNION


specifies how the X2-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the X2-axis scale based on the COLUMNWEIGHT= option
and the column axis type, as follows:
• When COLUMNWEIGHT=EQUAL (default), UNIONALL is selected.
• When COLUMNWEIGHT=PROPORTIONAL and the column axis is
discrete, UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the X2-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X2-axis data ranges separately for each column on a per-panel basis.
The scaling does not span multiple panels.

Default AUTO

Interaction This option is needed only if you use a plot statement that supports a
secondary X2 axis. If you do not use that statement’s XAXIS= option
to map data to the X2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data Are
Mapped to a Designated Axis” on page 876

Tip Use the COLUMN2AXISOPTS= option to control shared axis features.

See The COLUMNWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.

Default 0

Note If there are n columns, then there are n-1 gutters.

See “dimension” on page 1340


LAYOUT DATAPANEL Statement 77

COLUMNS=integer
specifies the number of columns in the layout.

Defaults If this option is not specified and ROWS= is specified, then the
number of data cells (and columns) increases dynamically to allow all
classifier values to be presented.

If both this option and ROWS= are specified, then a grid of that size is
created, regardless of the number of classifier values. If the number of
classifier values is greater than the grid size, then no graphs are
created for some classifier values. If the number of classifier values is
small and the grid size large, then there might be empty cells created.

Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows, the
cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.

The START= and ORDER= options affect the how the rows are
populated.

The PANELNUMBER= option enables you to create multiple smaller


grids that completely partition the classifier values.

COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
EQUAL
all columns have equal width.
PROPORTIONAL
each column has a width that is proportional to the number of discrete midpoint
values that it contains.

Restriction At least one column axis must be discrete in order for


PROPORTIONAL to have any effect. Otherwise, EQUAL is used.

Interactions When COLUMNDATARANGE=UNIONALL, PROPORTIONAL


is ignored and EQUAL is used.

When PROPORTIONAL is in effect,


COLUMNDATARANGE=AUTO is interpreted as UNION.

If all of the following conditions are true, then the discrete axis is
used to proportion the columns: PROPORTIONAL is in effect,
both the X and X2 axes are used, and only one of the two axes is
discrete. If both axes are discrete, then the X axis is used to
proportion the columns.

When PROPORTIONAL is in effect, the OFFSETMIN= and


OFFSETMAX= axis options are ignored in
COLUMNAXISOPTS= and COLUMN2AXISOPTS=. The axis
offsets are always set to one-half of the midpoint spacing
regardless of plot type.

Default EQUAL
78 Chapter 4 • Layout Statements

HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphHeaderBackground:Color style reference.

Interaction HEADEROPAQUE= TRUE must be in effect for the color to be seen.

HEADERLABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the color and font attributes of the data labels.

Default The GraphValueText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE


specifies the content of the cell headers.
NAMEVALUE
displays the classification variable name and value as a name=value pair in each
cell header.

Example If the classification variables are Country and Product, then


HEADERLABEL=NAMEVALUE produces cell headers such as the
following:

Country=CANADA
Product=TABLE

VALUE
displays the classification variable value only in each cell header.

Example If the classification variables are Country and Product, then


HEADERLABEL=VALUE produces cell headers such as the
following:

CANADA
TABLE

NONE
suppresses the cell headers.

Default NAMEVALUE

HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or transparent
(FALSE).

Default TRUE

Interaction When this option is set to FALSE, the background color for cell headers
is not used.
LAYOUT DATAPANEL Statement 79

See “boolean ” on page 1339 for other Boolean values that you can use.

HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated list in
order to save space.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.
The following figure shows the effect of HEADERPACK= on the cell headers in one
row of a data lattice. The data lattice contains classification variables Country, Year, and
Product.

Default FALSE

Note If the length of the cell header text exceeds the available width, then the
text is truncated.

Tip If truncation occurs, then use the HEADERSPLITCOUNT= option to split


the cell header text into multiple lines.

See “boolean ” on page 1339 for other Boolean values that you can use.

HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell header when
HEADERPACK=TRUE.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.

Default A comma followed by a space

Interaction This option is ignored when HEADERPACK=FALSE.

HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before splitting the
text to the next line.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.
80 Chapter 4 • Layout Statements

The following figure shows how HEADERSPLITCOUNT=2 splits the cell header value
in a data panel of classification variables Country, Year, and Product.

Default The cell header text is not split

Interaction This option is ignored when HEADERPACK=FALSE.

Note If the length of the cell header text exceeds the available width, then the
text is truncated.

Tip Use the HEADERSEPARATOR= option to specify a different


separator.

INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the CLASSVARS variables
that contain a missing value.
TRUE
any crossing of the class variables that includes a missing value produces a row
or column of cells in the grid.
FALSE
any crossing of the class variables that includes a missing value does not produce
a row or columns of cells in the grid.
By default, missing class values are included in the classification. When the data
contains missing classification values, cells are created for the missing classes. The
classification headers for the missing values are blank for missing string values or a
dot for missing numeric values. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing values. If you
want to keep the missing values, then you can create a format that specifies more
meaningful headings for the missing classes. For an example, see “Missing Class
Values” in SAS Graph Template Language: User's Guide.
Note: ODS Graphics does not support Unicode values in user-defined formats in the
second maintenance release of SAS 9.4 and in earlier releases. Starting with the
third maintenance release of SAS 9.4, ODS Graphics supports Unicode values in
user-defined formats only if they are preceded by the (*ESC*) escape sequence.
Example: "(*ESC*){unicode beta}". ODS Graphics does not support an
escape character that is defined in an ODS ESCAPECHAR statement in user-
defined formats.

Default TRUE

See “boolean ” on page 1339 for other Boolean values that you can use.

INSET=(variable-list)
specifies what information is displayed in an inset. The variable-list defines one or
more variables whose names and values appear as a small table in the data cells. The
variables can be either numeric or character. Variable names are separated by spaces.
LAYOUT DATAPANEL Statement 81

Requirement No predefined information is available for the inset. You must create
the desired inset information as part of your input data. See “Creating
Your Inset Data” on page 68.

Note The variable values are associated with the data cells by data order.
That is, the first observation from all the variables in variable-list are
used in the first data cell, the second observation from all variables in
variable-list are used in the second data cell, and so on. If a value is
missing for an observation, then the corresponding name-value pair is
skipped in the affected data cell.

Tip The location and appearance of the inset is controlled by the


INSETOPTS= option.

See “Adding Insets to Your Graph” in SAS Graph Template Language:


User's Guide

INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information. The appearance
options can be any one or more of the following values:
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the inset is automatically aligned within the layout.
NONE
does not automatically align the inset. This inset’s position is set by the
HALIGN= and VALIGN=appearance-options.
AUTO
attempts to center the inset in the area that is farthest from any surrounding
markers. Data cells might have different inset placements.
(location-list)
restricts the inset’s possible locations to those locations in the specified
location-list, and uses the location-list position that least collides with the
data cell’s other graphics features. The location-list is a space-separated list
that can contain any of these locations: TOPLEFT, TOP, TOPRIGHT, LEFT,
CENTER, RIGHT, BOTTOMLEFT, BOTTOM, and BOTTOMRIGHT.

Example AUTOALIGN=(TOPRIGHT TOPLEFT)

Default NONE

Interaction When AUTOALIGN=AUTO or (location-list), the HALIGN= and


VALIGN= options are ignored.

BACKGROUNDCOLOR=style-reference | color
specifies the color of the inset background.
style-reference
specifies a style reference in the form style-element : style-attribute. Only the
COLOR and CONTRASTCOLOR style attributes are valid.

Default The background is transparent. No color is assigned.

BORDER=TRUE | FALSE
specifies whether a border is displayed around the inset.
82 Chapter 4 • Layout Statements

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

CONTENTDISPLAY=LABELVALUE | VALUE
specifies whether the variable information that is displayed in the inset includes
the column label and value, or only the column value.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.
If a label is not assigned to a column, then the column name is used as the label
for that column. Consider the following inset data:
F
Obs _TYPE_ Value Pr > F
1 SS1 94.359 <.0001

The following figure shows the effect that the CONTENTDISPLAY= option has
on the content of an inset that displays this data.

Default LABELVALUE

Tip Use the SEPARATOR= option to specify a separator other than the
default blank space.

DATASCHEME=LIST | MATCHED
specifies the scheme that was used to merge the inset information into the
analysis data.
LIST
one-to-one merging (no BY statement) was used to merge the inset and
analysis data. The variable values are associated with the cells of the data
lattice by using data order. That is, the inset variable values in the first
observation are used in the inset for the first cell, the inset variable values in
the second observation are used in the inset for the second cell, and so on.
MATCHED
match-merging (using a BY statement) was used to merge the inset and
analysis data.

Default LIST

Tip MATCHED is the preferred data scheme for merging the inset and
analysis data.

See “Adding Insets to Classification Panels” in SAS Graph Template


Language: User's Guide

HALIGN=LEFT | CENTER | RIGHT


specifies the horizontal alignment of the inset.
LAYOUT DATAPANEL Statement 83

Default LEFT

Interaction This option has an effect only when this layout is nested within a
region layout or when this layout is nested in an overlay-type layout
and AUTOALIGN=NONE.

OPAQUE=TRUE | FALSE
specifies whether the inset background is opaque (TRUE) or transparent
(FALSE).

Default FALSE

Interaction When OPAQUE=FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

SEPARATOR="string"
specifies a new separator for the column label and value.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.

Default A blank space

Interaction This option is ignored when CONTENTDISPLAY=VALUE.

TEXTATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the entire inset, excluding the title.

Default The GraphDataText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

TITLE="string"
specifies a title for the inset. The title is added at the top of the inset and spans
the full inset width.

Note Space is not reserved for the title when this value is not specified.

Tip Text properties for the title string can be specified with TITLEATTRS=.

TITLEATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the inset’s title string.

Default The GraphValueText style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

VALIGN=TOP | CENTER | BOTTOM


specifies the vertical alignment of the inset.

Default TOP
84 Chapter 4 • Layout Statements

Interaction This option has effect only when this layout is nested within a
region layout or when this layout is nested in an overlay-type layout
and AUTOALIGN=NONE.

Requirements The options must be enclosed in parentheses.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills the data cells by rows, from the starting position.
COLUMNMAJOR
fills the data cells by columns, from the starting position.

Default ROWMAJOR

Interaction The starting point for rendering data cells is controlled by the START=
option. See the START= option for examples.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.
LAYOUT DATAPANEL Statement 85

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

PANELNUMBER=positive-integer
specifies the number of the panel to produce. This option enables you to partition a
large grid into a number of smaller sized grids under these conditions:
• You set a grid size explicitly ( ROWS= and COLUMNS= options).
• The grid size (gridrows x gridcolumns) is smaller than the total number of
classifier levels.
• You execute the template N times and increment the panel number each time. N
is determined by CEIL(total-classification-levels / gridrows x
gridcolumns).
86 Chapter 4 • Layout Statements

Default 1

Example Suppose there are two classifiers (CLASS1 has 10 unique values and
CLASS2 has 11 unique values). By setting some smaller grid size, say
ROWS=3 and COLUMNS=4, and making the value of
PANELNUMBER= a dynamic or macro variable, you can create 10
panels (9 panels with 12 data cells and 1 panel with 2 data cells) that
collectively display all 110 possible crossings. You simply invoke PROC
SGRENDER or a DATA step 10 times, incrementing the dynamic value
for PANELNUMBER each time.

ROLENAME=(role-name-list)
specifies user-defined roles for information contained in data columns. The role
name list is a space-separated list role-name=column pairs.

Default no user-defined roles

Requirement The role names that you choose must be unique and different from
the predefined roles.

Example The following example assigns the column Obs to the user-defined
role TIP1.
ROLENAME=(TIP1=OBS)

ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” on page 1032 for a list of options..

ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.

Requirement Axis options must be enclosed in parentheses and separated by


spaces.

Interaction This option is needed only if you use a plot statement that supports a
secondary Y2 axis. If you do not use that statement’s YAXIS= option
to map data to the Y2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data
Are Mapped to a Designated Axis” on page 876

See “Axis Options for LAYOUT DATALATTICE and LAYOUT


DATAPANEL” on page 1032 for a list of options..

ROWDATARANGE=AUTO | UNIONALL | UNION


specifies how the Y-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the Y-axis scale based on the ROWWEIGHT= option and
the column axis type, as follows:
• When ROWWEIGHT=EQUAL (default), UNIONALL is selected.
• When ROWWEIGHT=PROPORTIONAL and the row axis is discrete,
UNION is selected. Otherwise, UNIONALL is selected.
LAYOUT DATAPANEL Statement 87

UNIONALL
scales the Y-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y-axis data ranges separately for each row in the layout on a per-panel
basis. The scaling does not span multiple panels.

Default AUTO

Tip Use the ROWAXISOPTS= option to control shared axis features.

See The ROWWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

ROW2DATARANGE=AUTO | UNIONALL | UNION


specifies how the Y2-axes of instances of the graph-prototype are scaled.
AUTO
automatically selects the Y2-axis scale based on the ROWWEIGHT= option and
the column axis type, as follows:
• When ROWWEIGHT=EQUAL (default), UNIONALL is selected.
• When ROWWEIGHT=PROPORTIONAL and the row axis is discrete,
UNION is selected. Otherwise, UNIONALL is selected.
UNIONALL
scales the Y2-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y2-axis data ranges separately for each row in the layout on a per-
panel basis. The scaling does not span multiple panels.

Default AUTO

Interaction This option is needed only if you use a plot statement that supports a
secondary Y2 axis. If you do not use that statement’s YAXIS= option to
map data to the Y2 axis, then this option is ignored. For more
information about how data are mapped to the axes, see “Plot Data Are
Mapped to a Designated Axis” on page 876

Tip Use the ROW2AXISOPTS= option to control shared axis features.

See The ROWWEIGHT= option.

The PANELNUMBER= option for information about how to create


multiple panels.

ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Default 0

Note If there are n rows, then there are n-1 gutters.

See “dimension” on page 1340


88 Chapter 4 • Layout Statements

ROWS=integer
specifies the number of rows in the layout.

Defaults If this option is not specified and COLUMNS= is specified, then the
number of data cells (and rows) increases dynamically to allow all
classifier values to be presented.

If both this option and COLUMNS= are specified, then a grid of that
size is created, regardless of the number of classifier values. If the
number of classifier values is greater than the grid size, then no graphs
are created for some classifier values. If the number of classifier
values is small and the grid size large, then there might be empty cells
created.

Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows, the
cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.

The START= and ORDER= options affect how the rows are
populated.

Tip The PANELNUMBER= option enables you to create multiple smaller


grids that completely partition the classifier values.

ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
EQUAL
all rows have equal height.
PROPORTIONAL
each row has a height that is proportional to the number of discrete midpoint
values that it contains.

Restriction At least one row axis must be discrete in order for


PROPORTIONAL to have any effect. Otherwise, EQUAL is used.

Interactions When ROWDATARANGE=UNIONALL, PROPORTIONAL is


ignored and EQUAL is used.

When PROPORTIONAL is in effect, ROWDATARANGE=AUTO


is interpreted as UNION.

If all of the following conditions are true, then the discrete axis is
used to proportion the rows: PROPORTIONAL is in effect, both
the Y and Y2 axes are used, and only one of the two axes is
discrete. When both axes are discrete, the Y axis is used to
proportion the rows.

When PROPORTIONAL is in effect, the OFFSETMIN= and


OFFSETMAX= axis options are ignored in ROWAXISOPTS= and
ROW2AXISOPTS=. The axis offsets are always set to one-half of
the midpoint spacing regardless of plot type.

Default EQUAL
LAYOUT DATAPANEL Statement 89

SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting levels of
the layouts that are used.

Default FALSE

Note Fonts maintain their size regardless of the specifications in the nested
layouts.

See “boolean ” on page 1339 for other Boolean values that you can use.

SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled grid.
TRUE
skips empty cells and "snaps" the external axes to the nearest data cell, both
vertically and horizontally. Though the empty cells are not displayed, the data
cells in the grid are not enlarged to fill the area.
FALSE
displays external axes at their normal locations, even if there are empty cells at
one or more of the locations.
Whenever the total number of classifier crossings (data cells) is not evenly divisible
by the panel size (columns * rows), the last panel is partially filled with data cells
and padded with empty cells to complete the grid.
Here is an example of a data panel that consists of 16 data cells arranged in a 4-
column, 3-row grid. The following figure shows the default appearance of the last
panel:

When SKIPEMPTYCELLS=TRUE, the empty padding cells of the last panel are
removed and external axis ticks and tick values snap to the data cells:
90 Chapter 4 • Layout Statements

Note that SKIPEMPTYCELLS=TRUE removes only the empty padding cells on the
last panel. It does not remove any data cells that have no crossing values and
therefore no graph (these data cells are displayed when SPARSE=TRUE).

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

SORTORDER=(role-sort-list)
specifies the order of the cells along the columns and rows. The role sort list is a list
of rolename=sort-order-keyword pairs, enclosed in parentheses.
rolename
a role that is defined by the ROLENAME= option.

Note Roles that are not class variables are ignored.

sort-order-keyword
a sort-order keyword, which must be one of the following:

AUTO sorts using DATA for character data and


ascending unformatted for numeric data.
DATA retains the data order.
ASCENDINGFORMATTED sorts in ascending order, using the
formatted values.
DESCENDINGFORMATTED sorts in descending order, using the
formatted values.

Default AUTO for all roles.

Tip The placement of the cells within the layout also depends on the starting
location, which is controlled by the START= option.

SPARSE=TRUE | FALSE
specifies whether crossings of the class variables include only the crossings in the
data or all possible crossings.
LAYOUT DATAPANEL Statement 91

FALSE
specifies that data cells are created only for crossings of the class variables that
are in the data.
TRUE
specifies that the number of data cells is the product of the unique values for each
classification variable.
By default, if a crossing of the class variables has a missing value as part of the data,
then a data cell is created for it.
Here is an example of a classification panel where the classification variables are
COUNTRY and STATE. There are 3 distinct values of COUNTRY (Canada, Mexico,
and U.S.A.) Within Canada and Mexico there are 4 states, and within U.S.A. there
are 8 states. All state names are unique to each country. Therefore, there are 16
unique STATE values and 48 unique crossings of COUNTRY and STATE, but there
are data for only 16 of the crossings.
Assume that a data panel layout is created with COLUMNS=6 and SPARSE=TRUE,
meaning to display all possible crossings. This is what the first row would look like.
Blank data cells are added whenever there are no data values for a crossing:

When SPARSE=FALSE the crossings of the classifiers with no data are


automatically removed. This compacts the display:

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid cells from the top left or bottom left
corner. If ORDER=ROWMAJOR (the default) and START=TOPLEFT (the default),
then a 2 row 2 column grid is populated as shown in the following figure.
92 Chapter 4 • Layout Statements

If ORDER=ROWMAJOR (the default) and START=BOTTOMLEFT, then a 2 row 2


column grid is populated as shown in the following figure.

If ORDER=COLUMNMAJOR and START=BOTTOMLEFT, then a 2 row 2 column


grid is populated as shown in the following figure.

If ORDER=COLUMNMAJOR and START=TOPLEFT, then a 2 row 2 column grid


is populated as shown in the following figure.

Default TOPLEFT

SIDEBAR Optional Argument


ALIGN=BOTTOM | TOP | LEFT | RIGHT
specifies the sidebar’s location within the layout. You can specify up to four
SIDEBAR blocks in a LAYOUT DATAPANEL, one for each of the bottom, top, left,
and right sidebar positions.
• The LAYOUT DATAPANEL automatically aligns a sidebar with the layout
columns or rows.
• Only one statement (such as ENTRY or DISCRETELEGEND) or one layout
block (such as LAYOUT GRIDDED) is allowed in a SIDEBAR block. To create
multi-line text in a sidebar, nest ENTRY statements within a LAYOUT
GRIDDED block.
LAYOUT DATAPANEL Statement 93

Default BOTTOM

SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.

Default TRUE

Tip To prevent a layout block within the sidebar from expanding to the sidebar
boundaries, set this option to FALSE.

See “boolean ” on page 1339 for other Boolean values that you can use.

Details

Statement Description
The LAYOUT DATAPANEL statement creates a grid of graphs, based on the values of
one or more classifications variables. The main differences between this layout and the
DATALATTICE layout is that this layout supports more than two classification
variables, and it provides more control over the grid layout.
By default, the number of cells in the layout is determined by a crosstabulation table of
all the classification variables plus any empty cells needed to complete the last row or
column of the grid. The contents of each data cell are based on a graph prototype that
you specify in the graph-prototype-block. You can enhance the display using one or
more sidebar-statement-blocks. For classification variables that have many values, you
can use the COLUMNS= option or the ROWS= option, or both with the
PANELNUMBER= option to generate multiple panel displays.
The order of the value pairings for the classification variables is determined by the order
that the variables are specified on the CLASSVARS= argument. The last named
variable’s values vary most rapidly (like nested DO loops). Variable values are always
returned in data order.
By default, the first data cell to be filled is in the layout’s top left corner, and data cells
are filled from left-to-right, top-to-bottom. Use the START= option to change the
starting data cell to the bottom left corner, and use the ORDER= option to determine
whether data cells fill by column or by row. See the START= option for illustrations on
how START= and ORDER= interact to manage the fill sequence for data cells.
Note: The DATAPANEL layout is designed to be the outermost layout in the template.

Prototype Block
You must specify a single graph-prototype-block within the LAYOUT DATAPANEL
block, using the following syntax:
LAYOUT PROTOTYPE </option(s)>;
GTL-statements;
ENDLAYOUT;
The graph-prototype-block determines the graphical content of each data cell and is
repeated within each data cell, based on the subsets of the classification variables.
For more information about the LAYOUT PROTOTYPE block and the list of available
options, see “LAYOUT PROTOTYPE Statement” on page 159.
94 Chapter 4 • Layout Statements

Sidebar Blocks
A LAYOUT DATAPANEL enables you to display sidebars outside of the axis areas. A
sidebar spans across columns or rows and is useful for displaying information that
applies to all of the columns or all of the rows. For example, sidebars are useful for
displaying a legend.
A SIDEBAR statement has the following syntax:
SIDEBAR </ option(s) >;
GTL-statement(s);
ENDSIDEBAR;
The following example shows a SIDEBAR block that displays a legend at the top of the
layout grid.

sidebar / align=top;
discretelegend 'p' 'a' / across=2;
endsidebar;

Creating Your Inset Data


When you use the INSET= option to insert an inset, no predefined information is
available for the inset. You must create the desired inset information as part of your input
data. This is most typically done as follows (see the chapter on classification panels and
the chapter on insets in SAS Graph Template Language: User's Guide for complete
examples):
• Create a separate data set for the inset columns making sure that the column names
are different from the other columns used in graph. The number observations of inset
data should match the number of cells in the classification panel. The ordering of the
inset observations should be the same as population order of the cells of the
classification panel, taking into account the CLASSVARS= argument and the
ORDER= and START= options. Typically, the number of observations for the inset
data is smaller than the other input data for the graph.
• Merge the inset data set with the data set for the graph using a DATA or PROC SQL
step. Do not match-merge the observations of the two data sets (no BY processing).
The resulting data set typically has the inset columns padded with missing values.
• Use the merged data set to produce the graph, specifying the inset column names in
this option’s variable-list.

Example: LAYOUTDATAPANEL Statement

This example shows a four-column, three-row data panel using two classification
variables. With this layout, each data cell is subsetted and labeled with the values of the
classification variables.
• The ROWDATARANGE=UNION option assures that an axis range is computed
separately for each row using the data ranges of all Y= columns in that row. This
facilitates the visual comparison of the data cells.
• A SIDEBAR block is used to place the legend at the bottom of the lattice.
Example: LAYOUTDATAPANEL Statement 95

Example Graph
The following graph was generated by the “Example Program” on page 95:

Example Program
proc template;
define statgraph layoutdatapanel;
begingraph;
entrytitle "Annual Furniture Sales Comparisons";
layout datapanel classvars=(country year) /
columns=4 rows=3 rowdatarange=union
headerlabeldisplay=value
headerbackgroundcolor=GraphAltBlock:color
rowaxisopts=(display=(tickvalues) griddisplay=on
linearopts=(tickvalueformat=dollar12.))
columnaxisopts=(display=(tickvalues)
timeopts=(tickvalueformat=monname3.));
layout prototype / cycleattrs=true;
seriesplot x=month y=TotalActual / name="Actual";
seriesplot x=month y=TotalPredict / name="Predict";
endlayout;
sidebar / align=top;
discretelegend "Actual" "Predict" / border=false;
endsidebar;
endlayout;
endgraph;
end;
run;

proc summary data=sashelp.prdsal2 nway;


96 Chapter 4 • Layout Statements

class country year month;


var actual predict;
output out=prdsal2 sum=TotalActual TotalPredict;
run;

proc sgrender data=prdsal2 template=layoutdatapanel;


run;

LAYOUT GLOBALLEGEND Statement


Creates a compound legend containing multiple discrete legends positioned at the bottom of a graph.
Restrictions: Only one global legend is allowed in a graph.
The LAYOUT GLOBALLEGEND statement must be placed directly inside the
BEGINGRAPH block. It is not valid outside of the BEGINGRAPH block.
Continuous legends are not supported inside the global legend.
When the LAYOUT GLOBALLEGEND block is used, all of the template's legend
statements must be specified within the LAYOUT GLOBALLEGEND block. Any
legend statements that are specified outside of the LAYOUT GLOBALLEGEND block
are ignored.
See: “DISCRETELEGEND and MERGEDLEGEND Statements” on page 1109

Syntax
LAYOUT GLOBALLEGEND </option(s)>;
<discreteLegend-statement(s) | mergedLegend-statement(s)>;
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
DISPLAYCLIPPED=TRUE | FALSE
specifies whether the global legend is displayed when any portion of its
nested legends cannot be fully rendered because of space constraints.
GUTTER=dimension
specifies the gap between nested layouts.
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
TYPE=ROW | COLUMN
specifies whether nested legends are arranged into a single row or column.
WEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the preferred space allocation for the nested legends.

Legend title options


LAYOUT GLOBALLEGEND Statement 97

LEGENDTITLEPOSITION=LEFT | TOP
specifies the position of each nested legend’s title.
TITLE=“string”
specifies a title for the global legend.
TITLEATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the global legend title.

Location options
HALIGN=CENTER | LEFT | RIGHT
specifies the layout’s horizontal alignment within the graph area that is
defined by the BEGINGRAPH block.

Optional Arguments
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

DISPLAYCLIPPED=TRUE | FALSE
specifies whether the global legend is displayed when any portion of its nested
legends cannot be fully rendered because of space constraints. When the graph size
is reduced, parts of a nested legend (title, legend symbol, or legend value) might be
clipped (truncated). When clipping occurs and this option is FALSE, the entire global
legend is removed from the graph and the space for it is reclaimed by the remainder
of the graph. When this option is TRUE, the global legend always appears, even if
some parts of the nested legends have been clipped.

Default FALSE

Interaction This option overrides any DISPLAYCLIPPED option that is set on its
nested legend statements.

See “boolean ” on page 1339 for other Boolean values that you can use.

GUTTER=dimension
specifies the gap between nested layouts.

Default 0
98 Chapter 4 • Layout Statements

Note The default units for dimension are pixels.

See “dimension” on page 1340

HALIGN=CENTER | LEFT | RIGHT


specifies the layout’s horizontal alignment within the graph area that is defined by
the BEGINGRAPH block.

Default CENTER

Note When CENTER is in effect and the outermost layout is an overlay-type


layout, the global legend is centered below the wall area if it can fit within
the wall width.

LEGENDTITLEPOSITION=LEFT | TOP
specifies the position of each nested legend’s title. Specifying LEFT places each title
to the left of the legend items for that legend. Specifying TOP places each title above
the legend items for that legend.

Default LEFT

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Notes The default units for dimension are pixels.

Starting with the first maintenance release of SAS 9.4, the default padding
between the global legend and the plot area (including the axes) is
increased to 10 pixels. If the new default padding is not desirable, then use
this option to adjust it.
LAYOUT GLOBALLEGEND Statement 99

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

TITLE=“string”
specifies a title for the global legend.

Default No title is displayed for the global legend.

Restriction The string must be enclosed in quotation marks.

Tip The title for the global legend is independent of the titles for its nested
legends.

TITLEATTRS=style-element | style-element (text-options) | (text-options)


specifies the color and font attributes of the global legend title.

Default The GraphLabelText style element.

Interaction For this option to have any effect, the TITLE= option must also be
specified.
100 Chapter 4 • Layout Statements

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

TYPE=ROW | COLUMN
specifies whether nested legends are arranged into a single row or column.

Default ROW

Interaction When this option is set to ROW, the relative width of each legend is
determined by the setting for the WEIGHTS= option.

WEIGHTS=UNIFORM | PREFERRED | (weight-list)


specifies the preferred space allocation for the nested legends.
UNIFORM
allocates an equal amount of space for all nested legends.
PREFERRED
allocates the preferred amount of space for each nested legend.
(weight-list)
a space-separated list of preferred space allocations, enclosed in parentheses. The
list can combine numbers with the keyword PREFERRED. Each number is a
proportional weight for the corresponding nested legend (the weights do not have
to sum to 1.0). Keyword PREFERRED specifies that the corresponding nested
legend should be allocated its preferred space. The order of the weights that are
specified in the list should correspond to the order of the legend statements that
are nested in the GLOBALLEGEND layout.

Default UNIFORM

Restriction The option is supported only for TYPE=ROW.

Tip When a weight-list is specified, all the legends using PREFERRED get
their preferred space. Any remaining space is divided among the
legends, in proportion to the numeric values specified in the weight-list.

Details
A global legend layout can contain multiple discrete or merged legends. Continuous
legends are not supported inside the global legend block.
A global legend is placed at the bottom of the graph, just above the footnote(s). All of
the discrete or merged legend statements that are nested within the global legend block
are arranged into a single row or column, depending on the setting for the TYPE=
option.
Depending on the outermost layout type and the legend content, the legend is centered
on the graph wall area or on the graph output area. For example, if the outermost layout
is an overlay layout, then when positioning the legend, the GLOBALLEGEND
statement first attempts to center the legend on the graph wall area. If that position
causes the legend to be clipped, then it then attempts to center the legend on the entire
output area instead. In that case, the legend might appear to be slightly off-center with
respect to the graph.
Only one global legend block is permitted in a graph. The block must be located within
the BEGINGRAPH block, but outside of the outermost layout block.
Example: LAYOUT GLOBALLEGEND Statement 101

When a global legend block is used, only the legend statements that are specified within
the global legend block are displayed in the graph. Any legend statements that are
specified outside of the global legend block are ignored.

Example: LAYOUT GLOBALLEGEND Statement

The following graph was generated by the “Example Program” on page 101:

Example Program
proc template;
define statgraph globallegend;
begingraph;
entrytitle "Prediction Ellipses";
layout overlay;
scatterplot x=petallength y=petalwidth / group=species name="sp";
ellipse x=petallength y=petalwidth / type=predicted alpha=0.2
name="p80" legendlabel="80%" outlineattrs=graphconfidence;
ellipse x=petallength y=petalwidth / type=predicted alpha=0.05
name="p95" legendlabel="95%" outlineattrs=graphconfidence2;
endlayout;
layout globalLegend / type=column title="Sample Global Legend";
discretelegend "sp" / title="Species:";
discretelegend "p80" "p95" / title="Predictions:";
endLayout;
endgraph;
end;
run;
102 Chapter 4 • Layout Statements

proc sgrender data=sashelp.iris template=globallegend;


run;

LAYOUT GRIDDED Statement


Assembles the results of nested GTL-statements into a grid.
Note: Empty cells might be omitted from the grid. See “Details” on page 109.

Syntax
LAYOUT GRIDDED </option(s)>;
GTL-statements;
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
COLUMNGUTTER=dimension
specifies the amount of empty space between the columns.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting
levels of the layouts that are used.

Grid options
COLUMNS=integer
specifies the number of columns in the layout.
ROWS=integer
specifies the number of rows in the layout.

Layout options
ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Legend options
LOCATION=INSIDE | OUTSIDE
LAYOUT GRIDDED Statement 103

specifies whether the legend appears inside or outside the plot area when
nested within an overlay-type layout.

Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent when
nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies this layout’s horizontal alignment within its parent when nested
within an overlay-type or region layout.
VALIGN=CENTER | TOP | BOTTOM | number
specifies this layout’s vertical alignment within its parent when nested within
an overlay-type or region layout.

Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row
priority.

Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent when nested
within an overlay-type layout.
NONE
does not automatically align the layout within its overlay-type parent layout. This
layout’s position within its parent layout is therefore set by the HALIGN= and
VALIGN= options.
AUTO
within the overlay-type parent layout, attempts to center the layout in the area
that is farthest from any surrounding data point markers. This option is available
only if the parent layout contains a scatter plot. Otherwise, it is ignored.
(location-list)
within the parent layout, restricts the layout’s possible locations to those
locations in the specified location-list, and uses the location-list position that
least collides with the parent layout’s other graphics features. The location-list is
a space-separated list that can contain any of these locations: TOPLEFT, TOP,
TOPRIGHT, LEFT, CENTER, RIGHT, BOTTOMLEFT, BOTTOM, and
BOTTOMRIGHT.

Default NONE

Restriction This option is ignored if this layout statement is the outermost layout
or if the parent layout is not an overlay-type layout.

Interactions When this option is not NONE and the parent layout is an overlay-
type layout, the HALIGN= and VALIGN= options are ignored.

This option is ignored if LOCATION= OUTSIDE.

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type layout.
104 Chapter 4 • Layout Statements

BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

COLUMNGUTTER=dimension
specifies the amount of empty space between the columns.

Default 0

Note If there are n columns, then there are n-1 gutters.

See “dimension” on page 1340

COLUMNS=integer
specifies the number of columns in the layout. This option is used to create a grid
with a fixed number of columns, without concern for how many rows. For example,
the following settings ensure that columns 1 and 2 in the first row are filled with
content, as shown in the figure:

layout gridded / columns=2 order=rowmajor border=true ;


entry '1' /border=true;
entry '2' /border=true;
entry '3' /border=true;
endlayout;
LAYOUT GRIDDED Statement 105

Defaults If ORDER= ROWMAJOR, then the default is 1.

If ORDER=COLUMNMAJOR, then as many columns are created as


needed to satisfy the ROWS= request.

Restriction Assuming ORDER=ROWMAJOR, if COLUMNS=n and there are m


cells defined, and n > m, then only m columns are created (there are n -
m cells with zero size).

HALIGN=CENTER | LEFT | RIGHT | number


specifies this layout’s horizontal alignment within its parent when nested within an
overlay-type or region layout.
number
specifies the horizontal alignment as a fraction of the parent container’s width.

Range 0 to 1, where 0 is all the way to the left and 1 is all the way to the
right.

Interaction For a number setting to take effect, LOCATION=INSIDE must be


set. A number setting is invalid on this option when
LOCATION=OUTSIDE.

Default CENTER

Restriction This option has effect only when this layout is nested within a region
layout, or when this layout is nested in an overlay-type layout and
AUTOALIGN=NONE.

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type or region
layout.

LOCATION=INSIDE | OUTSIDE
specifies whether the legend appears inside or outside the plot area when nested
within an overlay-type layout.

Default INSIDE

Restriction This option has effect only when the GRIDDED layout block appears
within an overlay-type layout. For more information about how child
positions are determined in an overlay-type layout, see “LAYOUT
OVERLAY Statement” on page 136.

Interactions If this option is set to OUTSIDE, then the HALIGN= and VALIGN=
options must specify a keyword (LEFT, RIGHT, or CENTER). The
number setting for the alignment is invalid when the layout is
positioned outside of the plot area.

The actual position is determined by this option’s setting plus the


settings for the AUTOALIGN= or HALIGN= and VALIGN= options.
106 Chapter 4 • Layout Statements

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills all the columns in a row, from left to right, before going to the next row.
COLUMNMAJOR
fills all the rows in a column, from top to bottom, before going to the next
column.

Default ROWMAJOR

Requirements If this option is set to COLUMNMAJOR, then the ROWS= option


must be specified to indicate how many rows to fill before wrapping
to the next column. The default number of rows is 1.

If this option is set to ROWMAJOR, then the COLUMNS= option


must be specified to indicate how many columns to fill before
wrapping to the next column. The default number of columns is 1.

Interactions The ROWS= option is ignored when ORDER=ROWMAJOR.

The COLUMNS= option is ignored when


ORDER=COLUMNMAJOR.

See ROWS= on page 108

COLUMNS= on page 104

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
LAYOUT GRIDDED Statement 107

BOTTOM=dimension specifies the amount of extra space to add to the


bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Default 0
108 Chapter 4 • Layout Statements

Note If there are n rows, then there are n-1 gutters.

See “dimension” on page 1340

ROWS=integer
specifies the number of rows in the layout. This option is used to create a grid with a
fixed number of rows, without concern for how many columns. For example, the
following settings ensure that rows 1 and 2 in the first column are filled with content,
as shown in the figure:

layout gridded / rows=2 order=columnmajor border=true ;


entry '1' /border=true;
entry '2' /border=true;
entry '3' /border=true;
endlayout;

Defaults If ORDER= COLUMNMAJOR, then the default is 1.

If ORDER=ROWMAJOR, then this option is ignored and as many


rows are created as needed to satisfy the COLUMNS= request.

Restriction Assuming ORDER=COLUMNMAJOR, if ROWS=n and there are m


cells defined, and n > m, then only m rows are created (there are n - m
cells with zero size).

SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting levels of
the layouts that are used.

Default FALSE

Note Fonts maintain their size regardless of the specifications in the nested
layouts.

See “boolean ” on page 1339 for other Boolean values that you can use.

VALIGN=CENTER | TOP | BOTTOM | number


specifies this layout’s vertical alignment within its parent when nested within an
overlay-type or region layout.
number
specifies the vertical alignment as a fraction of the parent container’s height.

Range 0 to 1, where 0 is on the bottom and 1 is on the top.

Interaction For a number setting to take effect, LOCATION=INSIDE must be


set. A number setting is invalid on this option when
LOCATION=OUTSIDE.

Default CENTER
Example: LAYOUT GRIDDED Statement 109

Restriction This option has effect only when this layout is nested within a region
layout, or when this layout is nested in an overlay-type layout and
AUTOALIGN=NONE.

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type or region
layout.

Details
A GRIDDED layout is commonly used to create small tables of text that are nested
within other layouts. The layout might also be used to span and center a single entry (a
legend, for example) across a set of grids. Or it might be used to display a grid of graphs
when there is no need to scale axis data ranges or align graphs across grid cells.
The GRIDDED layout automatically decides how much area to allocate to cell contents:
• Text items have a fixed size based on the amount of text and the font properties.
• Graphs take up the remaining space.
The layout’s grid size is determined by the COLUMNS= and ROWS= options. The
resulting columns and rows can be separated by areas called “gutters,” which are
controlled by the COLUMNGUTTER= and ROWGUTTER= options.
By default, the results of the GTL statements are placed into the grid sequentially from
left to right, wrapping to a new row each time the current row is filled. You can use the
ORDER= option to fill cells from top to bottom down a column. In that case, the layout
cells wrap to a new column each time the current column is filled. The GTL statements
can include text statements, plot statements, and layout blocks. Each statement or layout
block provides content for one cell in the grid.
If a statement or layout block for a grid cell does not produce any output, then the space
for that cell might not be retained as an empty cell in the grid. In that case, the empty cell
is removed, and the remaining cells (if any) fill the gap in the grid. A statement produces
no output when required data for that statement does not resolve. A layout block
produces no output when it contains no statements or when none of the statements
contained in the block produce any output.

Example: LAYOUT GRIDDED Statement

The following graph was generated by the “Example Program” on page 110:
110 Chapter 4 • Layout Statements

Example Program
The GRIDDED layout offers the best way to nest a table of information inside another
layout. In the GRIDDED layout, you can control the content, text justification, and fonts
of columns. Because this example nests the GRIDDED layout within an OVERLAY
layout, you can control where it appears within the plot area. The AUTOALIGN= option
enables you to specify a prioritized list of possible positions where the layout should be
drawn. The position actually used is the first one that avoids collision with the
histogram. Also, the GRIDDED layout is set to be opaque so that the grid lines do not
show through.
This example also illustrates a reusable template in the sense that it works for any
numeric column specified by the dynamic variable VAR. Also, SGE functions for
computing the N, MEAN, STDDEV of the column are used in the table to compute the
statistics as the template is executed.
proc template;
define statgraph inset;
dynamic VAR;
begingraph;
entrytitle "Distribution of " VAR;
layout overlay / yaxisopts=(griddisplay=on);
histogram VAR / scale=percent;
layout gridded / columns=2
autoalign=(topleft topright) border=true
opaque=true backgroundcolor=GraphWalls:color;
entry halign=left "N";
entry halign=left eval(strip(put(n(VAR),12.0)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(VAR),12.2)));
entry halign=left "Std Dev";
entry halign=left eval(strip(put(stddev(VAR),12.2)));
endlayout;
LAYOUT LATTICE Statement 111

endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.cars template=inset;


dynamic VAR="Weight";
run;

LAYOUT LATTICE Statement


Creates a grid of graphs that automatically aligns plot areas and tick display areas across grid cells to
facilitate data comparisons among graphs.
Note: Empty cells might be omitted from the lattice. See “Cell Contents” on page 127.

Syntax
LAYOUT LATTICE </option(s)>;
GTL-statement(s) | cell-statement-block(s);
<COLUMNAXES;
COLUMNAXIS / axis-option(s);
<… more-COLUMNAXIS-statements …>
ENDCOLUMNAXES;>
<COLUMN2AXES;
COLUMNAXIS / axis-option(s);
<… more-COLUMNAXIS-statements …>
ENDCOLUMN2AXES;>
<ROWAXES;
ROWAXIS / axis-option(s);
<… more-ROWAXIS-statements …>
ENDROWAXES;>
<ROW2AXES;
ROWAXIS / axis-option(s);
<… more-ROWAXIS-statements …>
ENDROW2AXES;>
<COLUMNHEADERS;
GTL-statement(s);
ENDCOLUMNHEADERS;
<… more-header-statement-block(s) …> >
<SIDEBAR </option(s)>;
GTL-statement(s);
ENDSIDEBAR;>
<… more-sidebar-statement-blocks …> >
ENDLAYOUT;
112 Chapter 4 • Layout Statements

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting
levels of the layouts that are used.

Cell options
COLUMNWEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the proportional width of each column relative to the overall grid
width, not including the headings and sidebars.
ROWWEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the proportional height of each row relative to the overall grid
height, not including the headings and sidebars.

Column options
COLUMN2DATARANGE=DATA | UNION | UNIONALL
specifies how the X2-axis data ranges of graphs within the layout columns
are scaled.
COLUMNDATARANGE=DATA | UNION | UNIONALL
specifies how the X-axis data ranges of graphs within the layout columns are
scaled.

Lattice options
COLUMNS=integer
specifies the number of columns in the layout.
ROWS=integer
specifies the number of rows in the layout.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the unused cells in a partially filled
lattice.

Layout options
ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Location options
LAYOUT LATTICE Statement 113

AUTOALIGN=NONE | AUTO | (location-list)


specifies whether this layout is automatically aligned within its parent when
nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies this layout’s horizontal alignment within its parent when nested
within an overlay-type or region layout.
VALIGN=CENTER | TOP | BOTTOM | number
specifies this layout’s vertical alignment within its parent when nested within
an overlay-type or region layout.

Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row
priority.

Row options
ROW2DATARANGE=DATA | UNION | UNIONALL
specifies how the Y2-axis data ranges of graphs within the layout rows are
scaled.
ROWDATARANGE=DATA | UNION | UNIONALL
specifies how the Y-axis data ranges of graphs within the layout rows are
scaled.

Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent when nested
within an overlay-type layout.
NONE
does not automatically align the layout within its overlay-type parent layout. This
layout’s position within its parent layout is therefore set by the HALIGN= and
VALIGN= options.
AUTO
within the overlay-type parent layout, attempts to center the layout in the area
that is farthest from any surrounding data point markers. This option is available
only if the parent layout contains a scatter plot. Otherwise, it is ignored.
(location-list)
within the parent layout, restricts the layout’s possible locations to those
locations in the specified location-list, and uses the location-list position that
least collides with the parent layout’s other graphics features. The location-list is
a space-separated list that can contain any of these locations: TOPLEFT, TOP,
TOPRIGHT, LEFT, CENTER, RIGHT, BOTTOMLEFT, BOTTOM, and
BOTTOMRIGHT.

Default NONE

Restriction This option is ignored if this layout statement is the outermost layout or
if the parent layout is not an overlay-type layout.

Interaction When this option is not NONE and the parent layout is an overlay-type
layout, the HALIGN= and VALIGN= options are ignored.
114 Chapter 4 • Layout Statements

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type layout.

Example In the following example, the LATTICE layout is the child of the
OVERLAY layout. The child layout appears in either the top right or
top left position, based on which position has more “unoccupied” area.

dynamic VAR STAT1 STAT2 STAT3;


layout overlay;
histogram VAR;
layout lattice / AUTOALIGN=(TOPRIGHT TOPLEFT)
columns=1;
entry STAT1;
entry STAT2;
entry STAT3;
endlayout;
endlayout;

BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

COLUMNDATARANGE=DATA | UNION | UNIONALL


specifies how the X-axis data ranges of graphs within the layout columns are scaled.
DATA
scales the X-axis data ranges separately for each cell in the layout.
LAYOUT LATTICE Statement 115

UNION
scales the X-axis data ranges separately for each column in the layout. This
setting is supported only if all plots across the column can share the same data
range and axis type. For more information, see “Plot Axis Types Must Agree on
Common Axes” on page 883.
UNIONALL
scales the X-axis data ranges across all columns in the layout. This setting is
supported only if all plots across the column can share the same data range and
axis type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.

Default DATA

Interactions The data ranges are scaled only if the data values are continuous and
the graphs have the same orientation. If graphs cannot use the same
horizontal range or if COLUMNDATARANGE=DATA, then the
horizontal range of each graph is determined from the data.

If any plot statement in any cell contains a XAXIS=X2 option, then


this plot's X values are ignored whenever COLUMNDATARANGE=
is set to UNION or UNIONALL.

Tips If column axes are externalized and if a lattice cell contains a


LAYOUT OVERLAY with the XAXISOPTS= option specified, then
the XAXISOPTS option is ignored. In that case, you can use the
COLUMNAXIS statement to specify desired X-axis features. For
more information, see “Axis Statements” on page 129 .

By default, axes are always internal to the cell. To externalize column


axes, set this option to UNION or UNIONALL, and then specify a
COLUMNAXES block with as many COLUMNAXIS statements as
there are columns that contain X-axes to manage.

COLUMN2DATARANGE=DATA | UNION | UNIONALL


specifies how the X2-axis data ranges of graphs within the layout columns are
scaled.
DATA
scales the X2-axis data ranges separately for each cell in the layout.
UNION
scales the X2-axis data ranges separately for each column in the layout. This
setting is supported only if all plots across the column can share the same data
range and axis type. For more information, see “Plot Axis Types Must Agree on
Common Axes” on page 883.
UNIONALL
scales the X2-axis data ranges across all columns in the layout. This setting is
supported only if all plots across the column can share the same data range and
axis type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.

Default DATA

Interactions The data ranges are scaled only if the data values are continuous and
the graphs have the same orientation. If graphs cannot use the same
116 Chapter 4 • Layout Statements

horizontal range or if COLUMN2DATARANGE=DATA, then the


horizontal range of each graph is determined from the data.

If any plot statement in any cell contains a XAXIS=X option, then this
plot's X values are ignored whenever COLUMN2DATARANGE= is
set to UNION or UNIONALL.

Tips Axes are always internal to the cell, by default. To externalize column
axes, set this option to UNION or UNIONALL, and then specify a
COLUMN2AXES block with as many COLUMNAXIS statements as
there are columns that contain X2-axes to manage.

If column axes are externalized and if a lattice cell contains a


LAYOUT OVERLAY with the X2AXISOPTS= option specified, then
the X2AXISOPTS option is ignored. In that case, you can use the
COLUMNAXIS statement to specify desired X2-axis features. For
more information, see “Axis Statements” on page 129 .

COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.

Default 0

Note If there are n columns, then there are n-1 gutters.

See “dimension” on page 1340

COLUMNS=integer
specifies the number of columns in the layout.

Defaults If ORDER= ROWMAJOR, then the default is 1.

If ORDER=COLUMNMAJOR, then as many columns are created as


are needed to satisfy the ROWS= request.

Interactions If both ROWS=n and COLUMNS=m are specified, then an n by m


grid of cells is created. If the number of statements that define cell
contents is greater than n x m, then the grid size does not expand and
some statements are not displayed. If the number of statements that
define cell contents is less than n x m, then the grid will contain empty
cells.

If this option is not defined and ORDER=COLUMNMAJOR, then the


number of columns is dynamically determined by the number of
defined cells.

COLUMNWEIGHTS=UNIFORM | PREFERRED | (weight-list)


specifies the proportional width of each column relative to the overall grid width, not
including the headings and sidebars.
UNIFORM
equally divides the total available width among all of the columns.
PREFERRED
specifies that each column gets its preferred width based on the following:
• Columns that contain one or more vertically one-dimensional plots get the
maximum preferred width from the vertically one-dimensional plots.
LAYOUT LATTICE Statement 117

• The remaining columns that do not contain vertically one-dimensional plots


get an equal amount of width from the remaining space.

Interaction If a one-dimensional box plot is specified in the preferred column,


then the box plot's BOXWIDTH= option is ignored.

Notes The PREFERRED option is used for lattice layouts that mix one-
dimensional and two-dimensional plots in the grid. It enables the
layout to compute the weights automatically for columns that
contain one-dimensional plots.

Examples of one-dimensional plots include axis tables, block plots,


fringe plots, and box plots with Y= values only.

(weight-list)
a space-separated list of column weights. The list should contain a weight for
each column, which can be expressed as one of the following:
PREFERRED
specifies that the corresponding column gets its preferred width as described
previously.

Note The PREFERRED option should be used on columns that contain


only one-dimensional plots. Using the PREFERRED keyword on
columns that contain a mix of one-dimensional and two-dimensional
plots might cause unexpected results. In that case, use a numeric
weight instead.

Tip The PREFERRED option is particularly useful for axis tables.

number
specifies that the corresponding column gets a width that is based on the
proportion of the specified number to the total of the numbers in the weight
list. For example, the following weight specifications are equivalent:
columnweights=(0.2 0.3 0.5)

columnweights=(2 3 5)

In these examples, the first column gets 20% of the available width, the
second column gets 30%, and the third column gets 50%.
If the list contains the PREFERRED keyword, then the number specifies the
proportion of the width that remains after the preferred width or widths are
calculated and subtracted from the available width.

Requirements The values in the weight list must be enclosed in parentheses.

If there are n columns in the grid, then the weight list should
contain n weights, one for each column.

All of the numbers in the list must be positive.

At least one number in the list must be nonzero.

Note The weights for all of the columns are specified as a proportion
and, as such, are not required to total 1.0.
118 Chapter 4 • Layout Statements

Example Here is an example that specifies the preferred width for the first
column, 20% of the remaining width to the second column, and
80% of the remaining width to the third column.
columnweights=(preferred 0.2 0.8)

HALIGN=CENTER | LEFT | RIGHT | number


specifies this layout’s horizontal alignment within its parent when nested within an
overlay-type or region layout.
number
specifies the horizontal alignment as a fraction of the parent container’s width.

Range 0 to 1, where 0 is all the way to the left and 1 is all the way to the
right.

Interaction For a number setting to take effect, LOCATION=INSIDE must be


set. A number setting is invalid on this option when
LOCATION=OUTSIDE.

Default CENTER

Restriction This option has effect only when this layout is nested within a region
layout, or when this layout is nested in an overlay-type layout and
AUTOALIGN=NONE.

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type or region
layout.

Example In the following example, the LATTICE layout is the child of the
OVERLAY layout and is positioned in the OVERLAY’s top right
corner.
dynamic VAR STAT1 STAT2 STAT3;
layout overlay;
histogram VAR;
layout lattice / VALIGN=TOP HALIGN=RIGHT
columns=1;
entry STAT1;
entry STAT2;
entry STAT3;
endlayout;
endlayout;

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills all the columns in a row, from left to right, before going to the next row.
LAYOUT LATTICE Statement 119

COLUMNMAJOR
fills all the rows in a column, from top to bottom, before going to the next
column.

Default ROWMAJOR

Requirements If this option is set to COLUMNMAJOR, then the ROWS= option


must be specified to indicate how many rows to fill before wrapping
to the next column. The default number of rows is 1.

If this option is set to ROWMAJOR, then the COLUMNS= option


must be specified to indicate how many columns to fill before
wrapping to the next column. The default number of columns is 1.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
120 Chapter 4 • Layout Statements

LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

ROWDATARANGE=DATA | UNION | UNIONALL


specifies how the Y-axis data ranges of graphs within the layout rows are scaled.
DATA
scales the Y-axis data ranges separately for each cell in the layout.
UNION
scales the Y-axis data ranges separately for each row in the layout. This setting is
supported only if all plots down the row can share the same data range and axis
type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.
UNIONALL
scales the Y-axis data ranges across all rows in the layout. This setting is
supported only if all plots down the row can share the same data range and axis
type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.

Default DATA

Interactions The data ranges are scaled only if the data values are continuous and
the graphs have the same orientation. If graphs cannot use the same
vertical range or if ROWDATARANGE=DATA, then the vertical
range of each graph is determined from the data.

If any plot statement in any cell contains a YAXIS=Y2 option, then


this plot's Y values are ignored whenever ROWDATARANGE= is set
to UNION or UNIONALL.
LAYOUT LATTICE Statement 121

Tips Axes are always internal to the cell, by default. To externalize row
axes, set this option to UNION or UNIONALL, and then specify a
ROWAXES block with as many ROWAXIS statements as there are
rows that contain Y-axes to manage.

If row axes are externalized and if a lattice cell contains a LAYOUT


OVERLAY with the YAXISOPTS= option specified, then the
YAXISOPTS option is ignored. In that case, you can use the
ROWAXIS statement to specify desired Y-axis features. For more
information, see “Axis Statements” on page 129 .

ROW2DATARANGE=DATA | UNION | UNIONALL


specifies how the Y2-axis data ranges of graphs within the layout rows are scaled.
DATA
scales the Y2-axis data ranges separately for each cell in the layout.
UNION
scales the Y2-axis data ranges separately for each row in the layout. This setting
is supported only if all plots down the row can share the same data range and axis
type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.
UNIONALL
scales the Y2-axis data ranges across all rows in the layout. This setting is
supported only if all plots down the row can share the same data range and axis
type. For more information, see “Plot Axis Types Must Agree on Common
Axes” on page 883.

Default DATA

Interactions The data ranges are scaled only if the data values are continuous and
the graphs have the same orientation. If graphs cannot use the same
vertical range or if ROW2DATARANGE=DATA, then the vertical
range of each graph is determined from the data.

If any plot statement in any cell contains a YAXIS=Y option, then this
plot's Y values are ignored whenever ROW2DATARANGE= is set to
UNION or UNIONALL.

Tips Axes are always internal to the cell, by default. To externalize row
axes, set this option to UNION or UNIONALL, and then specify a
ROW2AXES block with as many ROWAXIS statements as there are
rows that contain Y2-axes to manage.

If row axes are externalized and if a lattice cell contains a LAYOUT


OVERLAY with the Y2AXISOPTS= option specified, then the
Y2AXISOPTS option is ignored. In that case, you can use the
ROWAXIS statement to specify desired Y2-axis features. For more
information, see “Axis Statements” on page 129 .

ROWGUTTER=dimension
specifies the amount of empty space between the rows.

Default 0

Note If there are n rows, then there are n-1 gutters.


122 Chapter 4 • Layout Statements

See “dimension” on page 1340

ROWS=integer
specifies the number of rows in the layout.

Defaults If ORDER=COLUMNMAJOR, then the default is 1.

If ORDER=ROWMAJOR, then as many ROWS are created as needed


to satisfy the COLUMNS= request.

Interactions If both ROWS=n and COLUMNS=m are specified, then an n by m


grid of cells is created. If the number of statements that define cell
contents is greater than n x m, then the grid size does not expand and
some statements are not displayed. If the number of statements that
define cell contents is less than n x m, then the grid will contain empty
cells.

If ORDER=ROWMAJOR and ROWS= is not defined, then the


number of rows is dynamically determined by the number of defined
cells.

ROWWEIGHTS=UNIFORM | PREFERRED | (weight-list)


specifies the proportional height of each row relative to the overall grid height, not
including the headings and sidebars.
UNIFORM
equally divides the total available height among all of the rows.
PREFERRED
specifies that each row gets its preferred height based on the following:
• Rows that contain one or more horizontally one-dimensional plots get the
maximum preferred height from the horizontally one-dimensional plots.
• The remaining rows that do not contain horizontally one-dimensional plots
get an equal amount of height from the remaining space.

Notes The PREFERRED option is used for lattice layouts that mix one-
dimensional and two-dimensional plots in the grid. It enables the layout
to compute the weights automatically for rows that contain one-
dimensional plots.

Examples of one-dimensional plots include axis tables, block plots,


fringe plots, and box plots with Y= values only.

(weight-list)
a space-separated list of row weights. The list should contain a weight for each
row, which can be expressed as one of the following:
PREFERRED
specifies that the corresponding row gets its preferred height as described
previously.

Note The PREFERRED option should be used on rows that contain only
one-dimensional plots. Using the PREFERRED keyword on rows that
contain a mix of one-dimensional and two-dimensional plots might
cause unexpected results. In that case, use a numeric weight instead.
LAYOUT LATTICE Statement 123

number
specifies that the corresponding row gets a height that is based on the
proportion of the specified number to the total of the numbers in the weight
list. For example, the following weight specifications are equivalent:
rowweights=(0.2 0.3 0.5)

rowweights=(2 3 5)

In these examples, the first row gets 20% of the available height, the second
row gets 30%, and the third row gets 50%.
If the list contains the PREFERRED keyword, then the number specifies the
proportion of the height that remains after the preferred height or heights are
calculated and subtracted from the available height.

Requirements The values in the weight list must be enclosed in parentheses.

If there are n rows in the grid, then the weight list should contain
n weights, one for each row.

All of the numbers in the list must be positive.

At least one number in the list must be nonzero.

Note The weights for all of the rows are specified as a proportion and,
as such, are not required to total 1.0.

Example Here is an example that specifies 25% of the available height for
the first row, 25% for the second row, and 50% for the third row.
rowweights=(1 1 2)

SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled, depending on the nesting levels of
the layouts that are used.

Default FALSE

Note Fonts maintain their size regardless of the specifications in the nested
layouts.

See “boolean ” on page 1339 for other Boolean values that you can use.

SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the unused cells in a partially filled lattice.
FALSE
displays external axes at their normal locations.
TRUE
skips empty cells and “snaps” the external axes to the nearest populated cell, both
vertically and horizontally.

Default FALSE

See “boolean ” on page 1339 for other Boolean values that you can use.

VALIGN=CENTER | TOP | BOTTOM | number


specifies this layout’s vertical alignment within its parent when nested within an
overlay-type or region layout.
124 Chapter 4 • Layout Statements

number
specifies the vertical alignment as a fraction of the parent container’s height.

Range 0 to 1, where 0 is on the bottom and 1 is on the top.

Interaction For a number setting to take effect, LOCATION=INSIDE must be


set. A number setting is invalid on this option when
LOCATION=OUTSIDE.

Default CENTER

Restriction This option has effect only when this layout is nested within a region
layout, or when this layout is nested in an overlay-type layout and
AUTOALIGN=NONE.

See “LAYOUT OVERLAY Statement” on page 142 for more information


about how child positions are determined in an overlay-type or region
layout.

Example In the following example, the LATTICE layout is the child of the
OVERLAY layout. The child layout will appear in either the top right
or top left position, based on which position has more "unoccupied"
area.
dynamic VAR STAT1 STAT2 STAT3;
layout overlay / height=500px width=600px;
histogram VAR;
layout lattice / VALIGN=TOP HALIGN=RIGHT
height=80px width=70px columns=1;
entry STAT1;
entry STAT2;
entry STAT3;
endlayout;
endlayout;

SIDEBAR Optional Arguments


ALIGN=TOP | BOTTOM | LEFT | RIGHT
specifies the alignment of the sidebar.

Default BOTTOM

Tip You can use ENTRY statements to place rotated text in the right or left side
bar.

SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.

Default TRUE

Tip To prevent a layout block within the sidebar from expanding to the sidebar
boundaries, set this option to FALSE.

See “boolean ” on page 1339 for other Boolean values that you can use.
LAYOUT LATTICE Statement 125

Details

Statement Description
The LAYOUT LATTICE statement creates a grid of graphs that are aligned across
columns and rows. For plot statements that are specified in the layout block or nested in
a LAYOUT OVERLAY statement, the LATTICE layout automatically aligns the plot
areas and tick display areas in the plots.
Note: To achieve the alignment, the LATTICE layout automatically aligns plot areas and
tick display areas across columns and rows. Also, it overrides axis-offset settings in
the OVERLAY layouts that you specify in those columns and rows. (For details
about offsets and the tick display area, see “Adjusting Axis Offsets” on page 886.) If
you do not want this alignment, then you might use LAYOUT GRIDDED instead.
For example, if you have a heterogeneous panel of graphs, such as a mix of scatter
plots, box plots, bar charts, or other types of graphs, then you might consider using
LAYOUT GRIDDED rather than LAYOUT LATTICE.
The layout can unify the scale of the data ranges that are displayed in the plots, based on
the values set for the COLUMNDATARANGE= and ROWDATARANGE= options. If
one or more plots within the template use the XAXIS= option to produce independent
X2 (top) axes, then the X2 data scales can be unified, based on the values set for the
COLUMN2DATARANGE= option. If one or more plots within the template use the
YAXIS= option to produce independent Y2 (right) axes, then the Y2 data scales can be
unified, based on the values set for the ROW2DATARANGE= options. The data ranges
can be scaled separately for each column, for each row, or for both. Or they can be
scaled across all columns, all rows, or all of both.
When the data-range scales are unified, you can simplify the layout by displaying only
the external axes that apply to all of the graphs across the corresponding columns or
rows. See “Axis Statements” on page 129 for more details.
The following figure shows the parts of the Lattice layout with the default axis display
(internal axes are displayed).
126 Chapter 4 • Layout Statements

This next figure shows the parts of the Lattice layout when the graph display is
simplified so that only external axes are displayed.
Note: The figure shows secondary X (top) and secondary Y (right) axes. The layout also
enables you to generate independent X2 (top) and independent Y2 (right) axes. For
details, see “Axis Statements” on page 129
LAYOUT LATTICE Statement 127

The columns and rows can be separated by areas called “gutters,” which are controlled
by the COLUMNGUTTER= and ROWGUTTER= options. In addition, the
COLUMNWEIGHTS= and ROWWEIGHTS= options can be used to allocate a
proportion of available space to each row and column.
The LATTICE layout automatically decides how much area to allocate to cell contents:
• Text items have a fixed size based on the amount of text and the font properties.
• Graphs take up the remaining space.
The layout’s grid size is determined by the COLUMNS= and ROWS= options.
By default, the results of the GTL-statements are placed into the grid sequentially from
left to right, wrapping to a new row each time the current row is filled. You can use the
ORDER= option to fill cells from top to bottom down a column. In that case, the layout
cells wrap to a new column each time the current column is filled.

Cell Contents
The following general syntax is used to define the contents of each cell in a LAYOUT
LATTICE:
GTL-statement(s) | cell-statement-block(s)
A cell-statement-block, when used, has the following syntax:
128 Chapter 4 • Layout Statements

CELL;
<CELLHEADER; GTL-statement(s); ENDCELLHEADER;>
GTL-statement(s);
ENDCELL;
The following guidelines apply to defining cell content:
• The contents of each cell is generated by GTL statements, which can be specified
independently or enclosed in a CELL block.
• Independent GTL statements include text statements, plot statements, or layout
blocks. Each independently specified GTL statement or layout block provides
content for one cell.
• A CELL block can include text statements, plot statements, or layout blocks. Each
CELL block provides content for one cell.
• Within a CELL block, you can use a CELLHEADER block to generate one or more
header lines within the cell. Specify each header line on a separate GTL statement
within the CELLHEADER block. The header block is typically used to specify one
or more text statements, but other statements are allowed within the block. For
example, you can specify a LAYOUT GRIDDED statement to produce a grid of text
for the header
• You can use only one CELLHEADER block per CELL block. If you specify more
than one, then only the last one is used.
• If you do not specify a CELLHEADER block in a CELL block, then the enclosed
GTL statements produce the same results that they would produce if they were
specified independently.
• If more than one plot statement is needed to generate contents for a cell, you should
place the plot statements in a layout block such as LAYOUT OVERLAY. Otherwise,
unexpected results might occur. This applies to independent GTL statements and to
GTL statements in a CELL block. See Figure 4.1 on page 129.
If a CELL block, or an independent statement or layout block for a lattice cell does not
produce any output, then the space for that cell might not be retained as an empty cell in
the lattice. In that case, the empty cell is removed, and the remaining cells (if any) fill
the gap in the lattice. A statement produces no output when required data for that
statement does not resolve. A layout block produces no output when it contains no
statements or when none of the statements contained in the block produce any output.
The example code shows a LAYOUT LATTICE block that uses one GTL statement and
one CELL block to generate the two-column layout shown in the following figure:
LAYOUT LATTICE Statement 129

Figure 4.1 Lattice Layout with Independent Plot Statements and a CELL Block

proc template;
define statgraph cellcontents;
begingraph;
layout lattice /
columngutter=5 columns=2;

/* independent plot statement - defines first cell */


scatterplot x=age y=height;

/* cell block - defines second cell */


cell;
cellheader;
entry "Cell Header" / border=true;
endcellheader;
/* two plot statements are needed - enclose
the statements in a LAYOUT OVERLAY block */
layout overlay;
scatterplot x=weight y=height;
referenceline y=53 / lineattrs=(pattern=shortdash)
curvelabellocation=inside curvelabel="Reference Line";
endlayout;
endcell;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.class template=cellcontents;


run;

Axis Statements

Overview
The axis statements can be used to simplify and clarify the layout by displaying only the
external axes in the resulting graph.
The following figure shows the default layout with internal axes displayed:
130 Chapter 4 • Layout Statements

This next figure shows a simplified layout with only the external axes displayed:

Axis statements are useful only if the data ranges across the affected columns or rows
are comparable and can be unified to a common scale. For example, external axes are
not supported if an affected lattice cell contains a LAYOUT OVERLAYEQUATED
statement. If the axis ranges are not unified for the affected columns or rows, then the
axis statements in the layout are ignored.
To unify data ranges in the layout grid, the following options are available:

Axis Option Axis Option

X COLUMNDATARANGE= X2 COLUMN2DATARANGE=

Y ROWDATARANGE= Y2 ROW2DATARANGE=
LAYOUT LATTICE Statement 131

Specifying Axis Features


For columns, axis features for the external X axes (bottom) are specified within a
COLUMNAXES block, nesting one COLUMNAXIS statement for each column that
contains an X axis that you need to manage. The COLUMNAXIS statement provides a
DISPLAYSECONDARY= option, which enables you to display a secondary X (top) axis
that mirrors the primary X axis but can have different display features. In that case, the
axis features that you specify in the COLUMNAXIS statement apply to both the primary
and secondary X axes.
If one or more plots within the template use the XAXIS= option to produce independent
X2 (top) axes, then axis features for the external X2 axes (top) are specified within a
COLUMN2AXES block, nesting one COLUMNAXIS statement for each column that
contains an X2 axis that you need to manage. Within the COLUMN2AXES block, the
COLUMNAXIS statement’s DISPLAYSECONDARY= option enables you to display a
secondary X2 (bottom) axis that mirrors the primary X2 axis but can have different
display features. Here again, the axis features that you specify in the COLUMNAXIS
statement apply to both the primary and secondary X2 axes.
Note: If you specify independent X and X2 scales at the same time, then the
DISPLAYSECONDARY= option is ignored in the COLUMNAXIS statement. This
is true whether the COLUMNAXIS statement is specified in a COLUMNAXES or
COLUMN2AXES block.
For both the COLUMNAXES and COLUMN2AXES blocks, if a lattice cell within the
column contains a LAYOUT OVERLAY with the XAXISOPTS= or X2AXISOPTS=
option specified, these OVERLAY options are ignored. In such cases, the desired axis
features should be specified in the COLUMNAXIS statement.
For rows, axis features for the external Y axes (left) are specified within a ROWAXES
block, nesting one ROWAXIS statement for each row that contains a Y axis that you
need to manage. The ROWAXIS statement provides a DISPLAYSECONDARY= option,
which enables you to display a secondary Y (right) axis that mirrors the primary Y axis
but can have different display features. In that case, the axis features that you specify in
the ROWAXIS statement apply to both the primary and secondary Y axes.
If one or more plots within the template use the YAXIS= option to produce independent
Y2 (right) axes, then axis features for the external Y2 axes (right) are specified within a
ROW2AXES block, nesting one ROWAXIS statement for each row that contains a Y2
axis that you need to manage. Within the ROW2AXES block, the ROWAXIS
statement’s DISPLAYSECONDARY= option enables you to display a secondary Y2
(left) axis that mirrors the primary Y2 axis but can have different display features. Here
again, the axis features that you specify in the ROWAXIS statement apply to both the
primary and secondary Y2 axes.
Note: If you specify independent Y and Y2 scales at the same time, then the
DISPLAYSECONDARY= option is ignored in the ROWAXIS statement. This is true
whether the ROWAXIS statement is specified in a ROWAXES or ROW2AXES
block.
For both the ROWAXES and ROW2AXES blocks, if a lattice cell within the row
contains a LAYOUT OVERLAY with the YAXISOPTS= or Y2AXISOPTS= option
specified, these OVERLAY options are ignored. In such cases, the desired axis features
should be specified in the ROWAXIS statement.

Syntax and Restrictions for the Axis Statements


The axis-statement blocks have the following general syntax:
132 Chapter 4 • Layout Statements

COLUMNAXES; COLUMN2AXES;
COLUMNAXIS / axis-option(s); COLUMNAXIS / axis-option(s);
<…COLUMNAXIS-n;> <…COLUMNAXIS-n;>
ENDCOLUMNAXES; ENDCOLUMN2AXES;

ROWAXES; ROW2AXES;
ROWAXIS / axis-option(s); ROWAXIS / axis-option(s);
<…ROWAXIS-n;> <…ROWAXIS-n;>
ENDROWAXES; ENDROW2AXES;

In the LATTICE layout block, the following restrictions apply:


• If the LAYOUT LATTICE statement sets the row or column data range to DATA,
then the corresponding axes block is ignored. The data range must be set to UNION
or UNIONALL to externalize the axes.
• Only one COLUMNAXES block can be used to manage X axes, and only one
COLUMN2AXES block can be used to manage X2 axes. If more than one of either
block is specified, then only the last one of that block type is used.
• Within a COLUMNAXES or COLUMN2AXES block, one COLUMNAXIS
statement should be specified for each column that contains axes that you need to
manage. Both axes blocks can contain a COLUMNAXIS statement for the same
column. For example, to manage the axes in the first column of the layout, the
COLUMNAXES block can contain a COLUMNAXIS statement that manages the
column’s X axes. The COLUMN2AXES block can contain a COLUMNAXIS
statement that manages the column’s X2 axes.
• Only one ROWAXES block can be used to manage Y axes, and only one
ROWAXES block can be used to manage Y2 axes. If more than one of either block
is specified, then only the last one of that block type is used.
• Within a ROWAXES or ROW2AXES block, one ROWAXIS statement should be
specified for each row that contains axes that you need to manage. Both axes blocks
can contain a ROWAXIS statement for the same row. For example, to manage the
axes in the first row of the layout, the ROWAXES block can contain a ROWAXIS
statement that manages the row’s Y axes. The ROW2AXES block can contain a
ROWAXIS statement that manages the column’s Y2 axes.
• If the number COLUMNLAXIS or ROWAXIS statements is greater than the number
needed, then the extra statements are ignored. If the number of statements is fewer
than the number needed, then the additional COLUMNAXIS or ROWAXIS
statements are automatically generated with DISPLAY=NONE options in effect.
For the list of axis-options, see “Axis Options for LAYOUT LATTICE” on page 963 .
The following example shows a LAYOUT LATTICE block that uses a ROWAXES
block to set external axes and display grid lines for the row display.
begingraph;
layout lattice /
rowdatarange=union
columns=2;

/* axis definitions */
rowaxes;
rowaxis /griddisplay=on;
endrowaxes;
LAYOUT LATTICE Statement 133

/* cell contents */
scatterplot x=x y=t;
scatterplot x=x y=y;

endlayout;
endgraph;

Here, the LAYOUT LATTICE statement specifies the ROWDATARANGE option to


unify the data ranges across rows in the layout. Because LAYOUT LATTICE specifies
COLUMNS=2 and there are two plot statements in the template, the resulting graph has
two columns and only one row. Thus, only one ROWAXIS statement is needed in the
ROWAXES block to specify axis attributes for that row of graphs. A ROW2AXES block
is not needed because neither SCATTERPLOT statement in the template maps data to
the Y2 axis.
For more information and examples that demonstrate how data are mapped to the axes,
see “Plot Data Are Mapped to a Designated Axis” on page 876 .

Header Statements
Header statements are used to display one or more headers for the columns and rows in a
Lattice layout. Each statement is specified as a block in the form statement -
ENDstatement. The header block is typically used to specify one or more text
statements, but other statements are allowed within the block. For example, you could
specify a LAYOUT GRIDDED statement to produce a grid of text for the header.
The general syntax for a COLUMNHEADERS statement is
COLUMNHEADERS;
GTL-statement(s);
ENDCOLUMNHEADERS;
The following header statements are available:

COLUMNHEADERS specifies a header for the primary (bottom) column-header


position.

COLUMN2HEADERS specifies a header for the secondary (top) column-header


position.

ROWHEADERS specifies a header for the primary (left) row-header position.


ENTRY statements can be used to specify rotated text.

ROW2HEADERS specifies a header for the secondary (right) row-header


position. ENTRY statements can be used to specify rotated
text.

• The LAYOUT LATTICE aligns headers with the columns, or the rows, or both.
• Each of the header blocks COLUMNHEADERS, COLUMN2HEADERS,
ROWHEADERS, and ROW2HEADERS can be used once in a LAYOUT LATTICE
block. If more than one block is specified for one of the statements, then only the last
specified block for that statement is used.
The following example shows a LAYOUT LATTICE block that uses a
COLUMNHEADERS block to display column headers above the left and right columns
in the layout.
134 Chapter 4 • Layout Statements

begingraph;
layout lattice / columns=2;

/* Lattice header definitions */


columnheaders;
entry "Left Column";
entry "Right Column";
endcolumnheaders;

/* cell contents */
scatter x=x y=t;
scatter x=x y=y;

endlayout;
endgraph;

Sidebar Statements
A LAYOUT LATTICE supports the display of a sidebar between a row or column
header and an external axis. (See the figures in “Statement Description” on page 125 .) A
sidebar spans across columns or rows and is useful for displaying information that
applies to all of the columns or all of the rows. For example, sidebars are useful for
displaying legends.
A SIDEBAR statement has the following syntax:
SIDEBAR </option(s)>;
GTL-statement(s);
ENDSIDEBAR;
• You can specify up to four SIDEBAR blocks in a LAYOUT LATTICE, one for each
of the top, bottom, left, and right sidebar positions.
• If two or more SIDEBAR blocks have the same alignment, then the sidebar
information forms two or more columns (ALIGN=LEFT or ALIGN=RIGHT) within
the sidebar area. Or it forms two or more rows (ALIGN=TOP or
ALIGN=BOTTOM) within the sidebar area.
• Only one statement (such as ENTRY or DISCRETELEGEND) or one layout block
(such as LAYOUT GRIDDED) is allowed in a SIDEBAR block. To create multi-line
text in a sidebar, nest ENTRY statements within a LAYOUT GRIDDED block.
• The LAYOUT LATTICE automatically aligns a sidebar with the layout columns or
rows.
The following example shows a LAYOUT LATTICE block that uses a SIDEBAR block
to display a top sidebar in the layout.
begingraph;
layout lattice / columns=2;

sidebar / align=top;
layout gridded / border=true ;
entry "Top Sidebar" ;
entry "(spans both columns)";
endlayout;
endsidebar;

scatterplot x=x y=t;


scatterolot x=x y=y;
Example: LAYOUT LATTICE Statement 135

endlayout;
begingraph;

Example: LAYOUT LATTICE Statement

This example shows a two-cell lattice layout (two columns, one row). A ROWAXES
block is used in the example to make the Y axes external to both cells.
• The ROWDATARANGE=UNION option assures that the data ranges of all Y=
columns in the row cells are considered to construct a common axis range. This
facilitates the visual comparison of the cells.
• A SIDEBAR block is used to place the legend at the top of the lattice.
• Because the ROWAXIS statement within the ROWAXES block uses the
DISPLAYSECONDARY= option, a secondary Y axis is displayed on the right. The
secondary Y axis is not an independent axis. Rather, it mirrors the primary Y axis,
making it easier to read Y-axis values when viewing the bar chart that is in the right
cell.
The following graph was generated by the “Example Program” on page 135 :

Example Program
proc template;
define statgraph layoutlattice;
begingraph;
entrytitle "Vehicle Gas Mileage";
entryfootnote "Averages of 428 models from 38 manufactures";
layout lattice / columns=2 rowdatarange=union;
136 Chapter 4 • Layout Statements

layout overlay / cycleattrs=true;


barchart category=origin response=mpg_highway /
stat=mean barwidth=0.8 name="H" ;
barchart category=origin response=mpg_city /
stat=mean barwidth=0.5 name="C" ;
endlayout;
layout overlay / cycleattrs=true;
barchart category=type response=mpg_highway /
stat=mean barwidth=0.8;
barchart category=type response=mpg_city /
stat=mean barwidth=0.5;
endlayout;
sidebar / align=top;
discretelegend "H" "C" / border=false;
endsidebar;
rowaxes;
rowaxis / display=(tickvalues)
displaysecondary=(tickvalues) griddisplay=on;
endrowaxes;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=layoutlattice;
run;

LAYOUT OVERLAY Statement


Builds a composite from one or more GTL-statements. The composite could be an entire graph. Or, if this
layout is nested in a GRIDDED or LATTICE layout, then the composite typically provides contents for one
cell in the parent layout.
Restrictions: You can add one or more 2-D plots to the graph area that the LAYOUT OVERLAY
statement creates, but all of the graphs will share the same set of axes.
3-D plots are not allowed.
Interaction: When nested within another layout type, the OVERLAY layout defines the graph
display for one cell of the parent layout. A separate OVERLAY layout is specified for
each cell.

Syntax
LAYOUT OVERLAY </option(s)>;
GTL-statements;
<INNERMARGIN </options(s)>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;>
<… more-innermargin-blocks …> >
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
LAYOUT OVERLAY Statement 137

ASPECTRATIO=AUTO | positive-number
specifies the aspect ratio of the plot’s wall area.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
WALLDISPLAY=STANDARD | ALL | NONE | (display-options)
specifies whether the plot’s wall and wall outline are displayed.

Axes options
X2AXISOPTS=(axis-options)
specifies one or more X2 axis options.
XAXISOPTS=(axis-options)
specifies one or more X axis options.
Y2AXISOPTS=(axis-options)
specifies one or more Y2 axis options.
YAXISOPTS=(axis-options)
specifies one or more Y axis options.

Optional Arguments
ASPECTRATIO=AUTO | positive-number
specifies the aspect ratio of the plot’s wall area. The ratio is expressed as a positive
decimal fraction representing wall-height divided by wall-width. For example, 0.75
is a 3/4 aspect ratio and 1.0 is a square aspect ratio.

Default AUTO. The wall area is sized to the maximum area that can fill the
available space inside the OVERLAY layout.

Interaction When the LAYOUT OVERLAY statement is nested in a LAYOUT


LATTICE block, the ASPECTRATIO= option is ignored unless
ROWDATARANGE=DATA, COLUMNDATARANGE=DATA,
ROW2DATARANGE=DATA, and COLUMN2DATARANGE=DATA
are in effect in the LAYOUT LATTICE statement.

See “LAYOUT LATTICE Statement” on page 111

BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
138 Chapter 4 • Layout Statements

style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in nested
plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots. For example, if you
overlay three series plots, then each series line has the same default visual
properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign different
visual properties to applicable plots (scatter plots and series plots and others).
Some plots in the layout do not participate in the cycling (for example, reference
lines and drop lines).

Default FALSE

See “Rotating Visual Attributes for Each Plot in an Overlay” on page 183

“boolean ” on page 1339 for other Boolean values that you can use.

Example In the following example, the first three series plots are assigned line
properties that are based on the GraphData1, GraphData2, and
GraphData3 style elements. The fourth series plot does not participate in
the attribute cycling because its LINEATTRS= option assigns a line style.
layout overlay / cycleattrs=true;
seriesplot x=date y=var1;
seriesplot x=date y=var2;
LAYOUT OVERLAY Statement 139

seriesplot x=date y=var3;


seriesplot x=date y=var4 / lineattrs=GraphReference;
endlayout;

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
140 Chapter 4 • Layout Statements

LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style- attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphWalls:Color style reference.

Interaction This option is ignored if WALLDISPLAY=NONE or


WALLDISPLAY=(OUTLINE).

WALLDISPLAY=STANDARD | ALL | NONE | (display-options)


specifies whether the plot’s wall and wall outline are displayed.
STANDARD
displays a filled wall. The setting of the FRAMEBORDER= attribute of the
GraphWalls style element determines whether the wall outline is displayed.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:

OUTLINE displays the wall outline.


FILL displays a filled wall area.
LAYOUT OVERLAY Statement 141

Default STANDARD

Tips Use the WALLCOLOR= option to control the fill color of the wall.

The appearance attributes of the wall outline are set by the GraphAxisLine
style element.

XAXISOPTS=(axis-options)
specifies one or more X axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY” on page 889 for a list of
axis options.

X2AXISOPTS=(axis-options)
specifies one or more X2 axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY” on page 889 for a list of
axis options.

YAXISOPTS=(axis-options)
specifies one or more Y axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY” on page 889 for a list of
options.

Y2AXISOPTS=(axis-options)
specifies one or more Y2 axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY” on page 889 for a list of
options.
142 Chapter 4 • Layout Statements

Details
The LAYOUT OVERLAY statement builds a composite using one or more GTL-
statements. You can specify one or more two-dimensional plots within the layout,
provided all plots can share the same type of axes. You can also specify one or more
insets, such as nested layout statements (for example, LAYOUT GRIDDED), ENTRY
statements, and legend statements (for example, CONTINUOUSLEGEND or
DISCRETELEGEND).
The following general logic applies to rendering the composite:
Note: The details for positioning insets also apply to insets that are specified within a
LAYOUT REGION block.
• All plot statements are rendered first. Plot statement results are always rendered in
the plot area. The plots are stacked on top of one another in the order in which they
are specified, with the last one on top. It is possible for one plot’s graphical data to
obscure graphical data beneath it. You can control this by selectively ordering the
plot statements, or by using transparency on the individual plots, or by doing both.
• The insets are rendered next, in the order in which they are specified. As with the
plot statements, it is possible for the insets to obscure the results of other statements
in the layout.
• To control the horizontal and vertical positioning of some insets, you can use the
inset statement’s AUTOALIGN= option, or its HALIGN= and VALIGN= options.
Each nested inset determines its own relative position in the parent OVERLAY. This
positioning achieves the best results for text-based insets whose size can be easily fit
within an open area of the graph wall. A large text-based inset might not fit well, and
an inset that contains a plot might be dropped from the display without warning
when the template is executed.
• Some insets, like legends, can be positioned inside or outside of the plot area using
the inset statement’s LOCATION= option. The inset’s AUTOALIGN= or HALIGN=
and VALIGN= settings are then relative to that location.
Generally, the first specified plot determines the layout’s default axis characteristics. To
enable another plot to define the axis characteristics, set PRIMARY=TRUE for that plot.
For more information about the default axis characteristics, see “When Plots Share Data
and a Common Axis” on page 880. See also the LAYOUT OVERLAYEQUATED and
the LAYOUT OVERLAY3D statements.
An overlay layout can also contain an inner margin, which is a nested region at the top or
bottom of the OVERLAY container. One or more inner margin plots can be specified,
and each is specified within an INNERMARGIN block. Within the INNERMARGIN
block, only one-dimensional plot statements such as BLOCKPLOT and AXISTABLE
can be specified. See “INNERMARGIN Statement” on page 166.

Example: Simple Overlay

This example shows how to create a simple overlay of two series plots using the
OVERLAY layout. The following figure shows the output.
Example: Simple Overlay 143

Here is the SAS code.


data workers;
format Date monyy5.;
input Date monyy5. Electric Masonry;
datalines;
JAN80 320.3 293.8
FEB80 315.7 285.8
MAR80 312.6 292
APR80 306.5 299.3
MAY80 308.6 301.7
JUN80 316.3 307.9
JUL80 319.5 310.7
AUG80 326.4 314.9
SEP80 330.8 312.7
OCT80 329.3 318.5
NOV80 330.6 307.7
DEC80 327.2 296.2
JAN81 316.2 259.2
FEB81 310.1 258.8
MAR81 308.5 271.5
APR81 311.1 281
MAY81 313.6 283.7
JUN81 318.3 289.3
JUL81 321.3 291.1
AUG81 327.4 295.9
SEP81 326.7 292.7
OCT81 326.4 282.6
NOV81 322.5 275.5
DEC81 318.6 260.2
JAN82 301.9 214.3
FEB82 296.1 224.8
MAR82 298.3 228.7
144 Chapter 4 • Layout Statements

APR82 297.7 244.7


MAY82 303.5 260.4
JUN82 305 262.2
JUL82 307.6 270.4
;
proc template;
define statgraph layoutoverlay;
begingraph;
entrytitle "Trends in Employment Levels";
layout overlay / cycleattrs=true
xaxisopts=(display=(ticks tickvalues))
yaxisopts=(label="Number of Workers (thousands)");
seriesplot x=date y=electric /
curvelabel="Electrical"
curvelabellocation=outside;
seriesplot x=date y=masonry / curvelabel="Masonry"
curvelabellocation=outside;
endlayout;
endgraph;
end;
run;

proc sgrender data=workers template=layoutoverlay;


run;

LAYOUT OVERLAYEQUATED Statement


Builds a composite from one or more GTL-statements. The composite could be an entire graph. Or, if this
layout is nested in another layout, such as a GRIDDED layout, then the composite typically provides
contents for one cell in the parent layout. In an OVERLAYEQUATED layout, the display unit of the X axis
always equals the display unit of the Y axis.
Restrictions: All overlaid plots share common X and Y axes.
3-D plots are not allowed.
You can add one or more of the following X-Y plots to the graph area that the
LAYOUT OVERLAYEQUATED statement creates: BANDPLOT,
CONTOURPLOTPARM, ELLIPSE, ELLIPSEPARM, HEATMAP, HEATMAPPARM,
LOESSPLOT, NEEDLEPLOT, PBSPLINEPLOT, REGRESSIONPLOT,
SCATTERPLOT, SERIESPLOT, STEPPLOT, or VECTORPLOT. As long as one of
these plots is present, you can also add FRINGEPLOT, LINEPARM, MODELBAND,
REFERENCELINE, DROPLINE, DISCRETELEGEND, CONTINUOUSLEGEND, and
text-based statements such as ENTRY.
This layout has only two independent axes from a data standpoint, X and Y. If any
contained plot uses an X=X2 or Y=Y2 option, then the option is ignored and the data
is mapped to the X or Y axis. However, the X2 and Y2 axes can be displayed using
the DISPLAY2= suboption of the XAXISOPTS= and YAXISOPTS= options.
Interaction: When nested within another layout type, the OVERLAYEQUATED layout defines the
graph display for one cell of the parent layout. A separate OVERLAYEQUATED
layout is specified for each cell.
LAYOUT OVERLAYEQUATED Statement 145

Syntax
LAYOUT OVERLAYEQUATED </option(s)>;
GTL-statements;
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
WALLDISPLAY=STANDARD | ALL | NONE | (display-options)
specifies whether the plot’s wall and wall outline are displayed.

Axes options
COMMONAXISOPTS=(common-axis-options)
specifies one or more options to apply to both the X and Y equated axes.
EQUATETYPE=FIT | SQUARE | SQUAREDATA | EQUATE
specifies how to draw the axis area.
XAXISOPTS=(axis-options)
specifies one or more X axis options.
YAXISOPTS=(axis-options)
specifies one or more Y axis options.

Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.


146 Chapter 4 • Layout Statements

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

COMMONAXISOPTS=(common-axis-options)
specifies one or more options to apply to both the X and Y equated axes.

Requirements Axis options must be enclosed in parentheses.

Each option must be specified as a name = value pair and must be


separated by a space.

See “Options That Apply in Common to Both Equated Axes” on page


1013 for a list of options.

CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in nested
plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots. For example, if you
overlay three series plots, then each series line has the same default visual
properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign different
visual properties to applicable plots (scatter plots and series plots and others).
Some plots in the layout do not participate in the cycling (for example, reference
lines and drop lines).

Default FALSE

See “Rotating Visual Attributes for Each Plot in an Overlay” on page 183

“boolean ” on page 1339 for other Boolean values that you can use.

EQUATETYPE=FIT | SQUARE | SQUAREDATA | EQUATE


specifies how to draw the axis area.
LAYOUT OVERLAYEQUATED Statement 147

FIT
specifies that the X and Y axes have equal increments between tick values. The
data ranges of both axes are compared to establish a common increment size. The
axes might be of different lengths and have a different number of tick marks.
Each axis represents its own data range. One axis might be extended to use
available space in the plot area. If a TICKVALUELIST= or
TICKVALUESEQUENCE= axis option is used on COMMONAXISOPTS= ,
then it is ignored.
SQUARE
specifies that both the X and Y axes have the same length and the same major
tick values. The axis length and tick values are chosen so that the minimum and
maximum of both X and Y appear in the range of values appearing on both axes.
SQUAREDATA
specifies that both the X and Y axes have the same data range, but they can have
different tick values. A UNION of the data ranges does not occur in this case. For
example, if the X axis values are 20 to 40 (range of 20) and the Y axis values are
200 to 260 (range of 60), then both axes have a range of 60 units, but the X axis
can have tick values 0, 20, 40, and 60, and the Y axis can have tick values 200,
220, 240, and 260.
EQUATE
same as FIT except that neither axis is extended to use available space in the plot
area.

Default FIT

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
148 Chapter 4 • Layout Statements

AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.
LAYOUT OVERLAYEQUATED Statement 149

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style- attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphWalls:Color style reference.

Interaction This option is ignored if WALLDISPLAY=NONE or


WALLDISPLAY=(OUTLINE).

WALLDISPLAY=STANDARD | ALL | NONE | (display-options)


specifies whether the plot’s wall and wall outline are displayed.
STANDARD
displays a filled wall. The setting of the FRAMEBORDER= attribute of the
GraphWalls style element determines whether the wall outline is displayed.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:

OUTLINE displays the wall outline.


FILL displays a filled wall area.

Default STANDARD

Tips Use the WALLCOLOR= option to control the fill color of the wall.

The appearance attributes of the wall outline are set by the GraphAxisLine
style element.

XAXISOPTS=(axis-options)
specifies one or more X axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.
150 Chapter 4 • Layout Statements

See “Options That Apply Separately to an X or Y Equated Axis” on


page 1019 for a list of options.

YAXISOPTS=(axis-options)
specifies one or more Y axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Options That Apply Separately to an X or Y Equated Axis” on


page 1019 for a list of options..

Details
The LAYOUT OVERLAYEQUATED statement is similar to the LAYOUT OVERLAY
statement: it builds a composite using one or more GTL-statements. Similar to a
LAYOUT OVERLAY, you can specify one or more 2-D plots within the layout,
provided all plots can share the same type of axes. (Additional restrictions are discussed
in a moment.) You can also specify one or more insets.
As an overlay-type layout, OVERLAYEQUATED has the same behavioral
characteristics as an OVERLAY layout. It uses the same general logic for rendering the
composite (see “LAYOUT OVERLAY Statement” on page 136 for details), and its
default axis characteristics are generally determined by the first specified plot, unless
you use PRIMARY=TRUE on an alternative plot statement (see “When Plots Share Data
and a Common Axis” on page 880).
OVERLAYEQUATED differs from OVERLAY in several ways. With
OVERLAYEQUATED,
• The axis type for both X and Y axes is always linear. Thus, plot types that have
discrete or binned axes cannot be used within this layout (for example, BOXPLOT,
BOXPLOTPARM, BARCHARTPARM, HISTOGRAM, and HISTOGRAMPARM).
• For equal data intervals on both axes, the display distance is the same. For example,
an interval of 2 on the X axis maps to the same display distance as an interval of 2 on
the Y axis.
• The aspect ratio of the plot display equals the aspect ratio of the plot data. In other
words, a 45 degree slope in data is represented by a 45 degree slope in the display.
The EQUATETYPE= option determines how the axes are drawn.
The following figure illustrates how a series plot might map differently when specified
in an OVERLAYEQUATED layout versus an OVERLAY layout:
Example: LAYOUT OVERLAYEQUATED Statement 151

A LAYOUT OVERLAYEQUATED statement enables you to specify one or more of the


following XY plots: SCATTERPLOT, SERIESPLOT, NEEDLEPLOT, STEPPLOT,
VECTORPLOT, BANDPLOT, LOESSPLOT, REGRESSIONPLOT, PBSPLINEPLOT,
and CONTOURPLOTPARM. As long as one of these plots is present, you can also add
FRINGEPLOT, LINEPARM, MODELBAND, REFERENCELINE, DROPLINE, and
insets as ENTRY, DISCRETELEGEND, and CONTINUOUSLEGEND.
From a data standpoint, this layout has only two independent axes, X and Y. If any plots
within the layout block use an XAXIS=X2 or YAXIS=Y2 option, then the option is
ignored and the data are mapped to the X or Y axis. To display X2 and Y2 axes, use the
DISPLAYSECONDARY= suboption of the XAXISOPTS= and YAXISOPTS= options.
If an OVERLAYEQUATED statement is nested in a LATTICE layout, then some of the
LATTICE’s alignment and external axis features are not supported on the
OVERLAYEQUATED layout.

Example: LAYOUT OVERLAYEQUATED Statement

The following graph was generated by the “Example Program” on page 152:
152 Chapter 4 • Layout Statements

Example Program
proc template;
define statgraph layoutoverlayequated;
begingraph;
entrytitle "Gas Mileage for GMC Models";
layout overlayequated / equatetype=fit;
referenceline y=16.2 /
curvelabel="City Average for Trucks/SUVs"
curvelabellocation=inside
curvelabelattrs=GraphReference;
referenceline x=20.6 /
curvelabel="Highway Average for Trucks/SUVs"
curvelabellocation=inside
curvelabelattrs=GraphReference;
scatterplot x=mpg_highway y=mpg_city /
datalabel=model;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars
template=layoutoverlayequated;
where make="GMC";
run;

LAYOUT OVERLAY3D Statement


Builds a 3-D composite from one or more GTL-statements. The composite could be an entire graph. Or, if
this layout is nested in a GRIDDED or LATTICE layout, then the composite typically provides contents for
one cell in the parent layout.
LAYOUT OVERLAY3D Statement 153

Restriction: You can add one or more 3-D plots to the graph area that the LAYOUT OVERLAY3D
statement creates, but all of the graphs will share the same set of axes.

Syntax
LAYOUT OVERLAY3D </option(s)>;
GTL-statements;
ENDLAYOUT;

Summary of Optional Arguments

Appearance options
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CUBE=TRUE | FALSE
specifies whether the layout displays the lines that indicate the complete
bounding cube of the axis planes.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
ROTATE=number
specifies the angle of rotation.
TILT=number
specifies the angle of tilt in degrees.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
WALLDISPLAY=STANDARD | ALL | NONE | (display-options)
specifies whether the plot’s wall and wall outline are displayed.
ZOOM=positive-number
specifies a zoom factor.

Axes options
XAXISOPTS=(axis-options)
specifies one or more X axis options.
YAXISOPTS=(axis-options)
specifies one or more Y axis options.
ZAXISOPTS=(axis-options)
specifies one or more Z axis options.
154 Chapter 4 • Layout Statements

Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

CUBE=TRUE | FALSE
specifies whether the layout displays the lines that indicate the complete bounding
cube of the axis planes.

Default TRUE

Note The cube lines are displayed independently of the wall borders and axis
lines. Because some cube lines coincide with wall borders and axis lines, it
might appear that turning off wall borders or axis lines has no effect when
CUBE=TRUE.

Tip The color, thickness, and pattern of the cube lines are determined by the
GraphAxisLines style element.

See “boolean ” on page 1339 for other Boolean values that you can use.

CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in nested
plot statements automatically change from plot to plot.
LAYOUT OVERLAY3D Statement 155

FALSE
does not cycle the default visual attributes of multiple plots. For example, if you
overlay three series plots, then each series line has the same default visual
properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign different
visual properties to applicable plots (scatter plots and series plots and others).
Some plots in the layout do not participate in the cycling (for example, reference
lines and drop lines).

Default FALSE

See “Rotating Visual Attributes for Each Plot in an Overlay” on page 183

“boolean ” on page 1339 for other Boolean values that you can use.

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO

Note The default units for dimension are pixels.


156 Chapter 4 • Layout Statements

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

ROTATE=number
specifies the angle of rotation. Rotation is measured in a clockwise direction about a
virtual axis parallel to the Z axis (vertical) and passing through the center of the
bounding cube. A counterclockwise rotation can be specified with a negative value.

Default 54

TILT=number
specifies the angle of tilt in degrees. Tilt is measured in a clockwise direction about a
virtual axis parallel to the X axis (vertical) and passing through the center of the
bounding cube. A counterclockwise rotation can be specified with a negative value.

Default 20

WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
LAYOUT OVERLAY3D Statement 157

style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style- attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphWalls:Color style reference.

Interaction This option is ignored if WALLDISPLAY=NONE or


WALLDISPLAY=(OUTLINE).

WALLDISPLAY=STANDARD | ALL | NONE | (display-options)


specifies whether the plot’s wall and wall outline are displayed.
STANDARD
displays a filled wall. The setting of the FRAMEBORDER= attribute of the
GraphWalls style element determines whether the wall outline is displayed.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:

OUTLINE displays the wall outline.


FILL displays a filled wall area.

Default STANDARD

Tips Use the WALLCOLOR= option to control the fill color of the wall.

The appearance attributes of the wall outline are set by the GraphAxisLine
style element.

See the CUBE= option.

XAXISOPTS=(axis-options)
specifies one or more X axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY3D” on page 945 for a list
of axis options.

YAXISOPTS=(axis-options)
specifies one or more Y axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.
158 Chapter 4 • Layout Statements

See “Axis Options for LAYOUT OVERLAY3D” on page 945 for a list
of axis options.

ZAXISOPTS=(axis-options)
specifies one or more Z axis options.

Requirements Axis options must be enclosed in parentheses and separated by


spaces.

Each option must be specified as a name = value pair, and each pair
must be separated by a space.

See “Axis Options for LAYOUT OVERLAY3D” on page 945 for a list
of axis options..

ZOOM=positive-number
specifies a zoom factor. Factors greater than 1 move closer to the bounding cube, less
than 1 move farther away

Default 1

Details
The LAYOUT OVERLAY3D statement builds a 3-D composite using one or more GTL-
statements. You can specify one or more 3-D plots within the layout, provided all plots
can share the same type of axes. You can also specify “annotations” (for example, with
one or more ENTRY statements or LAYOUT GRIDDED statements). However,
annotations in the OVERLAY3D layout are more likely to collide with other graphics
features than are annotations in other overlay-type layouts.
As an overlay-type layout, OVERLAY3D has the same behavioral characteristics as an
OVERLAY layout. It uses the same general logic for rendering the composite (see
“LAYOUT OVERLAY Statement” on page 136 for details), and its default axis
characteristics are generally determined by the first specified plot, unless you use
PRIMARY=TRUE on another plot statement (see “When Plots Share Data and a
Common Axis” on page 880).
Within an OVERLAY3D layout, a graph’s bounding cube can be tilted, rotated, and
zoomed to provide a different viewpoint. By default, the outline of the bounding cube is
displayed and the viewing rotation angle is 57 degrees, the tilt angle is 20 degrees, and
the zoom factor is 1. See the CUBE= , ROTATE= , TILT= , and ZOOM= options for
information about how to change the viewpoint.

Example: LAYOUT OVERLAY3D Statement

The following graph was generated by the “Example Program” on page 159:
LAYOUT PROTOTYPE Statement 159

Example Program
proc template;
define statgraph layoutoverlay3d;
begingraph;
entrytitle "Density Plot of Height and Weight";
layout overlay3d / tilt=10 rotate=54
walldisplay=none cube=false;
surfaceplotparm x=height y=weight z=density /
surfacecolorgradient=density;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.gridded template=layoutoverlay3d;
run;

LAYOUT PROTOTYPE Statement


Builds a composite from one or more plot-statements. The composite is used as a prototype or "rubber
stamp" that repeats in each cell of a parent DATALATTICE or DATAPANEL layout.
Restrictions: You can specify only one LAYOUT PROTOTYPE block in a LAYOUT DATAPANEL or
LAYOUT DATALATTICE block. If you specify more than one, then only the last
prototype block specified is honored. The remaining prototype blocks are ignored.
Only the following plots can be used in a LAYOUT PROTOTYPE block: BANDPLOT,
BARCHART, BARCHARTPARM, BLOCKPLOT, BOXPLOTPARM,
COUNTOURPLOTPARM, DROPLINE, ELLIPSEPARM, FRINGEPLOT,
HEATMAPPARM, HISTOGRAMPARM, LINECHART, LINEPARM, NEEDLEPLOT,
REFERENCELINE, SCATTERPLOT, SERIESPLOT, STEPPLOT, and
VECTORPLOT.
160 Chapter 4 • Layout Statements

SCATTERPLOTMATRIX plots, 3-D plots, and region plots such as PIECHART or


MOSAICPLOTPARM cannot be used in the LAYOUT PROTOTYPE block.
ENTRY, DISCRETELEGEND, and CONTINUOUSLEGEND statements cannot be
used in the LAYOUT PROTOTYPE block.
A plot statement cannot be used if it contains a column defined with an EVAL
expression.
You can add one or more two-dimensional plots and one-dimensional plots to the
graph area that the LAYOUT PROTOTYPE statement creates, provided all of the
graphs can share the same axis type.
If you include a plot statement with a CURVELABEL= option (such as
SERIESPLOT), then only CURVELABELLOCATION=INSIDE is supported.
If you include a plot statement that supports a CLIP= option (such as LINEPARM or
ELLIPSEPARM), then the CLIP value is always set to TRUE.
Requirement: The LAYOUT PROTOTYPE statement must be nested in a LAYOUT DATAPANEL or
LAYOUT DATALATTICE block.
Note: Nesting an INNERMARGIN block in the LAYOUT PROTOTYPE statement is valid in
the first maintenance release of SAS 9.4 and later releases.
See: “LAYOUT DATAPANEL Statement” on page 70
“LAYOUT DATALATTICE Statement” on page 45

Syntax
LAYOUT PROTOTYPE </option(s)>;
plot-statements;
<INNERMARGIN </options(s)>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;>
<… more-innermargin-blocks …> >
ENDLAYOUT;

Optional Arguments
ASPECTRATIO=AUTO | positive-number
specifies the aspect ratio of the prototype cell. The ratio is expressed as a positive
decimal fraction representing wall-height divided by wall-width. For example, 0.75
is a 3/4 aspect ratio and 1.0 is a square aspect ratio.

Default AUTO. The prototype cell is sized to the maximum area that can fill the
available space inside the layout cell.

Note If AUTO is not used for the aspect ratio, then the entire DATALATTICE or
DATAPANEL grid is affected and changes shape.

CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in nested
plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots. For example, if you
overlay three series plots, then each series line has the same default visual
properties.
LAYOUT PROTOTYPE Statement 161

TRUE
attempts to use the GraphData1–GraphDataN style elements to assign different
visual properties to applicable plots (scatter plots and series plots and others).
Some plots in the layout do not participate in the cycling (for example, reference
lines and drop lines).

Default FALSE

See “Rotating Visual Attributes for Each Plot in an Overlay” on page 183

“boolean ” on page 1339 for other Boolean values that you can use.

WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style- attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphWalls:Color style reference.

Interaction This option is ignored if WALLDISPLAY=NONE or


WALLDISPLAY=(OUTLINE).

WALLDISPLAY=STANDARD | ALL | NONE | (display-options)


specifies whether the plot’s wall and wall outline are displayed.
STANDARD
displays a filled wall. The setting of the FRAMEBORDER= attribute of the
GraphWalls style element determines whether the wall outline is displayed.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:

OUTLINE displays the wall outline.


FILL displays a filled wall area.

Default STANDARD

Tips Use the WALLCOLOR= option to control the fill color of the wall.

The appearance attributes of the wall outline are set by the GraphAxisLine
style element.

When the wall outline is suppressed, adjacent lines such as axis lines and
cell-header borders are still displayed. To suppress the axis lines, use the
appropriate display option for the axes. The cell-header borders cannot be
suppressed.
162 Chapter 4 • Layout Statements

Details
The LAYOUT PROTOTYPE statement defines a plot prototype or “rubber stamp” that
repeats automatically. It assembles the results of nested GTL statements into a single
axis area. The plots are drawn in the order in which they are specified. The results of the
last statement are placed on top.
The plot-statements determine the graphical content of the cells in the parent layout,
based on the subsetting of the specified classification variables. For an example, see
“LAYOUT DATALATTICE Statement” on page 45 or “LAYOUT DATAPANEL
Statement” on page 70.
A PROTOTYPE layout is essentially a restricted OVERLAY layout with the same
general rules for overlaying plots. The main difference is that there are no axis options
available on the LAYOUT PROTOTYPE statement. Axis properties are set with the
ROWAXISOPTS= and COLUMNAXISOPTS= options of the parent DATAPANEL or
DATALATTICE statement.
In SAS 9.4 and later releases, a PROTOTYPE layout can also contain an inner margin,
which is a nested region at the top or bottom of the PROTOTYPE container. One or
more inner margin plots can be specified, and each is specified within an
INNERMARGIN block. Within the INNERMARGIN block, only one-dimensional plot
statements such as BLOCKPLOT and AXISTABLE can be specified. See
“INNERMARGIN Statement” on page 166.

LAYOUT REGION Statement


Creates the drawing area for a plot that does not use axes.
Restrictions: A LAYOUT REGION block cannot contain more than one plot.
A LAYOUT REGION block can contain a PIECHART or MOSAICPLOTPARM plot
only.

Syntax
LAYOUT REGION </option(s)>;
GTL-statements;
ENDLAYOUT;

Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attribute named COLOR or CONTRASTCOLOR is used.

Default The GraphBackground:Color style reference.

Interaction OPAQUE=TRUE must be in effect for the color to be seen. By default,


OPAQUE=FALSE.

BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
LAYOUT REGION Statement 163

Default FALSE

Interaction If this option is set to FALSE, then the BORDERATTRS= option is


ignored.

See “boolean ” on page 1339 for other Boolean values that you can use.

BORDERATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the border line around the layout.

Default The GraphBorderLines style element.

Interaction BORDER= TRUE must be set for this option to have any effect.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent (FALSE).

Default FALSE

Interaction When this option is set to FALSE, the background color is not used.

See “boolean ” on page 1339 for other Boolean values that you can use.

OUTERPAD=AUTO | dimension | (pad-options)


specifies the amount of extra space to add outside the layout border.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value pair options,
enclosed in parentheses:

LEFT=dimension specifies the amount of extra space to add to the


left side.
RIGHT=dimension specifies the amount of extra space to add to the
right side.
TOP=dimension specifies the amount of extra space to add to the
top.
BOTTOM=dimension specifies the amount of extra space to add to the
bottom.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Default AUTO
164 Chapter 4 • Layout Statements

Note The default units for dimension are pixels.

See “dimension” on page 1340

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 0

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

Details
The REGION layout provides a container for plots that do not use axes. Within the
LAYOUT REGION block, you can specify a single plot statement of a type that never
uses axes, such as a PIECHART or MOSAICPLOTPARM. If multiple plot statements
are specified, then only the first one is honored. You can also specify one or more insets,
such as nested layout statements (for example, LAYOUT GRIDDED), ENTRY
statements, and legend statements (CONTINUOUSLEGEND or DISCRETELEGEND).
For example, you could specify a PIECHART statement with a DISCRETELEGEND
statement and an ENTRY statement. You can also nest one or more layout blocks within
the REGION layout. For example, you could nest a LAYOUT GRIDDED statement that
creates a small table of text.
Example: LAYOUT REGION Statement 165

When nested within another layout type, such as a GRIDDED or LATTICE layout, the
REGION layout defines the graphical display for one cell of the parent layout. A
separate REGION layout is specified for each cell.

Example: LAYOUT REGION Statement

The following graph was generated by the “Example Program” on page 165:

Example Program
proc template;
define statgraph layoutregion;
begingraph;
entrytitle "Average Weight by Age";
layout region;
piechart category=age response=weight /
stat=mean name="p"
datalabelcontent=(response) datalabellocation=outside;
discretelegend "p" / title="Age" across=2
border=true halign=right valign=top;
endlayout;
endgraph;
end;

proc sgrender data=sashelp.class template=layoutregion;


run;
166 Chapter 4 • Layout Statements

INNERMARGIN Statement
Provides a nested region in a LAYOUT OVERLAY or LAYOUT PROTOTYPE container in which a block
plot or axis table can be placed.
Restriction: This statement is valid in LAYOUT OVERLAY and LAYOUT PROTOTYPE blocks
only.
Notes: Two or more INNERMARGIN blocks that have the same alignment are stacked.
Multiple statements within an INNERMARGIN block are stacked.
For an X axis, the offsets on each end of the Y axis are increased to make room for
the inner margin plots. For a Y axis, the offsets on each end of the X axis are
increased to make room for the inner margin plots.

Syntax
INNERMARGIN < /option(s)>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;

Optional Arguments
ALIGN=TOP | BOTTOM | LEFT | RIGHT
specifies the alignment of the inner margin.

Default BOTTOM

Restrictions For a block plot, only TOP and BOTTOM are valid. LEFT and
RIGHT are ignored.

For an axis table, LEFT and RIGHT can be used for a Y or Y2 axis.

Multiple statements within an INNERMARGIN block are stacked.

Note For an inner margin with ALIGN=TOP or ALIGN=BOTTOM, the


offsets on each end of the Y axis are increased to reserve space for the
inner margin plots. For an inner margin with ALIGN=LEFT or
ALIGN=RIGHT, the offsets on each end of the X axis are increased to
reserve space for the inner margin plots.
INNERMARGIN Statement 167

BACKGROUNDCOLOR=style-reference | color
specifies the color of the inner margin background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the style
attributes named COLOR or CONTRASTCOLOR are used.
color
specifies a color.

See color on page 1340

Default The graph wall color. (See WALLCOLOR=.)

Interaction For this option to have any effect, the OPAQUE= option must be set to
TRUE.

Note The inner margin background is set to the wall color even when
WALLDISPLAY= NONE.

GUTTER=dimension
specifies the gap between stacked items in the inner margin.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default 0

Requirement The inner margin must contain two or more stacked items for this
option to have any effect.

Note The default units for dimension are pixels.

See “dimension” on page 1340

OPAQUE=TRUE | FALSE
specifies whether the inner margin's background is opaque.

TRUE specifies that the background is opaque.


FALSE specifies that the background is transparent.

Default FALSE

Interaction When this option is FALSE, the BACKGROUNDCOLOR= option is


ignored.

Tip To prevent axis color bars and grid lines from passing through the axis
table, set OPAQUE=TRUE.

See “boolean ” on page 1339 for other Boolean values that you can use.

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the inner-margin border.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
168 Chapter 4 • Layout Statements

dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 0

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 0

TOP=dimension
specifies the amount of extra space added to the top.

Default 5 px for the first inner margin adjacent to the bottom of the plot
area. Otherwise, 0.

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 5 px for the first inner margin adjacent to the top of the plot area.
Otherwise, 0.

Note Sides that are not assigned padding are padded with the default amount.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

SEPARATOR=TRUE | FALSE
specifies whether a separating line is drawn between the inner margin and the rest of
the layout content.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.

Default FALSE

Tip Use the SEPARATORATTRS= option to specify the attributes of the


separating line.

See “Example: Overlay with an Inner Margin Plot” on page 169

“boolean ” on page 1339 for other Boolean values that you can use.

SEPARATORATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the inner margin separating line.
Note: This option is valid in the first maintenance release of SAS 9.4 and later
releases.
Example: Overlay with an Inner Margin Plot 169

Default The graphAxisLines style element

Interaction This option is ignored when SEPARATOR=FALSE.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

“Example: Overlay with an Inner Margin Plot” on page 169

Details
An inner margin is a nested region in an OVERLAY container. You can specify one or
more inner margin plots. Specify each plot within an INNERMARGIN block. Within an
INNERMARGIN block, you can specify only the BLOCKPLOT and AXISTABLE
statements. See “Example: Overlay with an Inner Margin Plot” on page 169.

Example: Overlay with an Inner Margin Plot

Example Overview
This example shows how to place a plot in an inner margin of an OVERLAY layout. It
creates a graph that shows monthly total sales for a specific year. A LINECHART
statement is used to draw the plot. The months are shown along the category axis, and
the total sales values are shown along the response axis. The Sashelp.Prdsale data set is
used as the data source. The tick marks on the category axis are positioned between the
midpoints to align with the beginning of each month.
A BLOCKPLOT statement in an INNERMARGIN block is used to display the quarters
above the category axis. The INNERMARGIN statement uses the default alignment, so
the inner margin is positioned at the bottom of the layout container, beneath the line
chart. Alternate shading is used in the block plot to show the block boundaries. Because
the tick marks are positioned between the midpoints, they align with the block
boundaries. The SEPARATOR= and SEPARATORATTRS= options are used in the
INNERMARGIN statement to specify a dark-red, two-pixel-wide separator line between
the inner margin and the rest of the graph.
Note: The INNERMARGIN statement SEPARATOR= and SEPARATORATTRS=
options are valid in the first maintenance release of SAS 9.4 and later releases.
170 Chapter 4 • Layout Statements

Example Output
Here is the output for this example.

Example Program
Here is the SAS code.
/* Create a format for the quarters */
proc format;
value quartername 1="Quarter 1" 2="Quarter 2"
3="Quarter 3" 4="Quarter 4";
run;

/* Define the graph template */


proc template;
define statgraph innermargin;
dynamic year;
begingraph / subpixel=on;
entrytitle "Total Sales in " year;
layout overlay /
xaxisopts=(type=discrete discreteopts=(ticktype=inbetween));
innermargin /
separator=true
separatorattrs=(color=darkred thickness=2px);
blockplot x=month block=quarter /
filltype=alternate
fillattrs=(color=cxd7d7d7)
altfillattrs=(color=cxf7f7f7)
display=(fill values) valuehalign=center;
endinnermargin;
linechart category=month response=actual /
smoothconnect=true;
endlayout;
endgraph;
end;
run;

/* Generate the graph */


proc sgrender data=sashelp.prdsale template=innermargin;
format quarter quartername.;
Example: Overlay with an Inner Margin Plot 171

where year=1994;
dynamic year=1994;
run;
172 Chapter 4 • Layout Statements
173

Part 4

Plot Statements

Chapter 5
Key Concepts for Using Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Chapter 6
Plot Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
174
175

Chapter 5
Key Concepts for Using Plots

Minimum Requirements to Generate a Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175


ODS Graphics Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Display Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Display Attributes for Non-Grouped Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Display Attributes for Grouped Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Rotating Visual Attributes for Each Plot in an Overlay . . . . . . . . . . . . . . . . . . . . . 183
Remapping Groups for Grouped Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Interactions between Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Location and Position of Curve Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Curve Label Location Relative to the Plot Area . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Curve Label Position Relative to the Curve Line . . . . . . . . . . . . . . . . . . . . . . . . . . 186

Minimum Requirements to Generate a Plot


ODS graphics are generated by template definitions that determine a graph’s layout and
appearance and specify the variable roles to be represented in the graph display. A graph
can be rendered from a compiled template by associating the template with a data source
at run time.
The following SAS program shows the basic structure needed to meet the minimum
requirements for generating a plot using GTL:
proc template;
define statgraph minimumreq;
begingraph;
layout overlay;
scatterplot x=weight y=height;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.class template=minimumreq;


run;
176 Chapter 5 • Key Concepts for Using Plots

• The DEFINE STATGRAPH statement on PROC TEMPLATE is required to open a


definition block for defining and naming a graphics template. The END statement
closes the template definition.
• A BEGINGRAPH statement block is required to define the outermost container for
the graph. The ENDGRAPH statement closes the block.
• At least one layout statement block is required for specifying the elements that
compose the graph. To generate a plot, the layout block must contain at least one plot
statement. The ENDLAYOUT statement closes the layout block.
• The PROC TEMPLATE statement must be run to compile the template and save it in
the template store (Sasuser.Templat by default).
• The PROC SGRENDER statement is required to produce a graph from a compiled
template. The DATA= option specifies a run-time data source to use, and the
TEMPLATE= option specifies the template to use. The input data source must satisfy
any restrictions that are imposed by the template. For example, it must contain any
variables that have been specified on the template’s GTL statements.

ODS Graphics Environment


The ODS GRAPHICS statement manages the settings of the ODS Graphics environment
and is a statement that you will probably use frequently in your SAS sessions. For
example, the ODS GRAPHICS statement provides options that control the physical
aspects of your graphs, such as the image size and the name of the image file that is
created for the graph.
The default image size of 640 pixels by 480 pixels (4:3 aspect ratio) for ODS Graphics is
set in the SAS Registry. You can change the image size using the WIDTH= option, or
the HEIGHT= option, or both in the ODS GRAPHICS statement. To name the output
image file, use the IMAGENAME= option.
The following ODS GRAPHICS statement sets a 320 pixel width for the graph and
names the output image file modelfit:

ods graphics / width=320px


imagename="modelfit" reset;

proc sgrender data=sashelp.class template=modelfit;


run;

ods graphics off;

• The WIDTH= option sets the image width to 320 pixels. Because no HEIGHT=
option is used, SAS uses the design aspect ratio of the graph to compute the
appropriate height. (The width of 320px is half the default width, so SAS sets the
height to 240px, which is half the default height.)
• The IMAGENAME= option sets the name of the output image file to modelfit. The
RESET option ensures that each time the graph is produced, the previous version of
the image file is replaced. Otherwise, image names are incremented (modelfit1,
modelfit2, and so on) every time the graph is produced.
In general, it is good practice to specify only one sizing option without the other—just
the WIDTH= option or just the HEIGHT= option. That way SAS can maintain the
design aspect ratio of the graph, which might be important for many graphs. For
Display Attributes 177

example, a graph that has multiple columns or a statistics table on the side needs a wide
aspect ratio. Specifying both width and height in such cases might produce unpredictable
results.
Note: Size settings in the ODS GRAPHICS statement affect all of the graphs that are
rendered in the SAS session, unless they are changed by another ODS GRAPHICS
statement. The size for a graph produced by an individual template can be set with
the DESIGNWIDTH= and DESIGNHEIGHT= options in the BEGINGRAPH
statement. Size settings in the ODS GRAPHICS statement override size settings in
the BEGINGRAPH statement and remain in effect unless they are changed in
another ODS GRAPHICS statement or ODS GRAPHICS are turned off.
For more information about using the ODS GRAPHICS statement in GTL, see SAS
Graph Template Language: User's Guide. For a more complete discussion of the ODS
GRAPHICS statement, see “ODS GRAPHICS Statement” in SAS ODS Graphics:
Procedures Guide.

Display Attributes

Overview
The display attributes for the lines, colors, marker symbols, and text used in a graph are
derived from the ODS style that is in effect when the graph is produced. These display
attributes might also be influenced by grouped data. To override default display
attributes, all GTL plot statements provide options that manage the graph’s visual
appearance. For example, a BOXPLOT statement provides an OUTLIERATTRS=
option that manages the visual appearance of outliers.
Two ways are generally available for modifying a graph’s display attributes:
• Change the ODS style that is in effect for the graph. “ODS Styles” on page 16
provides an overview of the use of styles in a graph. SAS Graph Template Language:
User's Guide discusses the use of styles in more detail.
• Override default style settings using GTL statement options. Some examples are
given in the sections that follow.

Display Attributes for Non-Grouped Data


Appendix 3, “Display Attributes,” on page 1347 documents the attribute settings that can
be specified for the lines, data markers, text, or area fills in a plot. The defaults for these
attributes are defined on style elements, but you can use attribute options on the plot
statement to change the defaults.
For example, the LINEPARM statement provides a LINEATTRS= option that specifies
the color, line pattern, or line thickness of the plot line. For non-grouped data, if you do
not set a line pattern in your template, then the default line pattern for the plot is
obtained from the GraphDataDefault:LineStyle style reference.
To change the default line pattern, a PATTERN= suboption on LINEATTRS= is
available. Figure 5.1 on page 178 shows the most common line patterns available for the
PATTERN= suboption.
178 Chapter 5 • Key Concepts for Using Plots

Figure 5.1 "Common Line Patterns"

• the left column shows the names for the line patterns
• the center column illustrates the type of line the name requests
• the right column shows the SAS line-style numbers for the line patterns
“Available Line Patterns” on page 1352 provides the complete list of line patterns that
can be used with the GTL.
In the following template definition, the LINEPARM statement’s LINEATTRS= option
overrides the default line pattern by specifying PATTERN=DASH:
proc template;
define statgraph patternchange;
begingraph;
layout overlay;
scatterplot y=height x=weight;
lineparm yintercept=intercept slope=slope /
lineattrs=(pattern=dash);
endlayout;
endgraph;
end;

Other display options can be managed the same way. For example, the SCATTERPLOT
statement provides a MARKERATTRS= option that specifies the color, size, symbol,
and weight of the plot data markers. For non-grouped data, if you do not set a marker
symbol in your template, then the default marker symbol is obtained from the
GraphDataDefault:MarkerSymbol style reference.
To change the default marker symbol, a SYMBOL= suboption on MARKERATTRS= is
available. Figure 5.2 on page 179 shows the marker symbols available for the
SYMBOL= suboption.
Display Attributes 179

Figure 5.2 "Marker Symbols"

In the following template definition, the SCATTERPLOT statement’s


MARKERATTRS= option overrides the default marker symbol by specifying
SYMBOL=CIRCLEFILLED, which uses a filled circle to represent the data points.
proc template;
define statgraph symbolchange;
begingraph;
layout overlay;
scatterplot y=height x=weight /
markerattrs=(symbol=circlefilled);
endlayout;
endgraph;
end;

Display Attributes for Grouped Data


Appendix 3, “Display Attributes,” on page 1347 documents the attribute settings that you
can specify for the lines, data markers, text, or area fills in a plot. For a grouped plot
(that is, when you use the GROUP= option in the plot statement), each distinct group
value can be represented in the graph by a different combination of line pattern, color,
and marker symbol (depending on the graph type). The defaults for these features are set
by the LineStyle, Color, ContrastColor, FillPattern, and MarkerSymbol attributes of the
GraphData1–GraphDataN style elements.
Note: The MarkerSize and LineThickness style attributes are not honored in the case of
grouped data.
When missing group values are displayed, the default attributes of the missing value are
set by the GraphMissing style element unless the MISSING= system option specifies a
character other than "." or " ". In that case, missing group value attributes are determined
by the GraphData1–GraphDataN style elements.
Figure 5.1 on page 178 shows the common line patterns available, and Figure 5.2 on
page 179 shows the marker symbols available.
For grouped plots, attributes such as colors, line patterns, and marker symbols are used
to distinguish the individual group values. The attributes are derived from the
GraphData1–GraphDataN style elements in the current style. The attributes are rotated
to provide distinct visual characteristics for each group value. For information about
attribute rotation, see “Attribute Rotation Patterns” in SAS Graph Template Language:
User's Guide. As discussed in “Rotating Visual Attributes for Each Plot in an Overlay”
on page 183, plot options might also influence the attribute rotation pattern.
180 Chapter 5 • Key Concepts for Using Plots

You can use attribute options on the plot statement to change the default display
attributes used for group data. For example, in the following template definition, the
LINEPARM statement’s LINEATTRS= option specifies PATTERN=DASH. This
explicit setting overrides the default line pattern for the plot lines and uses dashed lines
for all of the plots, leaving color to distinguish among group values.
proc template;
define statgraph dashedline;
begingraph;
layout overlay;
scatterplot y=height x=weight / group=gender;
lineparm yintercept=intercept slope=slope / group=gender
lineattrs=(pattern=dash);
endlayout;
endgraph;
end;

Rather than setting the same line pattern on all group values, you can change the default
sequence of line patterns that is used for grouped values. To do so, set the LineStyle
attribute in some of the style elements GraphData1–GraphDataN.
In the following example, a style is defined to change the line pattern for GraphData1
and GraphData2. In this example, the style is derived from the DEFAULT style. Values
are set for the LineStyle attributes in the GraphData1 and GraphData2 style elements.
The first default line in the sequence has long dashes (style value 6) and the second line
has short dashes (style value 4). The LineStyle settings for the remaining GraphData
elements are not set, so are derived from the parent style (DEFAULT). This new line
sequence is used as the default line sequence for any plot that uses the MyDefault style.
To apply the style to a graph, the STYLE= option is used in the ODS HTML statement
to specify the style name.
Here is the code for this example.
/* Specify a path for the ODS output */
filename odsout "output-path";

/* Sort the SASHELP.CLASS data by sex and age. */


proc sort data=sashelp.class(keep=height weight sex age)
out=class;
by sex age;
run;

/* Generate slope and intercept data for plot reference lines. */


proc robustreg data=class method=m
plots=none
outest=stats(rename=(weight=slope));
by sex;
model height=weight;
run;

data class;
merge class stats(keep=intercept slope sex);
run;

proc template;
/* Create custom style MYDEFAULT from the STYLES.DEFAULT style. */
define style MyDefault;
parent=Styles.Default;
Display Attributes 181

style GraphData1 from GraphData1 /


LineStyle=6;
style GraphData2 from GraphData2 /
LineStyle=4;
end;

/* Create the plot template. */


define statgraph testPattern;
begingraph;
layout overlay;
scatterplot y=height x=weight / group=sex;
lineparm x=0 y=intercept slope=slope / group=sex name="lines";
discretelegend "lines";
endlayout;
endgraph;
end;
run;

/* Generate the plot. */


ods _all_ close;
ods html path=odsout file="mydefaultstyle.html"
style=MyDefault; /* Apply style MyDefault to the graph. */

proc sgrender data=class template=testPattern;


run;

ods html close;


ods html; /* Not required in SAS Studio */

Here is the output.

Similarly, for grouped data, you can set the MarkerSymbol attribute in each of the style
elements GraphData1–GraphDataN. In the following example, a style is defined to
change the MarkerSymbol attribute for GraphData1–GraphData3. This new sequence is
used as the default marker symbol sequence for any grouped plot that uses the
MyDefault style.
Here is the code for this example.
182 Chapter 5 • Key Concepts for Using Plots

Note: The data that was generated in the previous example is used again in this
example.
/* Specify a path for the ODS output */
filename odsout "output-path";

proc template;
/* Create custom style MYDEFAULT from STYLES.DEFAULT. */
define style MyDefault;
parent=Styles.Default;
style GraphData1 from GraphData1 /
MarkerSymbol="DIAMOND";
style GraphData2 from GraphData2 /
MarkerSymbol="CROSS";
style GraphData3 from GraphData3 /
MarkerSymbol="CIRCLE";
end;

/* Create the plot template. */


define statgraph testSymbols;
begingraph;
layout Overlay;
scatterPlot y=height x=weight / group=age name="symbols";
discretelegend "symbols" / title="Age";
endlayout;
endgraph;
end;
run;

/* Generate the plot. */


ods _all_ close;
ods html path=odsout file="mydefaultstyle.html"
style=MyDefault; /* Apply style MyDefault to the graph. */

proc sgrender data=class template=testSymbols;


run;
Display Attributes 183

Rotating Visual Attributes for Each Plot in an Overlay


Overlay-type layouts provide the CYCLEATTRS= option, which specifies whether the
default visual attributes of lines, marker symbols, and area fills in nested plot statements
automatically change from plot to plot. When CYCLEATTRS=TRUE, all applicable plot
statements (SCATTERPLOT, SERIESPLOT, and others) are sequentially assigned the
next unused GraphDataN style element. (The sequence is overridden for plot statements
that have an explicit setting, either through a style element assignment or option
settings.) No plot retains its default (implicit) style element.
In the following example, assuming ungrouped data and the default attribute rotation
pattern, the series plots are assigned line properties based on the GraphData1,
GraphData2, and GraphData3 style elements. The reference line uses GraphReference,
not GraphData4.

layout overlay / cycleattrs=true;


seriesplot x=date y=var1;
seriesplot x=date y=var2;
seriesplot x=date y=var3;
referenceline x=cutoff / lineattrs=GraphReference;
endlayout;

If one of the plots in this example uses grouped data, then the grouped plots also
participate in the default cycles. For example, if the second plot has three groups, then it
generates three plots, which are assigned line properties based on the GraphData2,
GraphData3, and GraphData4 style elements.
If the plot statement that uses grouped data also uses the INDEX= option to manage the
group values (see “Remapping Groups for Grouped Data” on page 183), then the
INDEX= option overrides the default behavior. In that case, the grouped plots do not
participate in the default cycling.
When one or more of the plots within the layout override the default cycling behavior,
the arrangement of the plots within the layout might affect the default mapping of the
GraphDataN elements to those statements that participate in the default cycling.

Remapping Groups for Grouped Data


Indexing can be used to collapse the number of groups that are represented in a graph.
For example, if 10 groups are in the data, then indexes 1 and 2 can be assigned to the
first two groups, and index 3 can be assigned to all other groups. The third through tenth
data groups are treated as a single group in the graph.
Indexing can control the order in which colors, area fills, marker symbols, and line styles
are mapped to group values in a graph. This ordering method is needed only for
coordinating the data display of multiple graphs when the default mapping would cause
group values to be mismatched between graphs.
For example, consider two studies of three drugs, A, B, and C. If Study 1 uses all three
drugs, then the first combination of color and marker symbol is mapped to Drug A. The
second combination of color and marker symbol is mapped to Drug B, and the third is
mapped to Drug C. If Study 2 omits Drug A, then the first combination of color and
marker symbol is mapped to Drug B, and the second is mapped to Drug C. If the two
graphs are viewed together, then this default mapping causes the group values to be
mismatched. The visual attributes that represent Drug A in the first graph represent Drug
184 Chapter 5 • Key Concepts for Using Plots

B in the second graph. Those that represent Drug B in the first graph represent Drug C in
the second group.
The GROUP= option mappings can be made consistent between the two graphs by
creating an index column for each study. For these example studies, the GROUP and
INDEX columns are the following:

Table 5.1 Study 1

Drug1 Index1

A 1

B 2

B 2

C 3

Table 5.2 Study 2

Drug2 Index2

B 2

C 3

C 3

If the graph for Study 1 specifies INDEX=INDEX1 and the graph for Study 2 specifies
INDEX=INDEX2, then the second combination of color and marker symbol is mapped
to Drug B in both graphs. The third combination of color and marker symbol is mapped
to Drug C in both graphs.

Interactions between Options


When you use GTL statement options to manage the graph display, interactions between
options might cause some option settings to be ignored. For example, an ENTRYTITLE
statement provides BORDER= and BORDERATTRS= options for managing a border
line around the graph title. Border attributes that are set on the BORDERATTRS= option
have no effect on the graph title unless the title border line is displayed by setting
BORDER=TRUE.
Similarly, if a BOXPLOT statement’s DISPLAY= option suppresses the display of
outliers in a box plot, then using the OUTLIERATTRS= option to set outlier attributes
has no effect. The OUTLIERATTRS= settings only take effect if DISPLAY= enables the
display of outliers.
The option interactions are not limited to options that simply manage visual elements.
For example, on a BOXPLOT, if the EXTREME= option extends the box whiskers
beyond the fences, then outliers are suppressed in the plot and options that affect the
outliers are ignored, if set.
Location and Position of Curve Labels 185

The documentation for each GTL statement identifies the option interactions that might
occur on that statement.

Location and Position of Curve Labels

Overview
On plots that generate a curve line (a series plot or a density plot, for example), you can
specify a label for the curve line. You can also determine the label’s location in the
graph. For example, the SERIESPLOT statement provides the following options for
managing a curve label:
CURVELABEL
specifies a label for the curve line.
CURVELABELLOCATION
specifies the location of the curve line label relative to the plot area.
CURVELABELPOSITION
specifies the position of the label relative to the curve line.

Curve Label Location Relative to the Plot Area


By default, the label for a curve line is displayed inside the plot area. The following
figure shows the default location of the label for a series plot labeled “Curve Label”:

Depending on the shape of the curve line, its distribution of values, and the other plot
elements that must be displayed within the plot area, GTL might have to add an offset
(see “Adjusting Axis Offsets” on page 886) to one of the plot’s axis lines to provide
enough room for the curve label. To prevent the offset of the axis line, you can move the
curve label outside of the plot area by specifying
CURVELABELLOCATION=OUTSIDE on the plot statement:
186 Chapter 5 • Key Concepts for Using Plots

Regardless of whether the curve label is displayed inside or outside of the plot area, you
can use the CURVELABELPOSITION= option to adjust the label’s position relative to
the curve line.

Curve Label Position Relative to the Curve Line


Given a curve label’s location inside or outside of the plot area, a plot statement’s
CURVELABELPOSITION= option can adjust the label’s position relative to the curve
line. For example, the following positions are available for a series plot (for some plots,
START and END are not available):
AUTO
positions the curve label automatically near the end series line along unused axes
whenever possible (typically Y2 or X2) to avoid collision with tick values. This
position is used only when CURVELABELLOCATION=OUTSIDE.
MAX
forces the curve label to appear near maximum series values (typically, to the right).
MIN
forces the curve label to appear near minimum series values (typically, to the left).
START
forces the curve label to appear near the beginning of the curve. This position is
particularly useful when the curve line has a spiral shape. It is used only when
CURVELABELLOCATION=INSIDE.
END
forces the curve label to appear near the end of the curve. This position is
particularly useful when the curve line has a spiral shape. It is used only when
CURVELABELLOCATION=INSIDE.
When CURVELABELLOCATION=INSIDE, you can choose whether to position the
curve label near the START or END of the curve, or near the minimum data values
(MIN) or maximum data values (MAX). START and END use a different algorithm than
MIN and MAX. They are particularly useful for spiral-shaped curves whose end points
do not correlate with the minimum and maximum data values. In those cases, START or
END provide “better” label locations than MIN and MAX.
When CURVELABELLOCATION=OUTSIDE and CURVELABELPOSITION=AUTO,
a “good” position is automatically chosen to avoid collision with the axis information.
The following figure shows the different combinations of label locations and positions:
Location and Position of Curve Labels 187

• The minimum or maximum axis tick marks can be adjusted (see “Adjusting Axis
Offsets” on page 886) so that the label can be placed inside the plot area. Increasing
label length decreases the area available for displaying plots.
• When CURVLABELLOCATION=OUTSIDE, you can set the
CURVELABELPOSITION to MIN or MAX, but the label might collide with the
axis ticks and tick values, unless you are aware of where the axes are positioned.
188 Chapter 5 • Key Concepts for Using Plots
189

Chapter 6
Plot Statements

Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
AXISTABLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
BANDPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
BARCHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
BARCHARTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
BIHISTOGRAM3DPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
BLOCKPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
BOXPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
BOXPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
BUBBLEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
CONTOURPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
DENDROGRAM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
DENSITYPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
DROPLINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
ELLIPSE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
ELLIPSEPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
FRINGEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
HEATMAP Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
HEATMAPPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
HIGHLOWPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
HISTOGRAM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
HISTOGRAMPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
LINECHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
LINEPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
LOESSPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
MODELBAND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
MOSAICPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
NEEDLEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
PBSPLINEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
PIECHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
POLYGONPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
REFERENCELINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
REGRESSIONPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
SCATTERPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
SCATTERPLOTMATRIX Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
SERIESPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
STEPPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774
SURFACEPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
TEXTPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
VECTORPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
WATERFALLCHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
190 Chapter 6 • Plot Statements

Dictionary

AXISTABLE Statement
Creates an event plot of input data along an axis of an X-Y plot.

Syntax
AXISTABLE X=column | expression VALUE=column </option(s)>;
AXISTABLE Y=column | expression VALUE=column </option(s)>;

Summary of Optional Arguments

Appearance options
CLASS=column | expression
creates a separate row or column for each unique class value.
CLASSORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the order in which the class values are displayed.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing
or bin width.
COLORGROUP=column | expression | discrete-attr-var
specifies a column that is used to discretely map the color of the value text.
DATATRANSPARENCY=number
specifies the degree of the transparency of the header, label, and values.
DISPLAY=STANDARD | ALL | (display-options)
specifies which features to display.
DROPONMISSING=TRUE | FALSE
specifies whether the entire axis table is dropped when all of the VALUE=
column values are missing.
GUTTER=dimension
specifies the gap between rows when a class variable is used.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether missing class values are represented in the table.
INDENT=dimension
specifies a value to be used with the INDENTWEIGHT= option to determine
the indention for each text value.
INDENTWEIGHT=numeric-column | expression
specifies the indention weight (multiplier) for each observation.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the table border.
POSITION=number
positions the plot along the axis orthogonal to the axis used for the values.
SHOWMISSING=TRUE | FALSE
specifies whether missing values are represented in the table.
AXISTABLE Statement 191

TEXTGROUP=discrete-attr-var
specifies the discrete attribute variable for a discrete attribute map that maps
text attributes to values for each observation.
VALUEATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the text values.
VALUEFORMAT=format
specifies a SAS format or a user-defined format for the table values.
VALUEHALIGN=AUTO | LEFT | CENTER | RIGHT
in a Y-axis table, specifies the horizontal alignment of the column values
relative to the column width.
VALUEJUSTIFY=AUTO | LEFT | CENTER | RIGHT
specifies the justification of the values in the axis table.

Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.

Header options
HEADERLABEL="string"
specifies the text for the table header.
HEADERLABELATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the table header.
TITLE="string"
specifies the text for the table title.
TITLEATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the table title.
TITLEHALIGN=AUTO | CENTER | LEFT | RIGHT
specifies the horizontal alignment of the axis table header label relative to the
axis table width.
TITLEJUSTIFY=LEFT | CENTER | RIGHT
specifies the justification of the title string. The justification is relative to the
axis table width.

Label options
LABEL="string"
specifies the text for the table label.
LABELATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the column label.
LABELHALIGN=AUTO | LEFT | CENTER | RIGHT
specifies the horizontal alignment of the column label when it is displayed.
LABELJUSTIFY=LEFT | CENTER | RIGHT
specifies the justification of the column label when it is displayed.
LABELPOSITION=MIN | MAX
specifies the end of the axis on which the label is displayed.

Midpoint options
CLASSDISPLAY=STACK | CLUSTER
192 Chapter 6 • Plot Statements

specifies how the class values are displayed.

Plot reference options


NAME="string"
assigns a name to this plot statement for reference in other template
statements.

Statistics options
STAT=AUTO | SUM | MEAN
specifies the statistic that is to be computed for the VALUE= column when
the column is numeric.

Required Arguments
Either the X= or the Y= argument must be specified in the AXISTABLE statement.
Specifying X= places an axis table along the X axis of a plot. Specifying Y= places an
axis table along the Y axis of a plot.
X=column | expression
specifies the column for the X axis.

Requirement If not specified, then Y= must be specified.

Y=column | expression
specifies the column for the Y axis.

Requirement If not specified, then X= must be specified.

VALUE=column
specifies the column that contains the axis table values.

Optional Arguments
CLASS=column | expression
creates a separate row or column for each unique class value. Each row or column is
labeled by the class value.

Interaction The DISPLAY= option that is in effect must include LABEL for any
labels to appear.

Tip Use the LABELATTRS= option to modify the label text attributes.

CLASSDISPLAY=STACK | CLUSTER
specifies how the class values are displayed.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
STACK
displays the class values vertically at each midpoint value on the X axis or
horizontally on the Y axis.
CLUSTER
displays the class values horizontally at each midpoint value on the X axis or
vertically on the Y axis.

Restriction CLUSTER applies only when the axis table is on a discrete axis.

Tip The CLUSTERWIDTH= option controls the cluster width.


AXISTABLE Statement 193

Default STACK

Interaction The CLASS= option must be specified for this option to have any
effect.

CLASSORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING


specifies the order in which the class values are displayed.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
DATA
displays the class values in the order in which they occur in the data.
REVERSEDATA
displays the class values in the reverse order from which they occur in the data.

Tip This option is useful when the plot axis is reversed.

ASCENDING | DESCENDING
displays the class values in ascending or descending order.

Default DATA

Interaction The CLASS= option must be specified for this option to have any
effect.

CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or bin
width.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Range 0.1–1, where 0.1 is the narrowest possible width and 1 is the widest
width.

Requirement For this option to take effect, the CLASS= option must also be
specified, and the CLASSDISPLAY= option must be set to
CLUSTER.

COLORGROUP=column | expression | discrete-attr-var


specifies a column that is used to discretely map the color of the value text.
discrete-attr-var
specifies a discrete attribute map variable that is defined in a
DISCRETEATTRVAR statement.

Restriction A discrete attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set by a
dynamic variable.

Each unique value of this column is mapped to the COLOR attribute of the
GraphData1–GraphDataN style elements that are in effect. If a discrete attribute
variable is specified, the color mapping from its associated DISCRETEATTRMAP
statement is used.

Interaction This option is ignored when the TEXTGROUP= option is specified.


194 Chapter 6 • Plot Statements

See “DISCRETEATTRVAR Statement” on page 1297

“DISCRETEATTRMAP Statement” on page 1287

DATATRANSPARENCY=number
specifies the degree of the transparency of the header, label, and values.

Default 0

Range 0–1, where 0 is opaque and 1 is entirely transparent

DISPLAY=STANDARD | ALL | (display-options)


specifies which features to display.
STANDARD
displays the table values and, if provided, the table label.
ALL
displays the same features as STANDARD.
(display-options)
a space-separated list of display options, enclosed in parentheses. The following
options are supported:
LABEL
displays the table label. The label can be the VALUE= column label or name,
the LABEL= value, or the CLASS= value for the table, depending on the
options that you specify.
VALUES
displays the column values.
Note: This feature applies to the second maintenance release of SAS 9.4 and
to later releases.

Tip The column values are always displayed, even if DISPLAY=(LABEL) is


specified. To hide the table label, specify DISPLAY=(VALUES).

Default STANDARD

Note If a table title is specified, it is always displayed.

DROPONMISSING=TRUE | FALSE
specifies whether the entire axis table is dropped when all of the VALUE= column
values are missing.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default FALSE

Tip The SHOWMISSING= option controls whether missing values are shown
in the table.

See VALUE= on page 192

“boolean ” on page 1339 for other Boolean values that you can use.

GUTTER=dimension
specifies the gap between rows when a class variable is used.
AXISTABLE Statement 195

Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Defaults Y-axis table: 8 px

X-axis table: 0 px

Interaction The CLASS= option must be specified for this option to have any
effect.

See “dimension” on page 1340

HEADERLABEL="string"
specifies the text for the table header.
Note: Starting with the second maintenance release of SAS 9.4, the
HEADERLABEL= option is deprecated and is replaced with the TITLE= option.
The syntax and functionality are the same. The HEADERLABEL= option is still
honored, but the TITLE= option is preferred.

Default No table header is displayed

Tip Use the HEADERLABELATTRS= option to control the appearance of the


table header.

HEADERLABELATTRS=style-element | style-element(text-options) | (text-options)


specifies the color and font attributes of the table header.
Note: Starting with the second maintenance release of SAS 9.4, the
HEADERLABELATTRS= option is deprecated and is replaced with the
TITLEATTRS= option. The syntax and functionality are the same. The
HEADERLABELATTRS= option is still honored, but the TITLEATTRS= option
is preferred.

See “TITLEATTRS=style-element | style-element(text-options) | (text-options)” on


page 200

INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether missing class values are represented in the table.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
Missing class values are included by default. When the data contains missing class
values, the label for those values is either blank for missing character values or a dot
for missing numeric values.
The following figure shows an X-axis axis table that displays values for classes Class 1,
Class 2, and any missing class values.

Notice that the label for the missing class values is blank. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing class values. If
you want to keep the missing class values, then you can create a format that specifies
196 Chapter 6 • Plot Statements

a more meaningful label for the missing class. For example, here is a format that
specifies a label for missing character and numeric class values.
proc format;
value $missingClass " " = "(Missing)";
value missingClass . = "(Missing)";
run;

A single space enclosed in quotation marks specifies a missing character value and a
dot specifies a missing numeric value. Although it might seem appropriate to use
empty quotation marks ('' or "") to specify a missing character value, doing so
produces unexpected results. To specify a missing character value, enclose a single
space in quotation marks (' ' or " "). You can use this format for the class columns in
the PROC SGRENDER statement. In that case, if the class columns contain missing
values, then the labels specified in the format statement are used for the missing
classes.
The following figure shows the previous example when format $missingClass is
applied to the class variable.

Note: In the second maintenance release of SAS 9.4 and in earlier releases, ODS
Graphics does not support Unicode values in user-defined formats. Starting with
the third maintenance release of SAS 9.4, ODS Graphics supports Unicode
values in user-defined formats only if they are preceded by the (*ESC*) escape
sequence. Example: "(*ESC*){unicode beta}". ODS Graphics does not
support an escape character that is defined in an ODS ESCAPECHAR statement
in user-defined formats.

Default TRUE

Interaction The CLASS= option must be specified for this option to have any
effect.

See “boolean ” on page 1339 for other Boolean values that you can use.

INDENT=dimension
specifies a value to be used with the INDENTWEIGHT= option to determine the
indention for each text value.

Default 1/8 inch

Interaction The INDENTWEIGHT= option must be specified for this option to


have any effect.

See “dimension” on page 1340

INDENTWEIGHT=numeric-column | expression
specifies the indention weight (multiplier) for each observation.
AXISTABLE Statement 197

Interaction For each observation, the INDENT= option value is multiplied by the
value of the column specified by this option to determine the indention
for that observation’s value.

LABEL="string"
specifies the text for the table label.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The class values are used when the CLASS= option is set and
CLASSDISPLAY=STACK is in effect. Otherwise, the VALUE=
column label or name is used.

Interaction This option is ignored when the CLASS= option is in effect.

Note If the length of the label exceeds the available space, the label is split
on blank space as needed to make it fit.

See CLASS= on page 192

LABELATTRS=style-element | style-element(text-options) | (text-options)


specifies the color and font attributes of the column label.

Defaults For non-grouped data, the GraphValueText style element.

For grouped data, the label color changes to match the group color
derived from the ContrastColor attribute of the GraphData1–
GraphDataN style elements.

Restriction Group behavior occurs only when the CLASS= and COLORGROUP=
option values are the same.

Interaction If one or more text options are specified and they do not include all the
font properties such as color, family, size, weight, and style, then the
properties that are not specified are derived from the GraphValueText
style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

LABELHALIGN=AUTO | LEFT | CENTER | RIGHT


specifies the horizontal alignment of the column label when it is displayed.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
The alignment is relative to the column width.
AUTO
uses the effective value of the LABELJUSTIFY= option.
LEFT | CENTER | RIGHT
horizontally justifies the label left, center, or right,

Default AUTO
198 Chapter 6 • Plot Statements

Restriction This option applies only to Y-axis tables.

Interaction The DISPLAY= option must include LABEL for this option to have
any effect.

LABELJUSTIFY=LEFT | CENTER | RIGHT


specifies the justification of the column label when it is displayed.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
The justification is relative to the column width.

Default CENTER

Restriction This option applies only to Y-axis tables.

Interaction The DISPLAY= option must include LABEL for this option to have
any effect.

LABELPOSITION=MIN | MAX
specifies the end of the axis on which the label is displayed. The label is aligned with
the tick values on the axis.

Default MIN

NAME="string"
assigns a name to this plot statement for reference in other template statements. The
specified name is used primarily in legend statements to coordinate the use of colors
and line patterns between the plot and the legend.

Restriction The string is case sensitive, cannot contain spaces, and must define a
unique name within the template.

PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the table border.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
dimension
specifies a dimension to use for the extra space at the left, right, top, and bottom
of the table border.
(pad-options)
a space-separated list of one or more of the following name-value-pair options,
enclosed in parentheses:
LEFT=dimension
specifies the amount of extra space added to the left side.

Default 4 px

Restriction This option applies only to Y-axis tables.

RIGHT=dimension
specifies the amount of extra space added to the right side.

Default 4 px
AXISTABLE Statement 199

Restriction This option applies only to Y-axis tables.

TOP=dimension
specifies the amount of extra space added to the top.

Default 0 px

Restriction This option applies only to X axis tables.

BOTTOM=dimension
specifies the amount of extra space added to the bottom.

Default 0 px

Restriction This option applies only to X axis tables.

Note Sides that are not assigned padding are padded with the default amount of
space.

Tip Use pad-options to create non-uniform padding.

Note The default units for dimension are pixels.

See “dimension” on page 1340

POSITION=number
positions the plot along the axis orthogonal to the axis used for the values. This
option enables you to position the plot when the AXISTABLE statement is not
placed in an INNERMARGIN block.
number
specifies the position on the orthogonal axis as a fraction of the axis range.

Default Determined by the system.

Range 0 (bottom)–1 (top)

Interaction This option is ignored when the AXISTABLE statement is placed in an


INNERMARGIN block. It is also ignored when the AXISTABLE
statement is placed in a LAYOUT OVERLAY block by itself.

Tip To reserve space for the plot at either end of the orthogonal axis,
specify the OFFSETMIN= or OFFSETMAX= option for the orthogonal
axis.

SHOWMISSING=TRUE | FALSE
specifies whether missing values are represented in the table.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
The values are evaluated before the column format is applied. When this option is set
to FALSE, missing numeric and character values are hidden.

Default TRUE

See “boolean ” on page 1339 for other Boolean values that you can use.
200 Chapter 6 • Plot Statements

STAT=AUTO | SUM | MEAN


specifies the statistic that is to be computed for the VALUE= column when the
column is numeric.
AUTO
computes the SUM statistic when the VALUE= column is numeric. When the
column is character, it uses the first column value as the statistic value.
SUM | MEAN
computes the SUM or MEAN statistic when the VALUE= column is numeric.
When the column is character, it uses the first column value as the statistic value.

Default AUTO

Interaction When the VALUE= column is character, the STAT= option always uses
the first column value as the statistic value. In that case, SUM and
MEAN are ignored.

TEXTGROUP=discrete-attr-var
specifies the discrete attribute variable for a discrete attribute map that maps text
attributes to values for each observation. The discrete attribute variable is defined in
a DISCRETEATTRVAR statement.

Restrictions A discrete attribute variable specification must be a direct reference to


the attribute variable. It cannot be set by a dynamic variable.

The SIZE= specification in the discrete attribute map TEXTATTRS=


option is ignored.

Interaction When this option is specified, the COLORGROUP= option is


ignored .

TITLE="string"
specifies the text for the table title.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default No table title is displayed

Note When an axis table is specified in the prototype of a data-driven layout, if


the table is on the X axis, then the table title appears only in the first
column of each row. If the table is on the Y axis, then the table title appears
only in the first row of each column.

Tip Use the TITLEATTRS= option to control the appearance of the table title.

TITLEATTRS=style-element | style-element(text-options) | (text-options)


specifies the color and font attributes of the table title.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The GraphLabelText style element.

Interaction If one or more text options are specified and they do not include all the
font properties such as color, family, size, weight, and style, then the
properties that are not specified are derived from the GraphLabelText
style element.
AXISTABLE Statement 201

See “General Syntax for Attribute Options” on page 1347 for the syntax for
using a style-element.

“Text Options” on page 1351 for available text-options.

TITLEHALIGN=AUTO | CENTER | LEFT | RIGHT


specifies the horizontal alignment of the axis table header label relative to the axis
table width.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
AUTO
aligns the title based on table type as follows:
• For a Y-axis table, aligns the title according to the effective TITLEJUSTIFY=
option value.
• Starting with the third maintenance release of SAS 9.4, for an X-axis table,
aligns the title LEFT.
CENTER | LEFT | RIGHT
horizontally aligns the table title center, left, or right.

Default AUTO

Restriction In the second maintenance release of SAS 9.4, this option applies only
to Y-axis tables. Starting with the third maintenance release of SAS 9.4,
this option applies to Y-axis tables and to X-axis tables.

Interaction The TITLE= option must be specified for this option to have any effect.

TITLEJUSTIFY=LEFT | CENTER | RIGHT


specifies the justification of the title string. The justification is relative to the axis
table width.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default LEFT

Restriction This option applies only to Y-axis tables.

Interaction The TITLE= option must be specified for this option to have any effect.

VALUEATTRS=style-element | style-element(text-options) | (text-options)


specifies the color and font attributes of the text values.

Default The GraphDataText style element.

Interaction If one or more text options are specified and they do not include all the
font properties such as color, family, size, weight, and style, then the
properties that are not specified are derived from the GraphLabelText
style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.


202 Chapter 6 • Plot Statements

VALUEFORMAT=format
specifies a SAS format or a user-defined format for the table values.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The format that is in effect for the column specified in the VALUE= option.
If no format is in effect, BEST6 is used for numeric columns.

Note Not all of the SAS formats are supported. See Appendix 4, “SAS Formats
Not Supported,” on page 1353.

VALUEHALIGN=AUTO | LEFT | CENTER | RIGHT


in a Y-axis table, specifies the horizontal alignment of the column values relative to
the column width.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
AUTO
uses the effective value of the VALUEJUSTIFY= option.
LEFT | CENTER | RIGHT
aligns the values left, center, or right relative to the column width.

Default AUTO

Restriction This option applies only to Y-axis tables.

VALUEJUSTIFY=AUTO | LEFT | CENTER | RIGHT


specifies the justification of the values in the axis table.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
AUTO
uses LEFT for text values or RIGHT for numeric values.
CENTER | LEFT | RIGHT
horizontally aligns the table values center, left, or right, relative to the column
width.

Default AUTO

Restriction This option applies only to Y-axis tables.

XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the secondary
X2 (top) axis.

Default X

Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2
(right) axis.
Example: AXISTABLE Statement 203

Default Y

Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

Details
The AXISTABLE statement enables you to place text values along the X or Y axis at
specific values on the axis. It offers more flexibility than the BLOCKPLOT statement,
which is used to denote changes in block values along the axis. The X and Y data does
not need to be sorted.

Example: AXISTABLE Statement

This example shows how to add a table of average sales data by division below a bar
chart of total sales by product and country. Here is the output that is generated by this
example.

An inner margin is created at the bottom of the layout container to reserve space for the
table. An AXISTABLE statement is used in the INNERMARGIN block to show the
average sales by division for each product.
Here is the SAS code for this example.
proc template;
define statgraph axistable;
begingraph;
entrytitle "Average Product Sales By Division and Country";
layout overlay / cycleattrs=true
204 Chapter 6 • Plot Statements

yaxisopts=(offsetmax=0.15 label="Sales By Country");


innermargin / align=bottom opaque=true backgroundcolor=cxf5f5f5;
axistable x=product value=actual /
name="division" stat=mean display=(label)
headerlabel="Sales By Division"
headerlabelattrs=GraphLabelText
valueattrs=(size=9pt weight=bold)
colorgroup=division class=division;
endinnermargin;
barchart category=product y=actual / name="country"
barlabel=true barlabelformat=dollar5.0
stat=mean group=country groupdisplay=cluster;
discretelegend "country" / title="Country:" location=inside
valign=top;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.prdsale template=axistable;


run;

See Also
“Creating an Axis-Aligned Inset with an Axis Table” in SAS Graph Template Language:
User's Guide

BANDPLOT Statement
Creates a band plot that typically shows confidence or prediction limits.
Requirements: You must specify either an X= argument or a Y= argument. You cannot specify both..
When you specify the X argument, you must also specify LIMITLOWER and
LIMITUPPER arguments for Y values.
When you specify the Y argument, you must also specify LIMITLOWER and
LIMITUPPER arguments for X values.
The plot data should be sorted by the X or Y variable that is used in the BANDPLOT
statement. Otherwise, specify CONNECTORDER= AXIS in the BANDPLOT
statement.

Syntax
BANDPLOT X=column | expression
LIMITLOWER=number | numeric-column | expression
LIMITUPPER=number | numeric-column | expression </option(s)>;
BANDPLOT Y=numeric-column | expression
LIMITLOWER=number | numeric-column | expression
LIMITUPPER=number | numeric-column | expression </option(s)>;

Summary of Optional Arguments

Appearance options
BANDPLOT Statement 205

ANTIALIAS=AUTO | OFF
specifies whether anti-aliasing is turned off for this plot.
CONNECTORDER=VALUES | AXIS
specifies how to connect the data points to form the band lines.
CURVELABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the band labels.
DATATRANSPARENCY=number
specifies the degree of the transparency of the band fill and band outline.
DISPLAY=STANDARD | ALL | (display-options)
specifies whether to display an outlined band area, a filled band area, or an
outlined and filled band area.
EXTEND=TRUE | FALSE
specifies whether the constant or "step" band is to be drawn to the area
bounded by the axes.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the filled band area.
INDEX=positive-integer-column | expression
specifies indices for mapping band attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
JUSTIFY=LEFT | CENTER | RIGHT
specifies the location of the data point relative to the step when TYPE=STEP.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the band outlines.
TYPE=SERIES | STEP
specifies how the data points for lower and upper band boundaries are
interpolated.

Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.

Data tip options


ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the
band plot.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns.
TIPLABEL=(role-label-list)
specifies display labels for tip columns.

Label options
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
CURVELABELLOWER="string" | column
206 Chapter 6 • Plot Statements

specifies a label for the lower band limit.


CURVELABELPOSITION=AUTO | MAX | MIN |START | END
specifies the position of the band labels relative to the curve line.
CURVELABELUPPER="string" | column
specifies a label for the upper band limit.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.

Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate band plot for each unique group value of the specified
column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.

Plot reference options


MODELNAME="plot-name"
specifies the name of the plot from which to derive the interpolation for the
band.
NAME="string"
assigns a name to this plot statement for reference in other template
statements.

Required Arguments
You must specify either an X= or Y= argument. You cannot specify both. In addition, the
LIMITLOWER= and LIMITUPPER= arguments must be used to specify the lower and
upper lines for the band.
X=column | expression
specifies X values. Numeric or character values can be used.

Requirement You must also specify the LIMITLOWER= and the LIMITUPPER=
arguments for the Y values.

Y=column | expression
specifies Y values. Numeric or character values can be used.

Requirement You must also specify the LIMITLOWER= and the LIMITUPPER=
arguments for the X values.

LIMITLOWER=number | numeric-column | expression


specifies a constant or column representing the values of the lower band line.

Interactions When this option is used with the X= option, it specifies the Y value
or values.

When this option is used with the Y= option, it represents the X value
or values.

Note If a constant is specified, then a straight line is drawn.

LIMITUPPER=number | numeric-column | expression


specifies a constant or column representing the values of the lower band line.
BANDPLOT Statement 207

Interactions When this option is used with the X= option, it specifies the Y value
or values.

When this option is used with the Y= option, it represents the X value
or values.

Note If a constant is specified, then a straight line is drawn.

Optional Arguments
ANTIALIAS=AUTO | OFF
specifies whether anti-aliasing is turned off for this plot.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
AUTO
specifies that anti-aliasing is controlled by the ANTIALIAS= option in the ODS
GRAPHICS statement.
OFF
specifies that anti-aliasing is always disabled for this plot.

Default AUTO

Interaction This option overrides the ANTIALIAS= option in the ODS


GRAPHICS statement.

CONNECTORDER=VALUES | AXIS
specifies how to connect the data points to form the band lines.
VALUES
connects data points in the order read from the X column (or Y column).
AXIS
connects data points as they occur left-to-right along the X axis (or bottom-to-top
along the Y axis).

Tip You can use this value to ensure the expected connect order for certain
types of series lines (for example, time series) when the input data might
not be sorted by the X column (or Y column).

Default VALUES

CURVELABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the color and font attributes of the band labels.

Defaults For non-grouped data, the GraphValueText style element.

For grouped data, text color is derived from the


GraphData1:ContrastColor–GraphDataN:ContrastColor style references.
The font is derived from the GraphValueText style element.

Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
208 Chapter 6 • Plot Statements

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

CURVELABELLOWER="string" | column
specifies a label for the lower band limit.

Default No curve label is displayed for the lower band

Requirements For non-grouped data, use "string".

For grouped data, use a column to define the lower band labels for
each group value. All of the labels for a specific group value must
be the same. Otherwise, the results are unpredictable.

Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.

CURVELABELUPPER="string" | column
specifies a label for the upper band limit.

Default No curve label is displayed for the upper band

Requirements For non-grouped data, use "string".

For grouped data, use a column to define the upper band labels for
each group value. All of the labels for a specific group value must
be the same. Otherwise, the results are unpredictable.

Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.

CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area

Default INSIDE

Restriction OUTSIDE cannot be used when the BANDPLOT is used in multicell


layouts such as LATTICE, DATAPANEL, or DATALATTICE where
axes might be external to the grid.

Interaction This option is used with the CURVELABELPOSITION= option to


determine where the band labels appear. For more information, see
“Location and Position of Curve Labels” on page 185.

CURVELABELPOSITION=AUTO | MAX | MIN |START | END


specifies the position of the band labels relative to the curve line.
AUTO
positions the band labels automatically near the band boundary along unused
axes whenever possible (typically Y2 and X2).
BANDPLOT Statement 209

Restriction This option is used only when


CURVELABELLOCATION=OUTSIDE.

MAX
forces the band labels to appear near maximum band values (maximum X-values
for horizontal curves, and maximum Y-values for vertical curves).
MIN
forces the band label to appear near minimum band values (minimum X-values
for horizontal curves, and minimum Y-values for vertical curves)
START
forces band labels to appear near the beginning of the curve.

Restriction This option is used only when


CURVELABELLOCATION=INSIDE.

Tip This option is particularly useful when the curve line has a spiral
shape.

END
forces band labels to appear near the end of the curve.

Restriction This option is used only when


CURVELABELLOCATION=INSIDE.

Tip This option is particularly useful when the curve line has a spiral
shape.

Defaults AUTO when CUVELABELLOCATION=OUTSIDE.

END when CURVELABELLOCATION=INSIDE.

Restriction The AUTO setting is ignored if CURVELABELLOCATION=INSIDE


is specified. The START and END settings are ignored if
CURVELABELLOCATION=OUTSIDE is specified.

Interaction This option is used with the CURVELABELLOCATION= option to


determine where the band labels appear. For more information, see
“Location and Position of Curve Labels” on page 185.

Note When you specify TICKVALUELIST=, VIEWMAX=, or VIEWMIN=


in an axis statement, the data points that are used to determine the
position of the band label might fall outside of the graph area. In that
case, the band label might not be displayed or might be positioned
incorrectly.

DATATRANSPARENCY=number
specifies the degree of the transparency of the band fill and band outline.

Default 0

Range 0–1, where 0 is opaque and 1 is entirely transparent

Note This option does not affect the band curve labels.

Tip The FILLATTRS= option can be used to set transparency for just the band
area. You can combine this option with FILLATTRS= to set one
210 Chapter 6 • Plot Statements

transparency for the band outline but a different transparency for the band
fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

DISPLAY=STANDARD | ALL | (display-options)


specifies whether to display an outlined band area, a filled band area, or an outlined
and filled band area.
STANDARD
displays filled band with no outline
ALL
displays an outlined, filled band
(display-options)
a space-separated list of one or more of the following options enclosed in
parentheses:

OUTLINE displays an outlined band


FILL displays a filled band

Default The value of the DisplayOpts attribute of the GraphBand style element,
which is DisplayOpts="FILL" by default.

Tip Use the OUTLINEATTRS= and FILLATTRS= options to control the


appearance of the band.

EXTEND=TRUE | FALSE
specifies whether the constant or "step" band is to be drawn to the area bounded by
the axes.

Default FALSE

Requirement When this option is used for a constant band, constants must be
specified for the upper and lower band limits. This requirement does
not apply to "step" bands.

Interactions This option is ignored when band labels are placed inside the plot
area (CURVELABELLOCATION=INSIDE). To extend the bands in
that case, use the CURVELABELLOCATION=OUTSIDE option.

If the X or Y value is character, then the EXTEND= option is


honored only when the upper and lower limits specify a number.

Tip If this option is not specified, then there can be a small gap between
the line and the axis. The gap is controlled by the axis offset. If the
axis offset is set to 0, then there is no gap.

See “boolean ” on page 1339 for other Boolean values that you can use.

FILLATTRS=style-element | style-element (fill-options) | (fill-options)


specifies the appearance of the filled band area.

Defaults For non-grouped data, the GraphConfidence:Color style reference.

For grouped data, the Color attribute of GraphData1–GraphDataN style


elements.
BANDPLOT Statement 211

Interaction For this option to have any effect, the fill must be enabled by the ODS
style or by the DISPLAY= option.

Tip The DATATRANSPARENCY= option sets the transparency for both


the band fill and band outline. You can combine this option with
DATATRANSPARENCY= to set one transparency for the band outline
and a different transparency for the band fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

See “General Syntax for Attribute Options” on page 1347 for the syntax for
using a style-element.

“Fill Options” on page 1348 for available fill-options values.

GROUP=column | discrete-attr-var | expression


creates a separate band plot for each unique group value of the specified column.
discrete-attr-var
specifies a discrete attribute map variable that is defined in a
DISCRETEATTRVAR statement.

Restriction A discrete attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set by a
dynamic variable.

Defaults If the band outline is enabled by the ODS style or the DISPLAY=
option, then each distinct group value is represented in the plot by a
different combination of outline color (defined by the ContrastColor
attribute of the GraphData1–GraphDataN and GraphMissing style
elements) and outline pattern (defined by the LineStyle attribute of the
GraphData1–GraphDataN and GraphMissing style elements).

If the band fill is enabled by the ODS style or the DISPLAY= option,
then each distinct group value is represented in the plot by a different
fill color (defined by the Color attribute of the GraphData1–
GraphDataN and GraphMissing style elements).

Restriction This option can be used only when a numeric column is specified for
the upper limit or the lower limit of the band plot. The other limit
could be a constant, if desired.

Interactions To label grouped band plots, you must specify


CURVELABELLOWER= column and CURVELABELUPPER=
column

The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of colors and line
patterns.

The INCLUDEMISSINGGROUP option controls whether missing


group values are considered a distinct group value.

Tip The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the band lines, but the
212 Chapter 6 • Plot Statements

PATTERN= suboption of the OUTLINEATTRS= option could be used


to assign the same line pattern to all band outlines.

See “DISCRETEATTRVAR Statement” on page 1297

INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.

Default TRUE

Interaction For this option to take effect, the GROUP= option must also be
specified.

Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in effect,
the INDEX= option is used, the MISSING= system option changes the
default missing character, or a user-defined format is applied to the
group value. In those cases, the attributes of the missing group value
are determined by a GraphData1–GraphDataN style element instead of
by the GraphMissing style element.

See “boolean ” on page 1339 for other Boolean values that you can use.

INDEX=positive-integer-column | expression
specifies indices for mapping band attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.

Requirements The column or expression value must be an integer value of 1 or


greater. Otherwise, this option is ignored.

The positive-integer column must not contain missing values.


Otherwise, the entire column is invalidated and this option is
ignored.

All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.

Interaction For this option to take effect, the GROUP= option must also be
specified.

Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N, then
a modulo operation remaps that index value to a number less than N
to determine which style to use.

If you do not use this option, then the group values are mapped in
the order of the data.

Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 183.

JUSTIFY=LEFT | CENTER | RIGHT


specifies the location of the data point relative to the step when TYPE=STEP.
BANDPLOT Statement 213

Default LEFT

Requirement TYPE= STEP must also be specified for this option to have any
effect.

Interaction If the MODELNAME= option is specified, then this option is


ignored.

LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.

Default The string specified on the NAME= option.

Restriction This option applies only to an associated DISCRETELEGEND


statement.

Interaction If the GROUP= option is specified, then this option is ignored.

MODELNAME="plot-name"
specifies the name of the plot from which to derive the interpolation for the band.
When this option is used, the band plot forms prediction or confidence limits for the
plot that supplies the fitted model.

Requirement plot-name must be the name that has been assigned on the associated
plot’s NAME= option.

Interaction This option overrides the JUSTIFY= and TYPE= options.

Tip If this option is not specified, then the interpolation is set by the
TYPE= option.

NAME="string"
assigns a name to this plot statement for reference in other template statements. The
specified name is used primarily in legend statements to coordinate the use of colors
and line patterns between the plot and the legend.

Restriction The string is case sensitive, cannot contain spaces, and must define a
unique name within the template.

Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.

OUTLINEATTRS=style-element | style-element (line-options) | (line-options)


specifies the appearance of the band outlines.

Defaults For non-grouped data, the GraphConfidence style element.

For grouped data, the ContrastColor and LineStyle attributes of the


GraphData1–GraphDataN style elements.
214 Chapter 6 • Plot Statements

Interaction For this option to have any effect, the outline must be enabled by the
ODS style or by the DISPLAY= option.

See “General Syntax for Attribute Options” on page 1347 for the syntax for
using a style-element.

“Line Options” on page 1349 for available line-options values.

ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data tips.
This option provides a way to add to the data columns that appear in data tips that are
specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.

Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)

Default No user-defined roles

Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, LIMITUPPER, LIMITLOWER, GROUP,
CURVELABELUPPER, and CURVELABELLOWER.

TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the band plot.
If this option is used, then it replaces all of the information that is displayed by
default. Roles for columns that do not contribute to the band plot can be specified
along with roles that do.
(role-list)
an ordered, space-separated list of unique BANDPLOT and user-defined roles.
BANDPLOT roles include X , Y , LIMITUPPER , LIMITLOWER , GROUP ,
INDEX , CURVELABELUPPER , and CURVELABELLOWER .
User-defined roles are defined with the ROLENAME= option.

Note CURVELABELUPPER and CURVELABELLOWER are considered


roles only when they are assigned a column of values. They are not
considered roles and do not display data tips when assigned a string.

Example This example displays data tips for the columns assigned to the roles
X, LIMITUPPER, and LIMITLOWER as well as the column Obs,
which is not assigned to any pre-defined BANDPLOT role. The Obs
column must first be assigned a role.

ROLENAME=(TIP1=OBS)
TIP=(TIP1 X LIMITUPPER LIMITLOWER)

NONE
suppresses data tips from the plot.

Default The columns assigned to these roles are automatically included in the
data tip information: X , Y , LIMITUPPER , LIMITLOWER , and
GROUP .
BANDPLOT Statement 215

Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that has the IMAGEMAP option
specified, and you must write the output to the ODS HTML
destination.

Interaction This option is ignored when the plot statement is in an OVERLAY or


PROTOTYPE layout and the INCLUDERANGES= option is
specified in the LINEAROPTS= or TIMEOPTS= option for either
axis.

Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.

TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control the
formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.

Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)

Default The column format of the column assigned to the role or BEST6 if no
format is assigned to a numeric column.

Restriction Only the roles that appear in the TIP= option are used.

Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)

TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control the
labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.

Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")

Default The column label or column name of the column assigned to the role.

Restriction Only the roles that appear in the TIP= option are used.

Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)

TYPE=SERIES | STEP
specifies how the data points for lower and upper band boundaries are interpolated.
SERIES
connects the data points using line segments (as in a SeriesPlot).
STEP
connects the data points (as in a StepPlot).
216 Chapter 6 • Plot Statements

Default SERIES

Interactions TYPE=STEP must be specified to enable the JUSTIFY= option.

If the MODELNAME= option is specified, then this option is ignored.

XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the secondary
X2 (top) axis.

Default X

Interactions This option is ignored if the X= argument is not specified.

The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2
(right) axis.

Default Y

Interactions This option is ignored if the Y= argument is not specified.

The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

Details
A band plot can specify an X column with Y upper and lower limits, or a Y column with
X upper and lower limits. If you specify the X argument, then you must specify
LIMITLOWER and LIMITUPPER arguments for the Y values to apply the limits to the
Y axis. If you specify the Y argument, then you must specify LIMITLOWER and
LIMITUPPER arguments for the X values to apply the limits to the X axis.
When you use a BANDPLOT statement to display prediction or confidence limits, the
band plot can be used with another plot that specifies a fitted model. For example, it can
be used with a series or step plot. In these cases, use the BANDPLOT option
MODELNAME= or TYPE= to identify the interpolation for the band.
You can use the BANDPLOT statement in displays that are independent of other plots.
For example, a band plot can be used to define yellow and green areas in an OVERLAY
LAYOUT statement that also contains a scatter plot. This use implies concern for any of
the scatter plot values that fall in the yellow area and comfort for any values that fall in
the green area. For this use, the upper and lower limits would be specified by a constant.
Note: The BANDPLOT statement is optimized to work as a Confidence or Prediction
band. If the band is self intersecting (not sorted for X or for Y), then the resulting
band is unpredictable. With unsorted data, the band that is generated for an output
Raster Image might not match the band that is generated for an output Vector
Graphic.
Example: BANDPLOT Statement 217

Example: BANDPLOT Statement

The following graph was generated by the “Example Program” on page 217:

Example Program
Here is the code for this example.
proc template;
define statgraph bandplot;
begingraph;
entrytitle "Fit Plot for Weight";
layout overlay;
bandplot x=height limitupper=uppermean
limitlower=lowermean /
name="band" modelname="fit"
legendlabel="95% Confidence Limits";
scatterplot x=height y=weight / primary=true;
seriesplot x=height y=predict / name="fit"
legendlabel="Fit Line";
discretelegend "fit" "band";
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.classfit template=bandplot;


run;
218 Chapter 6 • Plot Statements

BARCHART Statement
Creates a bar chart computed from input data.
Tips: For charts that have a large number of bars that are very close together, slight
variations in spacing that normally occur due to integer rounding can become more
obvious. Subpixel rendering provides more precise bar spacing in that case. In the
second maintenance release of SAS 9.4 and in earlier releases, specify
SUBPIXEL=ON in the BEGINGRAPH statement to enable subpixel rendering. See
SUBPIXEL= on page 33. Starting with the third maintenance release of SAS 9.4,
subpixel rendering is enabled by default.
To disable subpixel rendering in the third maintenance release of SAS 9.4 and in
later releases, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
SUBPIXEL= option, see SUBPIXEL= on page 33. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” in
SAS ODS Graphics: Procedures Guide.

Syntax
BARCHART CATEGORY=column | expression </option(s)>;
BARCHART CATEGORY=column | expression
RESPONSE=numeric-column | expression </option(s)>;

Summary of Optional Arguments

Appearance options
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
COLORBYFREQ=TRUE | FALSE
specifies whether the bar colors are based on statistical values when the
COLORRESPONSE= option is not specified.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option or the
COLORBYFREQ= option.
COLORRESPONSE=numeric-column | range-attr-var | expression
specifies the column or range attribute variable to use to map the bar colors to
a continuous color gradient.
CONNECTATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar connect lines.
DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN
enhances the visual appearance of the filled bars.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, connect
line, and bar labels, if displayed.
DISPLAY=STANDARD | ALL | (display-options)
specifies which bar features to display.
BARCHART Statement 219

DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the filled bar area.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled bar area.
FILLTYPE=SOLID | GRADIENT
specifies the bar fill type.
INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval
width.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar outlines.
TARGET=numeric-column | expression
specifies the target value for each bar.

Axes options
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.

Data tip options


TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns.
TIPLABEL=(role-label-list)
specifies display labels for tip columns.

Label options
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the bar.
BARLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the text properties of the bar label text.
BARLABELFITPOLICY=AUTO | NONE
specifies a policy for avoiding collisions among the bar labels when labels
are displayed.
BARLABELFORMAT=format
220 Chapter 6 • Plot Statements

specifies the text format used to display the bar label.


LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
SEGMENTLABEL=TRUE | FALSE
specifies whether a label is displayed inside each bar segment.
SEGMENTLABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the text properties of the text for the bar segment label.
SEGMENTLABELFITPOLICY=NONE | NOCLIP | THIN
specifies a policy for fitting the bar segment labels within the bar segments.
SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.

Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
GROUP=column | discrete-attr-var | expression
creates a separate bar segment or bar for each unique group value in the
specified column.
GROUP100=NONE | MAGNITUDE | POSITIVE
displays the computed response values (FREQ, SUM, or MEAN), normalized
to 100%.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.

ODS options
URL=string-column
specifies an HTML page to display when the bar is selected.

Plot reference options


NAME="string"
assigns a name to this plot statement for reference in other template
statements.

Statistics options
COLORSTAT=FREQ | PCT | SUM | MEAN | PROPORTION
specifies the statistic to be calculated for the data range of the bar-color
gradient.
STAT=FREQ | PCT | SUM | MEAN | PROPORTION
specifies the statistic to be computed for the Y-axis.

Required Arguments
Specifying only CATEGORY= creates a bar chart with bars that, by default, represent
frequency counts or percents of CATEGORY. Specifying both CATEGORY= and
BARCHART Statement 221

RESPONSE= creates a bar chart with bars representing summarized values of


RESPONSE categorized by CATEGORY.
CATEGORY=column | expression
specifies the column or expression for the category values.

Notes You can use X= as an alternative to CATEGORY=. If you use X=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options recognize X
as the category role and not as CATEGORY.

For interval category values, if a user-defined format is applied to the


category column, the format should map each category value to only one
unique formatted value. Otherwise, unexpected results might occur.

RESPONSE=numeric-column | expression
specifies the numeric column or expression for the response values.

Notes You can use Y= as an alternative to RESPONSE=. If you use Y=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will
recognize Y as the response role and not RESPONSE in that case.

This option is required only when you want summarized values of


RESPONSE that are categorized by CATEGORY.

Optional Arguments
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the bar. For
grouped clustered bars, each bar is labeled with the summarized value of the bar. For
grouped stacked bars, the segmented bar is labeled with the accumulated,
summarized value of all the bar segments.

Default FALSE

Tip The font and color attributes for the label are specified by the
BARLABELATTRS= option. The text format is specified by the
BARLABELFORMAT= option.

See “boolean ” on page 1339 for other Boolean values that you can use.

BARLABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the bar label text.

Default The GraphDataText style element.

Requirement For this option to take effect, BARLABEL=TRUE must be specified.

See “General Syntax for Attribute Options” on page 1347 for the syntax
on using a style-element.

“Text Options” on page 1351 for available text-options.

BARLABELFITPOLICY=AUTO | NONE
specifies a policy for avoiding collisions among the bar labels when labels are
displayed.
222 Chapter 6 • Plot Statements

AUTO
for a vertical bar chart, rotates the bar labels if the labels exceed the midpoint
spacing. For a horizontal bar chart, always draws the labels horizontally. The
following figure shows an example.

See the BARWIDTH= option for more information about the bar spacing.
NONE
does not rotate the bar labels. Labels that are too long overlap.
Labels can collide along their length and along their height. In some cases, if one or
more labels collide when the specified fit policy is used, then all of the labels are
dropped from the display. When that occurs, the following warning message is
written to the SAS log:
WARNING: The bar labels are suppressed. Use BARLABELFITPOLICY=NONE to
force the labels to be displayed.

TIP If the labels collide along their height, then using the BARLABELATTRS=
option to reduce the label font size might eliminate the collision.

Default AUTO

Requirement For this option to take effect, BARLABEL=TRUE must be specified.

BARLABELFORMAT=format
specifies the text format used to display the bar label.

Default The column format assigned to the RESPONSE= column or BEST6


if no format is assigned.

Requirement For this option to take effect, BARLABEL=TRUE must be specified.

BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.

Default 0.85

Range 0.1–1, where 0.1 is the narrowest and 1 is the widest


BARCHART Statement 223

Interaction Starting with the third maintenance release of SAS 9.4, the
INTERVALBARWIDTH= option overrides this option for an interval
bar chart.

Notes This option is needed only to change the default behavior.

By default, the bar width automatically adjusts based on the number of


bars to be displayed and the wall width.

Tip To remove any inter-bar gap, set BARWIDTH=1.

BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.

Default The GraphAxisLines style element.

Notes The baseline is always drawn by default.

When style-element is specified, only the style element’s COLOR,


LINESTYLE, and LINETHICKNESS attributes are used.

Tip To suppress the baseline, set the line thickness to 0:


baselineattrs=(thickness=0)

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline. The baseline is always
displayed in the chart, whether for a specified value or for the default value. When
this option is used, the axis range is adjusted to include the baseline, and the baseline
is placed at the specified value on the response axis.

Default 0

Interactions If GROUPDISPLAY=STACKED is specified, then this option is


ignored and the baseline is not displayed.

This option is ignored when the GROUP100= option is used.

If necessary, the response axis data range is extended to include the


baseline intercept. When a logarithmic response axis is requested and
BASELINEINTERCEPT= specifies 0 or a negative value, the
224 Chapter 6 • Plot Statements

response axis reverts to a linear axis. To restore the log axis in that
case, set BASELINEINTERCEPT= to a positive value.

Note Label positions are automatically adjusted to prevent the labels from
overlapping.

Tips Control the appearance of the baseline with the BASELINEATTRS=


option.

To suppress the baseline, use the BASELINEATTRS= option to set


the line thickness to 0.

The baseline does not add a tick or a tick value to the axis. To label the
baseline, use a REFERENCELINE statement to overlay a line with the
same X or Y value and include the CURVELABEL= option to specify
the label text.

COLORBYFREQ=TRUE | FALSE
specifies whether the bar colors are based on statistical values when the
COLORRESPONSE= option is not specified. Setting this option to TRUE enables
you to color the bars based on frequency counts, percentages, or proportions.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.

Default FALSE

Requirement The COLORSTAT= option must be FREQ, PCT, or PROPORTION


for this option to have any effect.

Interactions This option is ignored when the COLORRESPONSE= option is


specified.

When the GROUP= option is specified with the COLORBYFREQ=


option, the color attributes are controlled by the COLORBYFREQ=
option.

The COLOR= suboption of the FILLATTRS=,


FILLPATTERNATTRS=, and OUTLINEATTRS= options overrides
this option for the associated color attribute.

Note This option is independent of the STAT= and RESPONSE= options.

Tips Use the COLORSTAT= option to specify whether frequency counts,


percentages, or proportions are computed for the
COLORRESPONSE= column.

Use the FILLTYPE= option to specify whether each bar is filled with
a solid color or with a gradient color.

See “Example 3: Bar Chart with Bar Colors Controlled by a Statistic” on


page 249

COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option or the
COLORBYFREQ= option.
BARCHART Statement 225

color-ramp-style-element
specifies the name of a color-ramp style element. The style element should
contain these style attributes:

STARTCOLOR specifies the color for the smallest data value of the
COLORRESPONSE= column.
NEUTRALCOLOR specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR specifies the color for the highest data value of the
COLORRESPONSE= column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can use
style attribute references such as GraphData3:Color, color names, or RGB,
CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.

Requirement The list of colors must be enclosed in parentheses.

See “color ” on page 1340

Defaults For outline-only bars, the ThreeColorAltRamp style element

For bars with fill, the ThreeColorRamp style element

Interaction For this option to take effect, the COLORRESPONSE= option or the
COLORBYFREQ=TRUE option must also be specified.

Tip Use the DISPLAY= option to specify whether outlines and fills are
displayed.

COLORRESPONSE=numeric-column | range-attr-var | expression


specifies the column or range attribute variable to use to map the bar colors to a
continuous color gradient.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.

Restriction A range attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set as a
dynamic variable.

When a numeric column or expression is specified, the range of column or


expression values are linearly mapped to the color ramp that is specified by the
COLORMODEL= option. Each bar is colored using one color from the gradient
range. When a range attribute map variable is specified, the colors that are defined in
the associated range attribute map are used instead.

Requirement For a grouped plot, the COLORRESPONSE values should remain


constant for each group value. If the COLORRESPONSE column has
multiple values for a single GROUP value, unexpected results might
occur.
226 Chapter 6 • Plot Statements

Interactions The COLORBYFREQ= option is ignored when this option is


specified.

When the GROUP= option is specified with the


COLORRESPONSE= option, the color attributes are controlled by
the COLORRESPONSE= option.

When fill, fill pattern, or both are displayed, this option overrides
suboption COLOR= in the FILLATTRS= option and in the
FILLPATTERNATTRS= option and varies the color according to the
color gradient or the attribute map.

When only the outlines are displayed, this option overrides suboption
COLOR= in the OUTLINEATTRS= option and varies the outline
color according to the color gradient or the attribute map.

Tips To display a legend with this option in effect, use a


CONTINUOUSLEGEND statement.

Use the COLORSTAT= option to specify the statistic to compute for


the COLORRESPONSE= column.

Use the FILLTYPE= option to specify whether each bar is filled with
a solid color or with a gradient color.

For a numeric column or expression, the ThreeColorRamp style


element defines the fill color gradient, and the ThreeColorAltRamp
style element defines the outline color gradient.

COLORSTAT=FREQ | PCT | SUM | MEAN | PROPORTION


specifies the statistic to be calculated for the data range of the bar-color gradient.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
The statistics that are available depend on the COLORRESPONSE= and
COLORBYFREQ= option specifications. When the COLORRESPONSE= option is
specified, the following values are valid:

SUM
MEAN
When the COLORRESPONSE= option is not specified and
COLORBYFREQ=TRUE is in effect, the following values are valid:

FREQ frequency count


PCT percentages between 0 and 100
PROPORTION proportions between 0 and 1

Defaults FREQ when the COLORRESPONSE= option is not specified and


COLORBYFREQ=TRUE is in effect.

SUM when the COLORRESPONSE= option is specified.

Interactions This option is ignored when the COLORRESPONSE= option is not


specified and COLORBYFREQ=FALSE is in effect.
BARCHART Statement 227

This option might affect existing SAS programs. For programs written
before the third maintenance release of SAS 9.4, if STAT= and
COLORRESPONSE= are specified in a BARCHART statement, then
the bar-chart colors and color statistic might change from those of the
previous SAS releases. To restore the original colors and color statistic
in that case, set COLORSTAT= in the BARCHART statement to the
same statistic that is specified in STAT=.

Note This option is independent of the STAT= and RESPONSE= options.

See COLORBYFREQ= on page 224

COLORRESPONSE= on page 225

STAT= on page 240

“Example 3: Bar Chart with Bar Colors Controlled by a Statistic” on


page 249

CONNECTATTRS=style-element | style-element (line-options) | (line-options)


specifies the appearance of the bar connect lines.

Default The GraphConnectLine style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN


enhances the visual appearance of the filled bars. The following figure shows bars
with each of the skins applied.

Default The DATASKIN= option value that is specified in the


BEGINGRAPH statement. If not specified, then the
GraphSkins:DataSkin style element value is used.

Restriction Starting with the first maintenance release of SAS 9.4, the maximum
number of skinned graphical elements is limited to 200 per plot in an
overlay or prototype layout. When this limit is exceeded for a plot,
228 Chapter 6 • Plot Statements

the specified data skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.

Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.

Interactions This option overrides the BEGINGRAPH statement DATASKIN=


option.

The data skin appearance is based on the FILLATTRS= color.

When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.

When FILLTYPE=GRADIENT is in effect, DATASKIN=SHEEN is


ignored. In that case, use one of the other skins.

DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, connect line, and
bar labels, if displayed.

Default 0

Range 0–1, where 0 is opaque and 1 is entirely transparent

Tip The FILLATTRS= option can be used to set transparency for just the filled
bar area. You can combine this option with FILLATTRS= to set one
transparency for the bar outlines and connect lines but a different
transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.

Default 0 (no offset, all bars are centered on the category midpoints)

Range -0.5 to +0.5, where 0.5 represents half the distance between category ticks.
Normally, a positive offset is to the right when ORIENT=VERTICAL, and
up when ORIENT=HORIZONTAL. (If the layout's axis options set
REVERSE=TRUE, then the offset direction is also reversed.)

Tip Setting the discrete offset for the plots does not affect the axis minimum
and maximum offsets. In some cases, setting a discrete offset can cause
clipping at each end of the axis. In those cases, use the OFFSETMIN= and
OFFSETMAX= axis options to increase the axis minimum and maximum
offsets to accommodate the discrete offset.

See “About the DISCRETEOFFSET= Option” on page 245

Chapter 8, “Axis Options in Layouts,” on page 889 for information about


the REVERSE=, OFFSETMIN=, and OFFSETMAX= axis options

ORIENT=

DISPLAY=STANDARD | ALL | (display-options)


specifies which bar features to display.
BARCHART Statement 229

STANDARD
displays outlined, filled bars
ALL
displays outlined, filled bars, and connect lines
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:
OUTLINE
displays outlined bars.
FILL
displays bars with a solid fill.
CONNECT
displays line segments connecting adjacent midpoints at the end of each bar.
FILLPATTERN
displays bars with a patterned fill. This setting is used primarily for grouped
bar charts that must be rendered in monochrome for use in a journal article.
The fill patterns make it easier to distinguish among groups when color is not
available.

Default STANDARD

Restriction Connect lines are not drawn for grouped data.

Note The connect lines are drawn in axis order starting with the third
maintenance release of SAS 9.4. They are drawn in data order in prior
releases.

Tips Use the OUTLINEATTRS=, FILLATTRS=, and


FILLPATTERNATTRS= options to control the appearance of the bars.

Use CONNECTATTRS= to control the appearance of the connect lines.

You can specify both FILL and FILLPATTERN to combine solid fills
and pattern fills in the bars.

DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
A zero-length bar is displayed as a line spanning the normal bar width at the bar-
chart baseline on the response axis. When this option is set to TRUE, zero-length
bars are displayed. Otherwise, they are suppressed. The following figure shows a
simple example of each outcome. In the figure, the plot wall outline, category axis
line, and bar-chart baseline are suppressed for clarity.
230 Chapter 6 • Plot Statements

Default TRUE

Interaction This option is ignored when the GROUP= and


GROUPDISPLAY=STACK options are in effect. In that case, zero-
length bar segments are drawn.

Note When this option is set to FALSE, the bar is not drawn, but other
elements associated with the bar such as the target bar, the error bar, the
bar label, and the data label, are drawn.

Tip This option is useful when the bar-chart baseline is suppressed.

FILLATTRS=style-element | style-element (fill-options) | (fill-options)


specifies the appearance of the filled bar area.

Defaults For non-grouped data, the GraphDataDefault:Color style reference

For grouped data, the Color attribute of the GraphData1–GraphDataN


style elements.

Interaction When COLORRESPONSE= is in effect and the DISPLAY= option


enables FILL display, the FILLATTRS= suboption COLOR= is
ignored, and the bar fill colors vary according to the gradient.

Tip The DATATRANSPARENCY= option sets the transparency for the bar
fills, bar outlines, and connect lines. You can combine this option with
DATATRANSPARENCY= to set one transparency for the bar outlines
and connect lines but a different transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Fill Options” on page 1348 for available fill-options.

FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled bar area.
style-element
specifies the name of a style element. You can specify only one of the elements
GraphData1–GraphDataN.

Restriction The only styles that are delivered by SAS that support fill patterns
are JOURNAL2, JOURNAL3, and MONOCHROMEPRINTER. If
any other such style is in effect and this option uses style-element in
its specification, then this option is ignored.

(fill-pattern-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:
COLOR=color | style-reference
specifies a color to use for the bar-fill-pattern lines. With grouped data, the
COLOR= setting has the effect of holding the fill color constant across all
group values.
PATTERN=line-pattern
specifies a line pattern to use for the bar fill.
BARCHART Statement 231

To specify a line-pattern, combine a line-direction prefix (R for right, L for


left, and X for cross hatch) with a line-identification number:

With grouped data, the PATTERN= setting has the effect of holding the fill
pattern constant across all group values.

Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.

See DISPLAY=

FILLTYPE=SOLID | GRADIENT
specifies the bar fill type.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
SOLID
each bar is filled with the color that is assigned to that bar.
GRADIENT
an alpha gradient is used to determine the bar fill color. Each bar is filled with a
color and a transparency gradient that starts at the bar top with the specified fill
color and transparency, and transitions to fully transparent at the bar baseline.
The initial fill color is determined by a style element or by the FILLATTRS=
option COLOR= suboption. The initial transparency is determined by the
DATATRANSPARENCY= option or by the FILLATTRS= option
TRANSPARENCY= suboption.

Interactions The SHEEN data skin cannot be used when


FILLTYPE=GRADIENT is in effect. You can use one of the other
data skins.

In the second maintenance release of SAS 9.4,


FILLTYPE=GRADIENT is ignored when
GROUPDISPLAY=STACK is in effect. Starting with the third
maintenance release of SAS 9.4, FILLTYPE=GRADIENT is
honored in that case.

Tips Use the DATATRANSPARENCY= option or the FILLATTRS=


option TRANSPARENCY= suboption to set the initial
transparency in the gradients.

For grouped plots, use the FILLATTRS= option in a discrete


attribute map to set the initial transparency in the gradients for
specific values.
232 Chapter 6 • Plot Statements

See DATASKIN= on page 227

Default SOLID

Interaction The DISPLAY= option must include FILL for this option to have any
effect.

GROUP=column | discrete-attr-var | expression


creates a separate bar segment or bar for each unique group value in the specified
column.
discrete-attr-var
specifies a discrete attribute map variable that is defined in a
DISCRETEATTRVAR statement.

Restriction A discrete attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set by a
dynamic variable.

For example, the sashelp.Cars data used in the “Example Program” on page 247
contains a column named Origin, which identifies the region that produces each car.
This column could be used in the BARCHART statement to group the bars in the
display (see the GROUPDISPLAY= option to see the output for the grouped bars):
layout overlay;
barchart category=type response=mpg_highway /
stat=mean group=origin name="b";
discretelegend "b" / title="Regions:";
endlayout;

Defaults If bar fills or fill patterns are enabled by the ODS style or by the
DISPLAY= option, then each distinct group value is represented in the
plot by a different fill color or fill pattern. The fill colors are defined
by the Color attribute of the GraphData1–GraphDataN and
GraphMissing style elements. The fill patterns are defined by the
FillPattern attribute of the GraphData1–GraphDataN and
GraphMissing style elements.

If bar outlines are enabled by the ODS style or by the DISPLAY=


option, then each distinct group value is represented in the plot by a
different outline. The outline colors are defined by the ContrastColor
attribute of the GraphData1–GraphDataN and GraphMissing style
elements.

Interactions Connect lines are not drawn for grouped data.

By default, the group values are mapped in the order of the data. Use
the GROUPORDER= option to control the sorting order of the
grouped bar segments. Use the INDEX= option to alter the default
sequence of colors and line patterns.

The INCLUDEMISSINGGROUP option controls whether missing


group values are considered a distinct group value.

When both the GROUP= and COLORRESPONSE= options are


specified, the color attributes are controlled by the
COLORRESPONSE= option.
BARCHART Statement 233

Note The bar display depends on the setting for the GROUPDISPLAY=
option.

Tip The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the bar outlines, but you can
use the PATTERN= setting on the OUTLINEATTRS= option to assign
the same line pattern to all bar outlines and connect lines.

See “DISCRETEATTRVAR Statement” on page 1297

GROUP100=NONE | MAGNITUDE | POSITIVE


displays the computed response values (FREQ, SUM, or MEAN), normalized to
100%.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
NONE
displays the summarized data.
MAGNITUDE
normalizes both the negative and positive values to 100% by magnitude, and
displays the group values, preserving the sign. The positive values are displayed
above the bars for a vertical bar chart and on the right end for a horizontal bar
chart. The negative values are displayed enclosed in parentheses below the bars
for a vertical bar chart and on the left end for a horizontal bar chart.
The following figure illustrates the effect of MAGNITUDE on stacked bars in a
vertical bar chart.

POSITIVE
drops the negative values and normalizes only the positive values to 100%. The
following figure demonstrates the effect of POSITIVE on clustered bars in a
vertical bar chart. This chart uses the same data as the chart in the previous
figure.
234 Chapter 6 • Plot Statements

Notice that the negative values are dropped from the chart.

Default NONE

Requirement The GROUP= option must be specified for this option to have any
effect.

Interaction When this option is used, the BASELINEINTERCEPT= and


TARGET= options are ignored.

Note You can use this option with any value for the GROUPDISPLAY=
option.

Tip To display the values, specify BARLABEL=TRUE.

GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
STACK
displays group values as stacked segments within the category bar.

CLUSTER
displays group values as separate adjacent bars that replace the single category
bar. Each cluster of group values is centered at the category midpoint on the axis.
This example illustrates the clusters and also how groups are displayed when
they have an unequal number of unique values.
BARCHART Statement 235

Default STACK

Interaction When you use the BARLABEL= option and the GROUP= option, the
BARLABEL values are displayed for each bar when
GROUPDISPLAY=CLUSTER. When GROUPDISPLAY=STACK, the
whole bar is labeled at the top.

Tip For a linear response axis, when STAT=MEAN or STAT=PCT, the axis
tick values might be displayed as integer values when
GROUPDISPLAY=STACK. Changing GROUPDISPLAY= to
CLUSTER in that case might cause the axis values to change to
decimal values. To keep the integer axis values in both cases, you can
specify the INTEGER=TRUE option for the response axis. See
INTEGER= on page 915.

GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING


specifies the ordering of the groups within a category.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.

Tip This option is useful when you want to reverse the category axis.

ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.

Default DATA

Interactions This option is ignored if the GROUP= option is not also specified.

By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
236 Chapter 6 • Plot Statements

Notes Attributes such as color, symbol, and pattern are assigned to each
group in the DATA order by default, regardless of the
GROUPORDER= option setting.

The ASCENDING and DESCENDING settings linguistically sort the


group values within each category (or X value) for display position
purposes only. For numeric data, the order is based on the unformatted
values. For character data, the order is based on the formatted values.
The data order of the observations and the visual attributes that are
assigned to the group values remain unchanged.

INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.

Default TRUE

Interaction For this option to take effect, the GROUP= option must also be
specified.

Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in effect,
the INDEX= option is used, the MISSING= system option changes the
default missing character, or a user-defined format is applied to the
group value. In those cases, the attributes of the missing group value
are determined by a GraphData1–GraphDataN style element instead of
by the GraphMissing style element.

See “boolean ” on page 1339 for other Boolean values that you can use.

INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.

Requirements The column or expression value must be an integer value of 1 or


greater. Otherwise, this option is ignored.

The positive-integer column must not contain missing values.


Otherwise, the entire column is invalidated and this option is
ignored.

All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.

Interaction For this option to take effect, the GROUP= option must also be
specified.

Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N, then
a modulo operation remaps that index value to a number less than N
to determine which style to use.

If you do not use this option, then the group values are mapped in
the order of the data.

Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 183.
BARCHART Statement 237

INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval width.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.

Default The width specified by the BARWIDTH= option.

Restriction This option applies only to a linear or time category axis. When the
category axis is discrete, this option is ignored.

Interaction When the category data is interval, this option overrides the
BARWIDTH= option.

Tip To make the category axis type linear or time, include TYPE=LINEAR
or TYPE=TIME in the category axis options or assign the role of
primary plot to a plot that makes the category axis linear or time.

See “dimension” on page 1340

LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.

Default The response-variable label. If a label is not defined, then the response-
variable name is used.

Restriction This option applies only to an associated DISCRETELEGEND


statement.

Interaction If the GROUP= option is specified, then this option is ignored.

NAME="string"
assigns a name to this plot statement for reference in other template statements. The
specified name is used primarily in legend statements to coordinate the use of colors
and line patterns between the plot and the legend.

Restriction The string is case sensitive, cannot contain spaces, and must define a
unique name within the template.

Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.

ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.

Default VERTICAL

Notes When this option is set to HORIZONTAL, the category variable appears on
the Y (or Y2) axis and the response variable appears on the X (or X2) axis.
To set the axis properties for this chart, you should use the appropriate axis
options of the layout container.

When this option is set to VERTICAL, the category variable appears on the
X (or X2) axis and the response variable appears on the Y (or Y2) axis. To
set the axis properties for this chart, you should use the appropriate axis
options of the layout container.
238 Chapter 6 • Plot Statements

If you change the orientation of the bar chart, then you should adjust the
layout container’s axis options appropriately.

OUTLINEATTRS=style-element | style-element (line-options) | (line-options)


specifies the appearance of the bar outlines.

Defaults For non-grouped data, the ContrastColor, LineThickness, and


LineStyle attributes of the GraphOutlines style element.

For grouped data and filled bars, the ContrastColor attribute of the
GraphData1–GraphDataN style elements, and the LineThickness and
LineStyle attributes of the GraphOutlines style element.

For grouped data and unfilled bars, the ContrastColor and LineStyle
attributes of the GraphData1–GraphDataN style elements, and the
LineThickness attribute of the GraphOutlines style element.

Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.

If the DATASKIN= option applies a data skin, then this option is


ignored.

When the COLORRESPONSE= and DISPLAY=(OUTLINE) options


are in effect, the OUTLINEATTRS= suboption COLOR= is ignored,
and the bar outline colors vary according to the gradient.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for determining
default axis features. This option is needed only when two or more plots within an
overlay-type layout contribute to a common axis.

Default FALSE

Restriction This option is ignored if the plot is placed under a GRIDDED or


LATTICE layout block.

Note In an OVERLAY layout, only one plot in an overlay can be the primary
plot on a per-axis basis. When no plot is designated as the primary plot,
the first plot that can be a primary plot is considered the primary plot. If
multiple plots specify PRIMARY=TRUE for the same axis, then the
last such plot encountered is considered the primary plot.

See “When Plots Share Data and a Common Axis” on page 880

“boolean ” on page 1339 for other Boolean values that you can use.

SEGMENTLABEL=TRUE | FALSE
specifies whether a label is displayed inside each bar segment.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
BARCHART Statement 239

For an ungrouped bar chart or for a grouped bar chart with


GROUPDISPLAY=CLUSTER, AUTO displays a bar label inside each bar. The label
displays the statistic for that bar. For a grouped bar chart with
GROUPDISPLAY=STACK, AUTO displays a label inside each bar segment. Each
segment label displays the statistic for that bar segment, as shown in the following
figure.

When this value is set to FALSE, no labels are displayed inside the bars.

Default FALSE

Tips For a grouped bar chart with GROUPDISPLAY=STACK, specify both


SEGMENTLABEL=TRUE and BARLABEL=TRUE to display a label for
each bar segment and a label for the entire bar.

Use the SEGMENTLABELATTRS= option to modify the appearance of


the label text.

Use the SEGMENTLABELFITPOLICY= option to specify a policy for


fitting the labels inside the bars.

Use the SEGMENTLABELFORMAT= option to modify the format of the


segment labels.

See “boolean ” on page 1339 for other Boolean values that you can use.

SEGMENTLABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the text for the bar segment label.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The GraphDataText style element.

Interaction This option is ignored when SEGMENTLABEL=FALSE.

See “General Syntax for Attribute Options” on page 1347 for the syntax for
using a style-element.

“Text Options” on page 1351 for available text-options.


240 Chapter 6 • Plot Statements

SEGMENTLABELFITPOLICY=NONE | NOCLIP | THIN


specifies a policy for fitting the bar segment labels within the bar segments.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
NONE
no attempt is made to fit each segment label within its bar. Long bar segment
labels might overlap other graphical elements. The segment labels are not
considered when the axis ranges are computed. As a result, segment labels that
extend beyond the plot area are clipped.
NOCLIP
does not clip bar segment labels that extend beyond the plot area. Labels that do
not fit within the plot area extend into the graph axis area and might overlap axis
elements.
THIN
drops any bar segment label that does not fit within its segment. For a vertical bar
chart, the label width must not exceed the bar width, and the text height must not
exceed the segment height. For a horizontal bar chart, the label text height must
not exceed the bar width, and the label length must not exceed the segment
length.

Default THIN

Interaction This option is ignored when SEGMENTLABEL=FALSE.

SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The column format assigned to the RESPONSE= column, or BEST6 if


no format is assigned.

Interaction This option is ignored when SEGMENTLABEL=FALSE.

STAT=FREQ | PCT | SUM | MEAN | PROPORTION


specifies the statistic to be computed for the Y-axis. For bar charts with no
RESPONSE= column:

FREQ frequency count


PCT percentages between 0 and 100
PROPORTION proportions between 0 and 1
Note: Prior to SAS 9.4, PCT displayed proportions between 0 and 1. To restore the
original PCT results in SAS 9.4 and later releases, specify PROPORTION
instead.
For bar charts with a RESPONSE= column:

SUM
MEAN

Defaults For bar charts with no RESPONSE= column, the default is FREQ.

For bar charts with a RESPONSE= column, the default is SUM.


BARCHART Statement 241

Note When this option is used with the GROUP=group option, the specified
statistic is computed for each segment that is created for the unique group
values.

Tip If this option is used with COLORRESPONSE= in SAS programs that


were written before the third maintenance release of SAS 9.4, the bar-
chart colors and color statistic might change from those of the previous
SAS releases. To restore the original colors and color statistic, set
COLORSTAT= in the BARCHART statement to the same statistic that is
specified in STAT=.

TARGET=numeric-column | expression
specifies the target value for each bar. The visual representation is a triangle with a
line at the target value.
layout overlay;
barchart category=type response=mpg_highway / barwidth=.8
target=mpg_city group=origin groupdisplay=cluster
name='bar';
discretelegend 'bar';
endlayout;

Default No targets are displayed.

Interactions For this option to take effect, the RESPONSE= argument must also be
used.

If the GROUP= option is used and GROUPDISPLAY= STACK, then


this option is ignored.

This option is ignored when the GROUP100= option is used.

Tips The statistic indicated by the STAT= option applies to the


TARGET=column. If a constant value is desired for each target, then
specify it only once for repeated category (X) values (or category and
GROUP combinations), and leave the other target values missing.

The target color is that of the bar outline.


242 Chapter 6 • Plot Statements

TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar. If this
option is used, then the information specified replaces all of the information that is
displayed by default.
(role-list)
an ordered, space-separated list of unique BARCHART roles. BARCHART roles
include CATEGORY or X, RESPONSE or Y, COLORRESPONSE, INDEX,
GROUP, and TARGET.

Notes For the category and response roles, the TIP= option recognizes only
the category and response arguments that you use in the BARCHART
statement. If you use the CATEGORY= and RESPONSE= arguments,
then you must specify roles CATEGORY and RESPONSE.
Conversely, if you use the X= and Y= arguments, then you must
specify roles X and Y.

The COLORRESPONSE role is valid starting with the third


maintenance release of SAS 9.4.

Example The following example displays data tips for the columns assigned
only to the roles CATEGORY and RESPONSE:

TIP=(CATEGORY RESPONSE)

NONE
suppresses data tips and URLs (if requested) from the plot.

Default The columns assigned to these roles are automatically included in the
data tip information: CATEGORY or X, RESPONSE or Y,
COLORRESPONSE, and GROUP.

Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement with the IMAGEMAP option specified,
and you must write the output to the ODS HTML destination.

Interaction This option is ignored when the plot statement is in an OVERLAY or


PROTOTYPE layout and the INCLUDERANGES= option is
specified in the LINEAROPTS= or TIMEOPTS= option for either
axis.

Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.

TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control the
formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.

Example TIP=(RESPONSE)
TIPFORMAT=(RESPONSE=DOLLAR12.)

Default The column format of the column assigned to the role or BEST6 if no
format is assigned to a numeric column.
BARCHART Statement 243

Restriction Only the roles that appear in the TIP= option are used.

Requirement A column must be assigned to each of the specified roles.

TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control the
labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.

Example TIP=(RESPONSE)
TIPLABEL=(RESPONSE="Average Sales")

Default The column label or column name of the column assigned to the role.

Restriction Only the roles that appear in the TIP= option are used.

Requirement A column must be assigned to each of the specified roles.

URL=string-column
specifies an HTML page to display when the bar is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for each
bar that is to have an active link.

Example http://www.sas.com/technologies/analytics/
index.html

Requirement To generate selectable bars, you must include an ODS GRAPHICS


ON statement that has the IMAGEMAP option specified, and you
must write the output to the ODS HTML destination.

Interactions This option has no effect when TIP=NONE.

This option is ignored when the plot statement is in an OVERLAY or


PROTOTYPE layout and the INCLUDERANGES= option is
specified in the LINEAROPTS= or TIMEOPTS= option for either
axis.

Notes For non-grouped data, the values of the column are expected to be
same for each unique category value. If they are not, then the results
might be unpredictable.

For grouped data, the values of the column are expected to be the
same for each unique category and GROUP combination.

Tips The URL value can be blank for some category values, meaning that
no action is taken when the bars for those category values are
selected.

The URL value can be the same for different category values,
meaning that the same action is taken when the bars for those
category values are selected.
244 Chapter 6 • Plot Statements

XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the secondary
X2 (top) axis.

Default X

Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2
(right) axis.

Default Y

Interactions This option is ignored if the RESPONSE= argument is not specified.

The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 875.

Details

Statement Description
The BARCHART statement creates a bar chart with bars that represent summarized
response values. The response values are categorized by the unique category values or,
starting with the third maintenance release of SAS 9.4, by the bins in binned category
data. The BARCHART statement takes nonsummarized data as input and calculates the
appropriate summarization statistics (sum, mean, and so on) for each unique category
value or category bin. Prior to the third maintenance release of SAS 9.4, the category
axis for a bar chart must be discrete. Starting with the third maintenance release of SAS
9.4, the category axis can be discrete, linear, or time. The response axis in all cases is
interval.
When the chart is oriented vertically, the X (or X2) axis is used for CATEGORY and the
Y (or Y2) axis is used for RESPONSE. When it is oriented horizontally, the X (or X2)
axis is used for RESPONSE and the Y (or Y2) axis is used for CATEGORY. (See
ORIENT= on page 237.)
By default, if the category column is character, then the bars in the chart appear in the
order in which the category values are present in the input data. If the category column is
numeric, then the values are presented in ascending order. For non-grouped data,
duplicated category values are summarized into a unique value. For grouped data, the
category values are summarized as needed. (See the GROUP= option.)
Starting with the third maintenance release of SAS 9.4, for numeric category values, an
interval bar chart is generated only when the category axis type is linear or time. To
specify a category axis type of linear or time, include the TYPE= option in the category
axis options, or assign the role of primary plot to a plot that sets the category axis type to
linear or time automatically. By default, a bar is drawn for each unique category value,
which can result in a large number of bars for numeric category data.
When binning is used, for each bin, a summarization statistic is computed, and a bar is
drawn that represents that statistic. The width of each bar spans the width of the bin that
it represents. The left-most edge of the bar represents the start of the bin, and the right-
most edge represents the end. See “Example 1: Horizontal Bar Chart” on page 247.
BARCHART Statement 245

TIP Prior to the third maintenance release of SAS 9.4, use the HISTOGRAM
statement to create a bar chart that represents response values along an interval axis.

About the DISCRETEOFFSET= Option


The DISCRETEOFFSET= option is useful for graphing multiple response variables side
by side on a common axis. By default within an overlay-type layout, if multiple
BARCHART statements are used with different response variables, then the bars for
matching category values are centered on the midpoints and the bars are superimposed.
To make it easier to distinguish among superimposed bars, you can assign a different
BARWIDTH= setting to each BARCHART statement in the overlay:
layout overlay / cycleattrs=true
xaxisopts=(display=(tickvalues))
yaxisopts=(label="Revenue" offsetmax=0.2);

barchart category=year response=A_revenue / stat=sum name="A"


legendlabel="A" barwidth=0.8 ;
barchart category=year response=B_revenue / stat=sum name="B"
legendlabel="B" barwidth=0.6 ;
barchart category=year response=C_revenue / stat=sum name="C"
legendlabel="C" barwidth=0.4 ;

discretelegend "A" "B" "C" / title="Product:"


location=inside halign=right valign=top;
endlayout;

To place the different response values side by side, you can assign a different offset to
each BARCHART statement. The BARWIDTH= option can be used with
DISCRETEOFFSET= to create narrower bars that require less width within the plot
area:
layout overlay / cycleattrs=true
xaxisopts=(display=(tickvalues))
yaxisopts=(label="Revenue" offsetmax=0.2);

barchart category=year response=A_revenue / stat=sum name="A"


legendlabel="A"
discreteoffset=-0.3 barwidth=0.3 ;
barchart category=year response=B_revenue / stat=sum name="B"
legendlabel="B"
246 Chapter 6 • Plot Statements

discreteoffset=0 barwidth=0.3 ;
barchart category=year response=C_revenue / stat=sum name="C"
legendlabel="C"
discreteoffset=+0.3 barwidth=0.3 ;

discretelegend "A" "B" "C" / title="Product:"


location=inside halign=right valign=top;
endlayout;

Different combinations of DISCRETEOFFSET and BARWIDTH can be used to get the


effect that you want. Gaps can be created between bars by providing a narrower bar
width. Or, bars can be overlapped if the bar widths are increased in proportion to the
discrete offset.
layout overlay / cycleattrs=true
xaxisopts=(display=(tickvalues))
yaxisopts=(label="Revenue" offsetmax=0.2);

barchart category=year response=A_revenue / stat=sum name="A"


legendlabel="A" datatransparency=0.2
discreteoffset=-0.2 barwidth=0.5 ;
barchart category=year response=B_revenue / stat=sum name="B"
legendlabel="B" datatransparency=0.2
discreteoffset=0 barwidth=0.5 ;
barchart category=year response=C_revenue / stat=sum name="C"
legendlabel="C" datatransparency=0.2
discreteoffset=+0.2 barwidth=0.5 ;

discretelegend "A" "B" "C" / title="Product:"


location=inside halign=right valign=top;
endlayout;
Example 1: Horizontal Bar Chart 247

Examples

Example 1: Horizontal Bar Chart


The following graph was generated by the “Example Program” on page 247:

Example Program
proc template;
define statgraph barchart;
begingraph;
entrytitle "Average Mileage by Vehicle Type";
layout overlay;
barchart category=type response=mpg_highway /
stat=mean orient=horizontal;
endlayout;
248 Chapter 6 • Plot Statements

endgraph;
end;

proc sgrender data=sashelp.cars template=barchart;


run;

Example 2: Interval Bar Chart


Interval bar charts are available starting with the third maintenance release of SAS 9.4.
In the second maintenance release of SAS 9.4 and in earlier releases, use the
HISTOGRAM statement to generate an interval bar chart. The following graph was
generated by the “Example Program” on page 248:

Example Program
Here is the SAS code.
proc template;
define statgraph cylinders;
begingraph;
entrytitle "Interval Bar Chart of Vehicle Engine Cylinders";
layout overlay /
xaxisopts=(label="Engine Cylinders" type=linear
linearopts=(tickvaluelist=(3 4 5 6 8 10 12)))
yaxisopts=(label="Percentage of Vehicles Manufactured"
griddisplay=on linearopts=(tickvalueformat=percent7.1));
barchart category=cylinders / stat=proportion
barlabel=true barlabelformat=percent7.1;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.cars template=cylinders;


Example 3: Bar Chart with Bar Colors Controlled by a Statistic 249

run;

Details
An interval bar chart can be generated only when the category axis type is LINEAR or
TIME. In this example, the TYPE=LINEAR option is included in the XAXISOPTS=
options. With numeric category data, a bar is drawn for each unique category value. In
some cases, that can generate too many bars in the resulting chart. In this example, there
are only seven unique values. The TICKVALUELIST= option is used in the
XAXISOPTS= option to display all of the values on the category axis.

Example 3: Bar Chart with Bar Colors Controlled by a Statistic


The ability to use a computed statistic to control the bar colors in a bar chart is available
starting with the third maintenance release of SAS 9.4. This example uses the
COLORBYFREQ=TRUE option to enable a computed statistic to control the bar colors
and the COLOSTAT=PCT to specify percentage as the controlling statistic. Here is the
output from “Example Program” on page 249.

Example Program
proc template;
define statgraph barchart;
begingraph;
entrytitle "Average Mileage by Vehicle Type";
layout overlay;
barchart category=type response=mpg_highway / name="bar"
stat=mean orient=horizontal
colorbyfreq=true colorstat=pct;
continuouslegend "bar" /
title="Percent of Total Models Manufactured";
endlayout;
endgraph;
end;
run;
250 Chapter 6 • Plot Statements

proc sgrender data=sashelp.cars template=barchart;


run;

BARCHARTPARM Statement
Creates a bar chart specified by pre-summarized data.
Requirement: The input data must be pre-summarized, with appropriate summarization statistics
(sum, mean, and so on) computed for the RESPONSE column.
Tips: For charts that have a large number of bars that are very close together, slight
variations in spacing that normally occur due to integer rounding can become more
obvious. Subpixel rendering provides more precise bar spacing in that case. In the
second maintenance release of SAS 9.4 and in earlier releases, specify
SUBPIXEL=ON in the BEGINGRAPH statement to enable subpixel rendering. See
SUBPIXEL= on page 33. Starting with the third maintenance release of SAS 9.4,
subpixel rendering is enabled by default.
To disable subpixel rendering in the third maintenance release of SAS 9.4 and in
later releases, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
SUBPIXEL= option, see SUBPIXEL= on page 33. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” in
SAS ODS Graphics: Procedures Guide.

Syntax
BARCHARTPARM CATEGORY=column | expression
RESPONSE=numeric-column | expression </option(s)>;

Summary of Optional Arguments

Appearance options
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing
or bin width.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
COLORRESPONSE=numeric-column | range-attr-var | expression
specifies the column or range attribute variable to use to map the bar colors to
a continuous color gradient.
CONNECTATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar connect lines.
DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN
enhances the visual appearance of the filled bars.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, error bars,
connect line, and data labels, if displayed.
BARCHARTPARM Statement 251

DISPLAY=STANDARD | ALL | (display-options)


specifies which bar features to display.
DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
ERRORBARATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the error bars associated with the bars.
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
ERRORLOWER=numeric-column | expression
specifies the values of the lower endpoints on the Y error bars.
ERRORUPPER=numeric-column | expression
specifies the values of the upper endpoints on the Y error bars.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the filled bar area.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled bar area.
FILLTYPE=SOLID | GRADIENT
specifies the bar fill type.
INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval
width.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar outlines.
TARGET=numeric-column | expression
specifies the target value for each bar.

Axes options
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.

Data tip options


ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar.
TIPFORMAT=(role-format-list)
252 Chapter 6 • Plot Statements

specifies display formats for tip columns.


TIPLABEL=(role-label-list)
specifies display labels for tip columns.

Label options
DATALABEL=column | expression
specifies the label that appears at the end of each bar.
DATALABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the labels that are specified in the
DATALABEL= option.
DATALABELFITPOLICY=AUTO | NONE | ROTATE | SPLIT | SPLITALWAYS
specifies a policy for avoiding collisions among the bar labels when labels
are displayed.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed data
labels.
DATALABELTYPE=AUTO | COLUMN
specifies whether the data labels display the RESPONSE values or the values
of the column that is specified by the DATALABEL= option.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
SEGMENTLABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the text properties of the text for the bar segment label.
SEGMENTLABELFITPOLICY=NONE | NOCLIP | THIN
specifies a policy for fitting the bar segment labels within the bar segments.
SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
SEGMENTLABELTYPE=NONE | AUTO
specifies whether a label is displayed inside each bar segment.

Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
GROUP=column | discrete-attr-var | expression
creates a separate bar segment or bar for each unique group value in the
specified column.
GROUP100=NONE | MAGNITUDE | POSITIVE
displays the response values, normalized to 100%.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.

ODS options
URL=string-column
BARCHARTPARM Statement 253

specifies an HTML page to display when the bar is selected.

Plot reference options


NAME="string"
assigns a name to this plot statement for reference in other template
statements.

Required Arguments
CATEGORY=column | expression
specifies the column for the unique category values. All values are treated as
discrete.

Note You can use X= as an alternative to CATEGORY=. If you use X=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will recognize
X as the category role and not CATEGORY in that case.

RESPONSE=numeric-column | expression
specifies the column for the response values.

Note You can use Y= as an alternative to RESPONSE=. If you use Y=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will recognize
Y as the response role and not RESPONSE in that case.

Optional Arguments
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.

Default 0.85

Range 0.1–1, where 0.1 is the narrowest and 1 is the widest

Interaction Starting with the third maintenance release of SAS 9.4, the
INTERVALBARWIDTH= option overrides this option for an interval
bar chart.

Notes This option is needed only to change the default behavior.

By default, the bar width automatically adjusts based on the number of


bars to be displayed and the wall width.

Tip To remove any inter-bar gap, set BARWIDTH=1.

BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.

Default The GraphAxisLines style element.

Notes The baseline is always drawn by default.

When style-element is specified, only the style element’s COLOR,


LINESTYLE, and LINETHICKNESS attributes are used.

Tip To suppress the baseline, set the line thickness to 0:


baselineattrs=(thickness=0)
254 Chapter 6 • Plot Statements

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline. The baseline is always
displayed in the chart, whether for a specified value or for the default value. When
this option is used, the axis range is adjusted to include the baseline, and the baseline
is placed at the specified value on the response axis.

Default 0

Interactions If GROUPDISPLAY=STACKED is specified, then this option is


ignored and the baseline is not displayed.

If necessary, the response axis data range is extended to include the


baseline intercept. When a logarithmic response axis is requested and
BASELINEINTERCEPT= specifies 0 or a negative value, the
response axis reverts to a linear axis. To restore the log axis in that
case, set BASELINEINTERCEPT= to a positive value.

Note Label positions are automatically adjusted to prevent the labels from
overlapping.

Tips Control the appearance of the baseline with the BASELINEATTRS=


option.

To suppress the baseline, use the BASELINEATTRS= option to set


the line thickness to 0.

The baseline does not add a tick or a tick value to the axis. To label the
baseline, use a REFERENCELINE statement to overlay a line with the
same X or Y value and include the CURVELABEL= option to specify
the label text.

CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or bin
width.
BARCHARTPARM Statement 255

Default 0.85

Range 0.1–1, where 0.1 is the narrowest possible width and 1 is the widest
width.

Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.

Interaction When GROUPDISPLAY=CLUSTER, the default BARWIDTH is


1.0.

COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element. The style element should
contain these style attributes:

STARTCOLOR specifies the color for the smallest data value of the
COLORRESPONSE= column.
NEUTRALCOLOR specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR specifies the color for the highest data value of the
COLORRESPONSE= column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can use
style attribute references such as GraphData3:Color, color names, or RGB,
CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.

Requirement The list of colors must be enclosed in parentheses.

See “color ” on page 1340

Defaults For outline-only bars, the ThreeColorAltRamp style element


256 Chapter 6 • Plot Statements

For bars with fill, the ThreeColorRamp style element

Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.

Tip Use the DISPLAY= option to specify whether outlines and fills are
displayed.

COLORRESPONSE=numeric-column | range-attr-var | expression


specifies the column or range attribute variable to use to map the bar colors to a
continuous color gradient.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.

Restriction A range attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set as a
dynamic variable.

When a numeric column or expression is specified, the range of column or


expression values are linearly mapped to the color ramp that is specified by the
COLORMODEL= option. Each bar is colored using one color from the gradient
range. When a range attribute map variable is specified, the colors that are defined in
the associated range attribute map are used instead.

Requirement For a grouped plot, the COLORRESPONSE values should remain


constant for each group value. If the COLORRESPONSE column has
multiple values for a single GROUP value, unexpected results might
occur.

Interactions When the GROUP= option is specified with the


COLORRESPONSE= option, the color attributes are controlled by
the COLORRESPONSE= option.

When fill, fill pattern, or both are displayed, this option overrides
suboption COLOR= in the FILLATTRS= option and in the
FILLPATTERNATTRS= option and varies the color according to the
color gradient or the attribute map.

When only the outlines are displayed, this option overrides suboption
COLOR= in the OUTLINEATTRS= option and varies the outline
color according to the color gradient or the attribute map.

Tips To display a legend with this option in effect, use a


CONTINUOUSLEGEND statement.

Use the FILLTYPE= option to specify whether each bar is filled with
a solid color or with a gradient color.

For a numeric column or expression, the ThreeColorRamp style


element defines the fill color gradient, and the ThreeColorAltRamp
style element defines the outline color gradient.
BARCHARTPARM Statement 257

CONNECTATTRS=style-element | style-element (line-options) | (line-options)


specifies the appearance of the bar connect lines.

Default The GraphConnectLine style element.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Line Options” on page 1349 for available line-options.

DATALABEL=column | expression
specifies the label that appears at the end of each bar.

Interactions Starting with the second maintenance release of SAS 9.4, this option is
ignored when DATALABELTYPE=AUTO.

When the GROUP= option is in effect, the data label values are
displayed only when GROUPDISPLAY=CLUSTER.

If the GROUP= option is in effect and there are multiple input


observations per bar for the GROUP= column, then the value for the
DATALABEL= column should be the same for each observation that
is on the same bar.

DATALABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the color and font attributes of the labels that are specified in the
DATALABEL= option.

Default The GraphDataText style element.

Interaction For this option to take effect, the DATALABEL= option must also be
used.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.

“Text Options” on page 1351 for available text-options.

DATALABELFITPOLICY=AUTO | NONE | ROTATE | SPLIT | SPLITALWAYS


specifies a policy for avoiding collisions among the bar labels when labels are
displayed.
AUTO
selects a collision avoidance policy based on the chart orientation and data type.
For a numeric column with ORIENT=VERTICAL, AUTO rotates the labels if
they do not fit the midpoint spacing. For a character column, AUTO splits the
labels if they do not fit the midpoint spacing.

Note When ORIENT=HORIZONTAL, AUTO always draw the labels


horizontally.

Tip If character labels do not fit after splitting, then try using ROTATE instead
of AUTO.

See ORIENT= on page 273 for information about chart orientation.

BARWIDTH= for information about bar spacing.


258 Chapter 6 • Plot Statements

NONE
does not attempt to fit bar labels that collide.
ROTATE
rotates the bar labels for vertical bars if the labels collide in the available width.

Requirement The chart orientation must be vertical (ORIENT=VERTICAL).

SPLIT
splits the label for vertical bars at a split character only if a split is needed at that
character in order to make the label fit the available space. No split occurs at split
characters that occur where a split is not needed. If the label does not contain any
of the specified split characters, then a split does not occur. In that case, if the
label does not fit the available space, then it might collide with the adjoining
labels.

Requirement The chart orientation must be vertical (ORIENT=VERTICAL).

See the DATALABELSPLITCHAR= option for information about


specifying the split characters

SPLITALWAYS
splits the label for vertical bars at every occurrence of a split character. If the
label does not contain any of the specified split characters, then a split does not
occur.

Requirement The chart orientation must be vertical (ORIENT=VERTICAL).

See the DATALABELSPLITCHAR= option for information about


specifying the split characters

Here is an example of a vertical bar chart where DATALABELFITPOLICY=AUTO


and a numeric column is used as the data labels.

In this case, AUTO rotates the numeric labels to avoid collision.


In some cases, if one or more labels collide when the specified fit policy is used, then
all of the labels are dropped from the display. When that occurs, the following
warning message is written to the SAS log:
WARNING: The bar labels are suppressed. Use DATALABELFITPOLICY=NONE to
BARCHARTPARM Statement 259

force the labels to be displayed.

Default AUTO

Requirement The DATALABEL= option must also be specified.

Interaction When DATALABELTYPE=AUTO is in effect, for a vertical bar


chart, only AUTO, NONE, and ROTATE are valid. All other values
revert to AUTO. For a horizontal bar chart, only AUTO and NONE
are valid. All other values revert to AUTO.

DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split. When multiple
split characters are specified, each character in the list is treated as a separate split
character unless the specified characters appear consecutively in the data label. In
that case, all of the specified split characters together are treated as a single split
character.
When DATALABELFITPOLICY=SPLIT and a data label collision is detected, the
data label is split on a specified split character only if a split is needed at that point in
order to make the label fit. In that case, a split might not occur on every split
character. When DATALABELFITPOLICY=SPLITALWAYS, the data label is split
unconditionally on every occurrence of a split character. If the data label does not
contain any of the specified split characters, then the label is not split.
"character-list"
one or more characters with no space between each character and enclosed in
quotation marks.

Default A blank space

Requirements The list of characters must be enclosed in quotation marks.

Multiple characters must be specified with no space between them.


For example, to specify the split characters a, b, and c, use the
following option:
datalabelsplitchar="abc"

The DATALABELFITPOLICY= option must specify SPLIT or


SPLITALWAYS.

Interactions The DATALABELFITPOLICY= option specifies the policy that is


used to manage the split behavior of the data label.

The DATALABELSPLITCHARDROP= option specifies whether


the split characters are included in the displayed data label or are
dropped.

Notes When multiple characters are specified, the order of the characters
in the list is not significant.

The split characters are case sensitive.

DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed data labels.
260 Chapter 6 • Plot Statements

TRUE
drops a split character from the display when a split occurs at that character. Split
characters at which a split does not occur are left in place. The
DATALABELFITPOLICY= option determines where the labels are split. When
DATALABELFITPOLICY=SPLIT, each label is split at a split character only
where a split is needed in order to make the label fit the available space. At each
split point, the split character is dropped, and the characters that follow the split
character, up to but not including the split character at the next split point, are
wrapped to the following line.
When DATALABELFITPOLICY=SPLITALWAYS, each label is split at every
instance of a split character. All of the split characters are dropped. The
characters that follow each split character, up to but not including the next split
character, are wrapped to the next line.
The following figure shows how label Product*Group*1 is split when the
DATALABELSPLITCHARDROP=TRUE and DATALABELSPLITCHAR="*"
options are specified with the SPLIT and SPLITALWAYS fit policies.

In this example, when DATALABELFITPOLICY=SPLIT, the label is split at the


first occurrence of the asterisk in order to make the label fit. No split is needed at
the second asterisk. The first asterisk is dropped, and Group*1 wraps to the next
line. Notice that the second asterisk is not dropped in this case. When
DATALABELFITPOLICY=SPLITALWAYS, the label is split at every
occurrence of the asterisk. In this case, both asterisks are dropped, and the
characters that follow each asterisk wrap to the next line.
FALSE
includes the split characters in the data label display. The
DATALABELFITPOLICY= option determines how the split characters are
displayed. When DATALABELFITPOLICY=SPLIT, each data label is split at a
split character only where a split is needed in order to make the label fit the
available space. A split might not occur at every split character in the label. At
each split point, the split character remains as the last character in the current
line. The characters that follow the split character, up to and including the split
character at the next split point, are then wrapped to the following line. This
process repeats until the entire data label is displayed.
When DATALABELFITPOLICY=SPLITALWAYS, each data label is split at
every instance of a split character in the label regardless of whether a split is
actually needed. Each split character remains as the last character in the current
line. The characters that follow each split character, up to and including the next
split character, are then wrapped to the next line.
The following figure shows how label Product*Group*1 is split when the
DATALABELSPLITCHARDROP=FALSE and DATALABELSPLITCHAR="*"
options are specified with the SPLIT and SPLITALWAYS fit policies.
BARCHARTPARM Statement 261

In this example, when DATALABELFITPOLICY=SPLIT, the label is split at the


first occurrence of the asterisk in order to make the label fit. No split is needed at
the second asterisk. The characters that follow the first asterisk wrap to the next
line. When DATALABELFITPOLICY=SPLITALWAYS, the label is split at
every occurrence of the asterisk. Each asterisk remains as the last character in the
current line, and the characters that follow are wrapped to the next line.

Default TRUE. A split character is dropped from the data-label display


when a split occurs at that character.

Requirements The DATALABEL= option must also be specified.

The DATALABELFITPOLICY= option must specify SPLIT or


SPLITALWAYS.

Interaction The DATALABELSPLITCHAR= option specifies the split


characters.

See “boolean ” on page 1339 for other Boolean values that you can use.

DATALABELTYPE=AUTO | COLUMN
specifies whether the data labels display the RESPONSE values or the values of the
column that is specified by the DATALABEL= option.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
AUTO
the labels are displayed as follows:
• For an ungrouped bar chart, the summarized value for each bar is placed
above the bar.
• For a grouped bar chart with stacked bars, the total of the summarized
segment values for each bar is placed above the segmented bar.
• For a grouped bar chart with clustered bars, the summarized value for each
bar in the cluster is placed above the bar.

Interactions AUTO overrides the DATALABEL= option.

When AUTO is in effect, some data-label fit policies are


unavailable. See DATALABELFITPOLICY=.

COLUMN
the data labels display the DATALABEL= column values.

Interaction The DATALABEL= option must be specified for COLUMN to


have any effect. If the DATALABEL= option is not specified,
AUTO is used instead.
262 Chapter 6 • Plot Statements

Default COLUMN

DATASKIN=NONE | CRISP | GLOSS | MATTE | PRESSED | SHEEN


enhances the visual appearance of the filled bars. The following figure shows bars
with each of the skins applied.

Default The DATASKIN= option value that is specified in the


BEGINGRAPH statement. If not specified, then the
GraphSkins:DataSkin style element value is used.

Restriction Starting with the first maintenance release of SAS 9.4, the maximum
number of skinned graphical elements is limited to 200 per plot in an
overlay or prototype layout. When this limit is exceeded for a plot,
the specified data skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.

Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.

Interactions This option overrides the BEGINGRAPH statement DATASKIN=


option.

The data skin appearance is based on the FILLATTRS= color.

When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.

When FILLTYPE=GRADIENT is in effect, DATASKIN=SHEEN is


ignored. In that case, use one of the other skins.

DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, error bars, connect
line, and data labels, if displayed.

Default 0

Range 0–1, where 0 is opaque and 1 is entirely transparent


BARCHARTPARM Statement 263

Tip The FILLATTRS= option can be used to set transparency for just the bar
fills. You can combine this option with FILLATTRS= to set one
transparency for the bar outlines, error bars, and connect lines but a
different transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.

Default 0 (no offset, all bars are centered on the category midpoints)

Range -0.5 to +0.5, where 0.5 represents half the distance between category ticks.
Normally, a positive offset is to the right when ORIENT=VERTICAL, and
up when ORIENT=HORIZONTAL. (If the layout's axis options set
REVERSE=TRUE, then the offset direction is also reversed.)

Tip Setting the discrete offset for the plots does not affect the axis minimum
and maximum offsets. In some cases, setting a discrete offset can cause
clipping at each end of the axis. In those cases, use the OFFSETMIN= and
OFFSETMAX= axis options to increase the axis minimum and maximum
offsets to accommodate the discrete offset.

See “About the DISCRETEOFFSET= Option” on page 280

Chapter 8, “Axis Options in Layouts,” on page 889 for information about


the OFFSETMIN= and OFFSETMAX= axis options

ORIENT=

DISPLAY=STANDARD | ALL | (display-options)


specifies which bar features to display.
STANDARD
displays outlined, filled bars
ALL
displays outlined, filled bars and also connect lines
(display-options)
a space-separated list of one or more of the following options enclosed in
parentheses:
OUTLINE
displays outlined bars.
FILL
displays bars with a solid fill.
CONNECT
displays line segments connecting adjacent midpoints at the end of each bar.
FILLPATTERN
displays bars with a patterned fill. This setting is used primarily for grouped
bar charts that must be rendered in monochrome for use in a journal article.
The fill patterns make it easier to distinguish among groups when color is not
available.

Default STANDARD
264 Chapter 6 • Plot Statements

Restriction Neither error bars nor connect lines are displayed for grouped data.

Interaction Connect lines are not drawn for grouped data.

Note Error bars are automatically displayed whenever the ERRORUPPER=


or ERRORLOWER= options are specified.

Tips Use the OUTLINEATTRS= , FILLATTRS= , and


FILLPATTERNATTRS= options to control the appearance of the bars.
Use CONNECTATTRS= to control the appearance of the connect lines.

Both FILL and FILLPATTERN can be specified to combine solid fills


and pattern fills in the bars.

DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
A zero-length bar is displayed as a line spanning the normal bar width at the bar-
chart baseline on the response axis. When this option is set to TRUE, zero-length
bars are displayed. Otherwise, they are suppressed. The following figure shows a
simple example of each outcome. In the figure, the plot wall outline, category axis
line, and bar-chart baseline are suppressed for clarity.

Default TRUE

Interaction This option is ignored when the GROUP= and


GROUPDISPLAY=STACK options are in effect. In that case, zero-
length bar segments are drawn.

Note When this option is set to FALSE, the bar is not drawn, but other
elements associated with the bar such as the target bar, the error bar, the
bar label, and the data label, are drawn.

Tip This option is useful when the bar-chart baseline is suppressed.

ERRORBARATTRS=style-element | style-element (line-options) | (line-options)


specifies the attributes of the error bars associated with the bars.

Defaults For non-grouped data, the GraphError style element.

For grouped data, the LineStyle and LineThickness attributes of the


GraphError style element and the ContrastColor attribute of the
GraphData1–GraphDataN style elements.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.
BARCHARTPARM Statement 265

“Line Options” on page 1349 for available line-options.

ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.

Defaults SERIF in the first maintenance release of SAS 9.4 and earlier releases.

Starting with the second maintanance release of SAS 9.4,


GraphError:CapStyle style reference. If attribute CapStyle is not defined
in the active style, then SERIF is the default value.

Tip The appearance of the error bars is controlled by the


ERRORBARATTRS= option.

ERRORLOWER=numeric-column | expression
specifies the values of the lower endpoints on the Y error bars.

Default The lower segment of the error bars is not drawn.

Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.

Interaction If the GROUP= option is specified with GROUPDISPLAY=STACK


or with GROUP100=POSITIVE or MAGNITUDE, then this option
is ignored.

Tip You can use the ERRORBARATTRS= option to control the


appearance of the error bars.

ERRORUPPER=numeric-column | expression
specifies the values of the upper endpoints on the Y error bars.

Default The upper segment of the error bars is not drawn.

Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.

Interaction If the GROUP= option is specified with GROUPDISPLAY=STACK


or with GROUP100=POSITIVE or MAGNITUDE, then this option
is ignored.

Tip You can use the ERRORBARATTRS= option to control the


appearance of the error bars.

FILLATTRS=style-element | style-element (fill-options) | (fill-options)


specifies the appearance of the filled bar area.

Defaults For non-grouped data, the GraphDataDefault:Color style reference.


266 Chapter 6 • Plot Statements

For grouped data, the GraphData1:Color–GraphDataN:Color style


references.

Interaction When COLORRESPONSE= is in effect and the DISPLAY= option


enables FILL display, the FILLATTRS= suboption COLOR= is
ignored, and the bar fill colors vary according to the gradient.

Tip The DATATRANSPARENCY= option sets the transparency for bar


fills, bar outlines, error bars, and connect lines. You can combine this
option with DATATRANSPARENCY= to set one transparency for the
bar outlines, error bars, and connect lines but a different transparency
for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element .

“Fill Options” on page 1348 for available fill-options.

FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled bar area.
style-element
specifies the name of a style element. You can specify only one of the elements
GraphData1–GraphDataN.

Restriction The only styles that are delivered by SAS that support fill patterns
are JOURNAL2, JOURNAL3, and MONOCHROMEPRINTER. If
any other such style is in effect and this option uses style-element in
its specification, then this option is ignored.

(fill-pattern-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:
COLOR=color | style-reference
specifies a color to use for the bar-fill-pattern lines. With grouped data, the
COLOR= setting has the effect of holding the fill color constant across all
group values.
PATTERN=line-pattern
specifies a line pattern to use for the bar fill.
To specify a line-pattern, combine a line-direction prefix (R for right, L for
left, and X for cross hatch) with a line-identification number:
BARCHARTPARM Statement 267

With grouped data, the PATTERN= setting has the effect of holding the fill
pattern constant across all group values.

Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.

See DISPLAY=

FILLTYPE=SOLID | GRADIENT
specifies the bar fill type.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
SOLID
each bar is filled with the color that is assigned to that bar.
GRADIENT
an alpha gradient is used to determine the bar fill color. Each bar is filled with a
color and a transparency gradient that starts at the bar top with the specified fill
color and transparency, and transitions to fully transparent at the bar baseline.
The initial fill color is determined by a style element or by the FILLATTRS=
option COLOR= suboption. The initial transparency is determined by the
DATATRANSPARENCY= option or by the FILLATTRS= option
TRANSPARENCY= suboption.

Interactions The SHEEN data skin cannot be used when


FILLTYPE=GRADIENT is in effect. You can use one of the other
data skins.

In the second maintenance release of SAS 9.4,


FILLTYPE=GRADIENT is ignored when
GROUPDISPLAY=STACK is in effect. Starting with the third
maintenance release of SAS 9.4, FILLTYPE=GRADIENT is
honored in that case.

Tips Use the DATATRANSPARENCY= option or the FILLATTRS=


option TRANSPARENCY= suboption to set the initial
transparency in the gradients.

For grouped plots, use the FILLATTRS= option in a discrete


attribute map to set the initial transparency in the gradients for
specific values.

See DATASKIN= on page 262

Default SOLID

Interaction The DISPLAY= option must include FILL for this option to have any
effect.

GROUP=column | discrete-attr-var | expression


creates a separate bar segment or bar for each unique group value in the specified
column.
discrete-attr-var
specifies a discrete attribute map variable that is defined in a
DISCRETEATTRVAR statement.
268 Chapter 6 • Plot Statements

Restriction A discrete attribute map variable specification must be a direct


reference to the attribute map variable. It cannot be set by a
dynamic variable.

The bar display depends on the setting for the GROUPDISPLAY= option. For
example, for a vertical bar chart with GROUPDISPLAY=STACK, bar segments are
stacked to form the bar. The height of each segment represents the corresponding
group value’s proportional contribution to the response value.

Defaults If bar fills are enabled by the ODS style or by the DISPLAY= option,
then each distinct group value is represented in the plot by a different
fill color or fill pattern. The fill colors are defined by the Color
attribute of the GraphData1–GraphDataN and GraphMissing style
elements. The fill patterns are defined by the FillPattern attribute of
the GraphData1–GraphDataN and GraphMissing style elements.

If bar outlines are enabled by the ODS style or by the DISPLAY=


option, then each distinct group value is represented in the plot by a
different outline. The outline colors are defined by the ContrastColor
attribute of the GraphData1–GraphDataN and GraphMissing style
elements.

Interactions Connect lines are not drawn for grouped data.

By default, the group values are mapped in the order of the data. Use
the GROUPORDER= option to control the sorting order of the group
values.

The INCLUDEMISSINGGROUP option controls whether missing


group values are considered a distinct group value.

When both the GROUP= and COLORRESPONSE= options are


specified, the color attributes are controlled by the
COLORRESPONSE= option.

Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the bar outlines, but you
could use the PATTERN= setting on the OUTLINEATTRS= option to
assign the same line pattern to all bar outlines and connect lines.

Use the INDEX= option to alter the default sequence of colors, fill
patterns, and line patterns.

GROUP100=NONE | MAGNITUDE | POSITIVE


displays the response values, normalized to 100%.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
NONE
displays the data as received.
MAGNITUDE
normalizes both the negative and positive values to 100% by magnitude, and
displays the group values, preserving the sign. The positive values are displayed
above the bars for a vertical bar chart and on the right end for a horizontal bar
BARCHARTPARM Statement 269

chart. The negative values are displayed enclosed in parentheses below the bars
for a vertical bar chart and on the left end for a horizontal bar chart.
The following figure illustrates the effect of MAGNITUDE on stacked bars in a
vertical bar chart.

POSITIVE
drops the negative values and normalizes only the positive values to 100%. The
following figure demonstrates the effect of POSITIVE on clustered bars in a
vertical bar chart. This chart uses the same data as the chart in the previous
figure.

Notice that the negative values are dropped from the chart.

Default NONE

Requirement The GROUP= option must be specified for this option to have any
effect.

Interaction Error bars are not drawn when GROUP100=POSITIVE or


MAGNITUDE. See ERRORLOWER= and ERRORUPPER=.

Note You can use this option with any value for the GROUPDISPLAY=
option.
270 Chapter 6 • Plot Statements

Tip To display the values, specify DATALABELTYPE=AUTO.

GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
STACK
displays group values as stacked segments within the category bar.

CLUSTER
displays group values as separate adjacent bars that replace the single category
bar. Each cluster of group values is centered at the category midpoint on the axis.
This example illustrates the clusters and also how groups are displayed when
they have an unequal number of unique values.

Default STACK

Interactions When you use the DATALABEL= option and the GROUP= option,
the DATALABEL values are displayed for each bar when
GROUPDISPLAY=CLUSTER. When GROUPDISPLAY=STACK,
the whole bar is labeled at the top.

Error bars are not drawn when GROUPDISPLAY=STACK.

When the TARGET= and GROUP= options are in effect, the target
values are not displayed when GROUPDISPLAY=STACK. In that
BARCHARTPARM Statement 271

case, you must specify GROUPDISPLAY=CLUSTER to display the


target values.

GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING


specifies the ordering of the groups within a category.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Note: This feature applies to the second maintenance release of SAS 9.4 and to
later releases.

Tip This option is useful when you want to reverse the category axis.

ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.

Default DATA

Interactions This option is ignored if the GROUP= option is not also specified.

By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.

Notes Attributes such as color, symbol, and pattern are assigned to each
group in the DATA order by default, regardless of the
GROUPORDER= option setting.

The ASCENDING and DESCENDING settings linguistically sort the


group values within each category (or X value) for display position
purposes only. For numeric data, the order is based on the unformatted
values. For character data, the order is based on the formatted values.
The data order of the observations and the visual attributes that are
assigned to the group values remain unchanged.

INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.

Default TRUE

Interaction For this option to take effect, the GROUP= option must also be
specified.

Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in effect,
the INDEX= option is used, the MISSING= system option changes the
default missing character, or a user-defined format is applied to the
group value. In those cases, the attributes of the missing group value
are determined by a GraphData1–GraphDataN style element instead of
by the GraphMissing style element.

See “boolean ” on page 1339 for other Boolean values that you can use.
272 Chapter 6 • Plot Statements

INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.

Requirements The column or expression value must be an integer value of 1 or


greater. Otherwise, this option is ignored.

The positive-integer column must not contain missing values.


Otherwise, the entire column is invalidated and this option is
ignored.

All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.

Interaction For this option to take effect, the GROUP= option must also be
specified.

Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N, then
a modulo operation remaps that index value to a number less than N
to determine which style to use.

If you do not use this option, then the group values are mapped in
the order of the data.

Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 183.

INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval width.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.

Default The width specified by the BARWIDTH= option.

Restriction This option applies only to a linear or time category axis. When the
category axis is discrete, this option is ignored.

Interaction When the category data is interval, this option overrides the
BARWIDTH= option.

Tip To make the category axis type linear or time, include TYPE=LINEAR
or TYPE=TIME in the category axis options or assign the role of
primary plot to a plot that makes the category axis linear or time.

See “dimension” on page 1340

LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.

Default The response-variable label. If a label is not defined, then the response-
variable name is used.

Restriction This option applies only to an associated DISCRETELEGEND


statement.
BARCHARTPARM Statement 273

Interaction If the GROUP= option is specified, then this option is ignored.

NAME="string"
assigns a name to this plot statement for reference in other template statements. The
specified name is used primarily in legend statements to coordinate the use of colors
and line patterns between the plot and the legend.

Restriction The string is case sensitive, cannot contain spaces, and must define a
unique name within the template.

Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.

ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.

Default VERTICAL

Notes When this option is set to VERTICAL, the category variable appears on the
X (or X2) axis and the response variable appears on the Y (or Y2) axis. To
set the axis properties for this chart, you should use the appropriate axis
options of the layout container.

When this option is set to HORIZONTAL, the category variable appears on


the Y (or Y2) axis and the response variable appears on the X (or X2) axis.
To set the axis properties for this chart, you should use the appropriate axis
options of the layout container.

If you change the orientation of the bar chart, then you should adjust the
layout container’s axis options appropriately.

OUTLINEATTRS=style-element | style-element (line-options) | (line-options)


specifies the appearance of the bar outlines.

Defaults For non-grouped data, the ContrastColor, LineThickness, and


LineStyle attributes of the GraphOutlines style element.

For grouped data and filled bars, the ContrastColor attribute of the
GraphData1–GraphDataN style elements, and the LineThickness and
LineStyle attributes of the GraphOutlines style element.

For grouped data and unfilled bars, the ContrastColor and LineStyle
attributes of the GraphData1–GraphDataN style elements, and the
LineThickness attribute of the GraphOutlines style element.

Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.

If the DATASKIN= option applies a data skin, then this option is


ignored.

When the COLORRESPONSE= and DISPLAY=(OUTLINE) options


are in effect, the OUTLINEATTRS= suboption COLOR= is ignored,
and the bar outline colors vary according to the gradient.

See “General Syntax for Attribute Options” on page 1347 for the syntax on
using a style-element.
274 Chapter 6 • Plot Statements

“Line Options” on page 1349 for available line-options.

PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for determining
default axis features. This option is needed only when two or more plots within an
overlay-type layout contribute to a common axis.

Default FALSE

Restriction This option is ignored if the plot is placed under a GRIDDED or


LATTICE layout block.

Note In an OVERLAY layout, only one plot in an overlay can be the primary
plot on a per-axis basis. When no plot is designated as the primary plot,
the first plot that can be a primary plot is considered the primary plot. If
multiple plots specify PRIMARY=TRUE for the same axis, then the
last such plot encountered is considered the primary plot.

See “When Plots Share Data and a Common Axis” on page 880

“boolean ” on page 1339 for other Boolean values that you can use.

ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data tips.
This option provides a way to add to the data columns that appear in data tips that are
specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.

Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)

Default No user-defined roles

Requirement The role names that you choose must be unique and different from
the predefined roles CATEGORY or X, RESPONSE or Y,
ERRORLOWER, ERRORUPPER, GROUP, and INDEX.

SEGMENTLABELATTRS=style-element | style-element (text-options) | (text-options)


specifies the text properties of the text for the bar segment label.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Default The GraphDataText style element.

Interaction This option is ignored when SEGMENTLABELTYPE=NONE.

See “General Syntax for Attribute Options” on page 1347 for the syntax for
using a style-element.

“Text Options” on page 1351 for available text-options.

SEGMENTLABELFITPOLICY=NONE | NOCLIP | THIN


specifies a policy for fitting the bar segment labels within the bar segments.
BARCHARTPARM Statement 275

Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
NONE
no attempt is made to fit each segment label within its bar. Long bar segment
labels might overlap other graphical elements. The segment labels are not
considered when the axis ranges are computed. As a result, segment labels that
extend beyond the plot area are clipped.
NOCLIP
does not clip bar segment labels that extend beyond the plot area. Labels that do
not fit within the plot area extend into the graph axis area and might overlap axis
elements.
THIN
drops any bar segment label that does not fit within its segment. For a vertical bar
chart, the label width must not exceed the bar width, and the text height must not
exceed the segment height. For a horizontal bar chart, the label text height must
not exceed the bar width, and the label length must not exceed the segment
length.

Default THIN

Interaction This option is ignored when SEGMENTLABELTYPE=NONE.

SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.

Defaults If DATALABELTYPE=AUTO is in effect, the column format assigned


to the RESPONSE= column, or BEST6 if no format is assigned.

If DATALABELTYPE=COLUMN is in effect, the column format


assigned to the DATALABEL= column, or BEST6 if no format is
assigned.

Interaction This option is ignored when SEGMENTLABELTYPE=NONE.

SEGMENTLABELTYPE=NONE | AUTO
specifies whether a label is displayed inside each bar segment.
Note: This feature applies to the second maintenance release of SAS 9.4 and to later
releases.
For an ungrouped bar chart or for a grouped bar chart with
GROUPDISPLAY=CLUSTER, AUTO displays a bar label inside each bar. The label
for each bar displays the value for that bar. For a grouped bar chart with
GROUPDISPLAY=STACK, AUTO displays a label inside each bar segment. The
label for each bar segment displays the value for that segment.
276 Chapter 6 • Plot Statements

When this value is set to NONE, no labels are displayed inside the bars.

Default NONE

Interaction The DATALABELTYPE= option determines whether the segment


labels display the RESPONSE column values or the values of the
column that is specified by the DATALABEL= option.

Tips For a grouped bar chart with GROUPDISPLAY=STACK, specify both


SEGMENTLABELTYPE=AUTO and DATALABEL=TRUE to display
a label for each bar segment and a label for the entire bar.

Use the SEGMENTLABELATTRS= option to modify the appearance


of the label text.

Use the SEGMENTLABELFITPOLICY= option to specify a policy for


fitting the labels inside the