SAS 9.4 Output Delivery System: Procedures Guide, Second Edition

SAS 9.4 Output Delivery System: Procedures Guide, Second Edition
SAS 9.4 Output Delivery
System
®
Procedures Guide
Second Edition
SAS® Documentation
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2015. SAS® 9.4 Output Delivery System: Procedures Guide,
Second Edition. Cary, NC: SAS Institute Inc.
SAS® 9.4 Output Delivery System: Procedures Guide, Second 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
About This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
PART 1
Introduction
1
Chapter 1 • Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Overview of the Output Delivery System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Overview of How ODS Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
PART 2
Customizing Procedure Output
7
Chapter 2 • Working with General Procedure Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Customized Output for an Output Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Customizing Titles and Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Chapter 3 • Using Selection and Exclusion Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Chapter 4 • Other SAS Statements That Are Used with ODS Procedures . . . . . . . . . . . . . . . . . 35
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
PART 3
The DOCUMENT Procedure
75
Chapter 5 • The ODS DOCUMENT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Chapter 6 • The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Overview: DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
About ODS Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Understanding an ODS Document Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Understanding Sequence Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
ODS Documents and Base SAS Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Getting Familiar with Output Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Compatibility across SAS Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Syntax: The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Advanced ODS DOCUMENT Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Viewing the Contents of an ODS Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Replaying Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Customizing Labels, Titles, and Footnotes with BY Variables . . . . . . . . . . . . . . . . . . 141
Results: DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Examples: The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
iv Contents
PART 4
The MSCHART Procedure
175
Chapter 7 • (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Overview: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Concepts: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Syntax: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Common Attribute Options for the MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . 205
Examples: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
PART 5
The ODSLIST Procedure
215
Chapter 8 • The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Overview: ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Syntax: The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Using the ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Changing the Bullet Type for Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Examples: The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
PART 6
The ODSTABLE Procedure
251
Chapter 9 • The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Overview: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Concepts: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Syntax: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Using the ODSTABLE Procedure to Create Tabular Output . . . . . . . . . . . . . . . . . . . . 286
Examples: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
PART 7
The ODSTEXT Procedure
307
Chapter 10 • The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Overview: ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Syntax: The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Using the ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Changing the Bullet Type for Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Examples: The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
PART 8
The TEMPLATE Procedure
335
Chapter 11 • TEMPLATE Procedure: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Introduction to the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Syntax: TEMPLATE Procedure: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Using the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
PROC TEMPLATE Statements by Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Where to Go from Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Contents
v
Chapter 12 • TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . . . . . . . . . . . 349
Overview: Template Stores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Concepts: Template Stores and the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . 350
Syntax: TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . . . . . . . 352
Examples: TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . . . . . 366
Chapter 13 • TEMPLATE Procedure: Creating Crosstabulation Table Templates . . . . . . . . . . 373
Overview: ODS Crosstabulation Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Concepts: Crosstabulation Output and the TEMPLATE Procedure . . . . . . . . . . . . . . . 377
Syntax: TEMPLATE Procedure: Creating Crosstabulation Table Templates . . . . . . . 378
Using Crosstabulation Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Examples: TEMPLATE Procedure: Creating Crosstabulation Table Templates . . . . . 403
Chapter 14 • TEMPLATE Procedure: Creating ODS Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Introduction to the Graph Template Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Syntax: TEMPLATE Procedure: Creating ODS Graphics . . . . . . . . . . . . . . . . . . . . . . 438
Where to Go from Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Chapter 15 • TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . . . . . . . . . . . 441
Overview: ODS Style Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Concepts: Styles and the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Syntax: TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . . . . . . . 461
Style Attributes Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Style Attributes Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Detailed Information for All Style Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Style Attribute Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Examples: TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . . . . . 521
Chapter 16 • TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . . . . . . . . . . . . 577
Overview: ODS Tabular Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Comparing the Edit of an Existing Table Template with Creating
a New Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Viewing the Contents of a Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
Syntax: TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . . . . . . . . . 583
Using the TEMPLATE Procedure to Create Tabular Output . . . . . . . . . . . . . . . . . . . . 610
Examples: TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . . . . . . 613
Chapter 17 • Tabular Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Understanding Table Templates, Table Elements, and Table Attributes . . . . . . . . . . .
Column Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Header and Footer Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
653
653
653
670
681
Chapter 18 • TEMPLATE Procedure: Creating Markup Language Tagsets . . . . . . . . . . . . . . . . 695
Overview: ODS Tagsets and the TEMPLATE PROCEDURE . . . . . . . . . . . . . . . . . . . 696
Concepts: Markup Languages and the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . 696
Syntax: TEMPLATE Procedure: Creating Markup Language Tagsets . . . . . . . . . . . . 703
Event Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
Event Statement Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
Examples: TEMPLATE Procedure: Creating Markup Language Tagsets . . . . . . . . . . 751
PART 9
ODS Styles Reference
777
vi Contents
Chapter 19 • Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779
Understanding Styles, Style Elements, and Style Attributes . . . . . . . . . . . . . . . . . . . . 779
Using Styles with Base SAS Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
Chapter 20 • Style Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789
Viewing ODS Styles Supplied by SAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789
Table of Suggested ODS Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791
Program for Viewing Multiple Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
ODS Styles Gallery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794
Chapter 21 • Style Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
General ODS Style Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
Style Elements Affecting Template-Based Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . 841
Style Elements Affecting Device-Based Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
Chapter 22 • Style Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859
Style Attributes Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859
Style Attributes Detailed Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870
Style Attribute Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903
PART 10
Appendices
909
Appendix 1 • Output Object Table Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911
ODS Table Names and the Base SAS Procedures That Produce Them . . . . . . . . . . . . 911
ODS Table Names and the Base SAS High-Performance
Procedures That Produce Them . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
ODS Table Names and the Base SAS Statistical Procedures That Produce Them . . . 925
ODS Table Names and the SAS/STAT Procedures That Produce Them . . . . . . . . . . . 925
ODS Table Names and the SAS/STAT High-Performance
Procedures That Produce Them . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929
ODS Table Names and the SAS/ETS Procedures That Produce Them . . . . . . . . . . . . 930
ODS Table Names and the SAS/ETS High-Performance
Procedures That Produce Them . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
ODS Table Names and the SAS/QC Procedures That Produce Them . . . . . . . . . . . . . 931
Recommended Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935
vii
About This Book
Lua License
Copyright © 1994–2012 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions: The
above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Syntax Conventions for the SAS Language
Overview of Syntax Conventions for the SAS Language
SAS uses standard conventions in the documentation of syntax for SAS language
elements. These conventions enable you to easily identify the components of SAS
syntax. The conventions can be divided into these parts:
•
syntax components
•
style conventions
•
special characters
•
references to SAS libraries and external files
viii About This Book
Syntax Components
The components of the syntax for most language elements include a keyword and
arguments. For some language elements, only a keyword is necessary. For other
language elements, the keyword is followed by an equal sign (=). The syntax for
arguments has multiple forms in order to demonstrate the syntax of multiple arguments,
with and without punctuation.
keyword
specifies the name of the SAS language element that you use when you write your
program. Keyword is a literal that is usually the first word in the syntax. In a CALL
routine, the first two words are keywords.
In these examples of SAS syntax, the keywords are bold:
CHAR (string, position)
CALL RANBIN (seed, n, p, x);
ALTER (alter-password)
BEST w.
REMOVE <data-set-name>
In this example, the first two words of the CALL routine are the keywords:
CALL RANBIN(seed, n, p, x)
The syntax of some SAS statements consists of a single keyword without arguments:
DO;
... SAS code ...
END;
Some system options require that one of two keyword values be specified:
DUPLEX | NODUPLEX
Some procedure statements have multiple keywords throughout the statement syntax:
CREATE <UNIQUE> INDEX index-name ON table-name (column-1 <, column-2, …>)
argument
specifies a numeric or character constant, variable, or expression. Arguments follow
the keyword or an equal sign after the keyword. The arguments are used by SAS to
process the language element. Arguments can be required or optional. In the syntax,
optional arguments are enclosed in angle brackets ( < > ).
In this example, string and position follow the keyword CHAR. These arguments are
required arguments for the CHAR function:
CHAR (string, position)
Each argument has a value. In this example of SAS code, the argument string has a
value of 'summer', and the argument position has a value of 4:
x=char('summer', 4);
In this example, string and substring are required arguments, whereas modifiers and
startpos are optional.
FIND(string, substring <, modifiers> <, startpos>
Syntax Conventions for the SAS Language
ix
argument(s)
specifies that one argument is required and that multiple arguments are allowed.
Separate arguments with a space. Punctuation, such as a comma ( , ) is not required
between arguments.
The MISSING statement is an example of this form of multiple arguments:
MISSING character(s);
<LITERAL_ARGUMENT> argument-1 <<LITERAL_ARGUMENT> argument-2 ... >
specifies that one argument is required and that a literal argument can be associated
with the argument. You can specify multiple literals and argument pairs. No
punctuation is required between the literal and argument pairs. The ellipsis (...)
indicates that additional literals and arguments are allowed.
The BY statement is an example of this argument:
BY <DESCENDING> variable-1 <<DESCENDING> variable-2 …>;
argument-1 <option(s)> <argument-2 <option(s)> ...>
specifies that one argument is required and that one or more options can be
associated with the argument. You can specify multiple arguments and associated
options. No punctuation is required between the argument and the option. The
ellipsis (...) indicates that additional arguments with an associated option are
allowed.
The FORMAT procedure PICTURE statement is an example of this form of multiple
arguments:
PICTURE name <(format-option(s))>
<value-range-set-1 <(picture-1-option(s))>
<value-range-set-2 <(picture-2-option(s))> …>>;
argument-1=value-1 <argument-2=value-2 ...>
specifies that the argument must be assigned a value and that you can specify
multiple arguments. The ellipsis (...) indicates that additional arguments are allowed.
No punctuation is required between arguments.
The LABEL statement is an example of this form of multiple arguments:
LABEL variable-1=label-1 <variable-2=label-2 …>;
argument-1 <, argument-2, ...>
specifies that one argument is required and that you can specify multiple arguments
that are separated by a comma or other punctuation. The ellipsis (...) indicates a
continuation of the arguments, separated by a comma. Both forms are used in the
SAS documentation.
Here are examples of this form of multiple arguments:
AUTHPROVIDERDOMAIN (provider-1:domain-1 <, provider-2:domain-2, …>
INTO :macro-variable-specification-1 <, :macro-variable-specification-2, …>
Note: In most cases, example code in SAS documentation is written in lowercase with a
monospace font. You can use uppercase, lowercase, or mixed case in the code that
you write.
Style Conventions
The style conventions that are used in documenting SAS syntax include uppercase bold,
uppercase, and italic:
x About This Book
UPPERCASE BOLD
identifies SAS keywords such as the names of functions or statements. In this
example, the keyword ERROR is written in uppercase bold:
ERROR <message>;
UPPERCASE
identifies arguments that are literals.
In this example of the CMPMODEL= system option, the literals include BOTH,
CATALOG, and XML:
CMPMODEL=BOTH | CATALOG | XML |
italic
identifies arguments or values that you supply. Items in italic represent user-supplied
values that are either one of the following:
•
nonliteral arguments. In this example of the LINK statement, the argument label
is a user-supplied value and therefore appears in italic:
LINK label;
•
nonliteral values that are assigned to an argument.
In this example of the FORMAT statement, the argument DEFAULT is assigned
the variable default-format:
FORMAT variable(s) <format > <DEFAULT = default-format>;
Special Characters
The syntax of SAS language elements can contain the following special characters:
=
an equal sign identifies a value for a literal in some language elements such as
system options.
In this example of the MAPS system option, the equal sign sets the value of MAPS:
MAPS=location-of-maps
<>
angle brackets identify optional arguments. A required argument is not enclosed in
angle brackets.
In this example of the CAT function, at least one item is required:
CAT (item-1 <, item-2, …>)
|
a vertical bar indicates that you can choose one value from a group of values. Values
that are separated by the vertical bar are mutually exclusive.
In this example of the CMPMODEL= system option, you can choose only one of the
arguments:
CMPMODEL=BOTH | CATALOG | XML
...
an ellipsis indicates that the argument can be repeated. If an argument and the ellipsis
are enclosed in angle brackets, then the argument is optional. The repeated argument
must contain punctuation if it appears before or after the argument.
Syntax Conventions for the SAS Language
xi
In this example of the CAT function, multiple item arguments are allowed, and they
must be separated by a comma:
CAT (item-1 <, item-2, …>)
'value' or "value"
indicates that an argument that is enclosed in single or double quotation marks must
have a value that is also enclosed in single or double quotation marks.
In this example of the FOOTNOTE statement, the argument text is enclosed in
quotation marks:
FOOTNOTE <n> <ods-format-options 'text' | "text">;
;
a semicolon indicates the end of a statement or CALL routine.
In this example, each statement ends with a semicolon:
data namegame;
length color name $8;
color = 'black';
name = 'jack';
game = trim(color) || name;
run;
References to SAS Libraries and External Files
Many SAS statements and other language elements refer to SAS libraries and external
files. You can choose whether to make the reference through a logical name (a libref or
fileref) or use the physical filename enclosed in quotation marks. If you use a logical
name, you typically have a choice of using a SAS statement (LIBNAME or
FILENAME) or the operating environment's control language to make the reference.
Several methods of referring to SAS libraries and external files are available, and some
of these methods depend on your operating environment.
In the examples that use external files, SAS documentation uses the italicized phrase
file-specification. In the examples that use SAS libraries, SAS documentation uses the
italicized phrase SAS-library enclosed in quotation marks:
infile file-specification obs = 100;
libname libref 'SAS-library';
xii About This Book
xiii
Accessibility
For information about the accessibility of this product, see Accessibility Features of the
Windowing Environment for SAS 9.4 at support.sas.com.
xiv About This Book
1
Part 1
Introduction
Chapter 1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2
3
Chapter 1
Introduction
Overview of the Output Delivery System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Overview of How ODS Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Components of SAS Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Features of ODS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Clearing the Results Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
4
5
6
Overview of the Output Delivery System
The Output Delivery System (ODS) gives you greater flexibility in generating, storing,
and reproducing SAS procedures and DATA step output, with a wide range of formatting
options. ODS provides formatting functionality that is not available from individual
procedures or from the DATA step alone. ODS overcomes these limitations and enables
you to format your output more easily.
By default, ODS output is formatted according to instructions that a PROC step or
DATA step defines. However, ODS provides ways for you to customize the output. You
can customize the output for an entire SAS job, or you can customize the output for a
single output object.
You can use ODS to accomplish the following tasks:
Create reports for popular software applications.
With ODS, you can use ODS destination statements to create output specifically for
software other than SAS and make that output easy to access. For example, you can
use the ODS PDF statement to create PDF files for viewing with Adobe Acrobat or
for printing. You can use the ODS EPUB statement to create output for e-book
readers. The ODS RTF statement creates output for Microsoft Word. For complete
documentation on the ODS destination statements, see “Dictionary of ODS
Language Statements” in SAS Output Delivery System: User's Guide.
Customize the report contents.
ODS enables you to modify the contents of your output. With ODS, you can embed
graphics, select specific cell contents to display, and create embedded links in tables
and graphs. You can select specific tables or graphs from procedure output to be
printed or you can exclude them. You can create SAS data sets directly from tables
or graphics.
Customize the presentation.
ODS enables you to change the appearance of your output. You can change the
colors, fonts, and borders of your output. You can customize the layout, format,
headers, and style. You can add images and embedded URLs.
4
Chapter 1
• Introduction
Create more accessible SAS output.
The ODS EPUB and ODS EPUB3 destinations are the recommended destinations for
creating SAS output that is accessible to the broadest audience. They create e-books
that utilize many of the accessibility features of the EPUB specification. These
features allow e-book readers such as iBooks to present e-books so that they adapt to
the needs of users with disabilities. For example, when reading an e-book created by
the ODS EPUB and ODS EPUB3 destinations using iBooks on an iPad, users can
adjust font size, color schemes, and magnification. They can also access the text
using assistive technologies such as the Voiceover screen reader and refreshable
braille displays.
Overview of How ODS Works
Components of SAS Output
The PROC or DATA step supplies raw data and the name of the table template that
contains the formatting instructions. ODS formats the output. You can use ODS to
format output from individual procedures and from the DATA step in many different
forms other than HTML output.
The following figure shows how SAS produces ODS output.
Figure 1.1 ODS Processing: What Goes in and What Comes Out
Data
Component
Table
Template
+
Output
Object
DOCUMENT
LISTING
OUTPUT
DOCUMENT LISTING
SAS
Output
Output Data Set
HTML
MARKUP
HTML
Output
PRINTER
MS PS
Windows
Printers
PCL
PDF
RTF
ODS
Destinations
RTF
Output
ODS
Outputs
SAS
User-Defined
Tagsets*
Tagsets
Destinations Formatted by SAS
Table 1.1
CHTML
Destinations Formatted by a Third Party
* List of Tagsets That SAS Supplies and Supports
CSV
CSVALL
CSVBYLINE
Overview of How ODS Works
DEFAULT
EXCELXP
HTML4
MSOFFICE2K
PHTML
TAGSETS.RTF
Table 1.2
5
HTMLPANEL
* Additional Diagnostic Tagsets That SAS Supports
EVENT_MAP
NAMEDHTML
STYLE_POPUP
TEXT_MAP
SHORT_MAP
STYLE_DISPLAY
Note: There are also preproduction tagsets. These tagsets can be found at http://
support.sas.com and are not yet supported by SAS.
Features of ODS
ODS is designed to overcome the limitations of traditional SAS output and to make it
easy to access and create files in different formats. ODS provides a method of delivering
output in a variety of formats, and makes the formatted output easy to access.
Important features of ODS include the following:
•
ODS combines raw data with one or more table templates to produce one or more
output objects. These objects can be sent to any or all ODS destinations. You control
the specific type of output from ODS by selecting an ODS destination. The currently
available ODS destinations can produce the following types of output:
•
traditional monospace output
•
an output data set
•
an ODS document that contains a hierarchy file of the output objects
•
output that is formatted for a high-resolution printer such as PostScript and PDF
•
output that is formatted in various markup languages such as HTML
•
RTF output that is formatted for use with Microsoft Word
•
PowerPoint output that is formatted for use with Microsoft PowerPoint
•
output that is formatted for EPUB e-books
•
ODS provides table templates that define the structure of the output from SAS
procedures and from the DATA step. You can customize the output by modifying
these templates, or by creating your own.
•
ODS provides a way for you to choose individual output objects to send to ODS
destinations. For example, PROC UNIVARIATE produces five output objects. You
can easily create HTML output, an output data set, LISTING output, or printer
output from any or all of these output objects. You can send different output objects
to different destinations.
•
In the SAS windowing environment, ODS stores a link to each output object in the
Results folder in the Results window.
•
Because formatting is now centralized in ODS, the addition of a new ODS
destination does not affect any procedures or the DATA step. As future destinations
are added to ODS, they will automatically become available to the DATA step and
all procedures that support ODS.
6
Chapter 1
• Introduction
•
With ODS, you can produce output for numerous destinations from a single source,
but you do not need to maintain separate sources for each destination. This feature
saves you time and system resources by enabling you to produce multiple types of
output with a single run of your procedure or data query.
Clearing the Results Window
The ODS HTML destination is turned on by default when you use the SAS windowing
environment. Therefore, the NEWFILE=NONE option is set by default in the HTML
file and all output is sent to a single HTML file. When you clear the Results window
manually by clicking on a node in the Results window and selecting Delete, or by
issuing the ODSRESULTS;CLEAR command, nodes are deleted from the Results
window. However, the HTML file remains open and the output from subsequent
procedure or DATA steps is appended to any previously created HTML output. You can
remove the contents of the HTML file, close the HTML file, and reset preferences to the
default state by doing one of the following:
•
Using the Command Line
1. Select the Results window or the Results Viewer window.
2. Submit either of these commands in the command line:
CLEAR
or
CLEAR ALL
•
Using the SAS Windowing Environment
1. Select the Results window or the Results Viewer window.
2. From the Menu, select Edit ð Clear All.
7
Part 2
Customizing Procedure Output
Chapter 2
Working with General Procedure Output . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 3
Using Selection and Exclusion Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 4
Other SAS Statements That Are Used with ODS Procedures . . . . . . 35
8
9
Chapter 2
Working with General Procedure
Output
Customized Output for an Output Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Customizing Titles and Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Customized Output for an Output Object
For a procedure, the name of the table template that is used for an output object comes
from the procedure code. The DATA step uses a default table template unless you
specify an alternative with the TEMPLATE= suboption in the ODS option in the FILE
statement. For more information, see the section on the TEMPLATE= suboption in
“FILE Statement for ODS” in SAS Output Delivery System: User's Guide.
To find out which table templates a procedure or the DATA step uses for the output
objects, you must look at a trace record. To produce a trace record in your SAS log,
submit the following SAS statements:
ods trace on;
your-proc-or-DATA-step
ods trace off;
Remember that not all procedures use table templates. If you produce a trace record for
one of these procedures, no template appears in the trace record. Conversely, some
procedures use multiple table templates to produce their output. More than one template
appears in the trace record produced in the log.
For a detailed explanation of the trace record, see the “ODS TRACE Statement” on page
68.
You can use PROC TEMPLATE to modify an entire table template. When a procedure
or DATA step uses a table template, it uses the elements that are defined or referenced in
its table template. In general, you cannot directly specify a table element for your
procedure or DATA step to use without modifying the template itself.
Note: Three Base SAS procedures, PROC PRINT, PROC REPORT, and PROC
TABULATE, do provide a way for you to access table elements from the procedure
step itself. Accessing the table elements enables you to customize your report. For
more information about these procedures, see Base SAS Procedures Guide.
10
Chapter 2
•
Working with General Procedure Output
Customizing Titles and Footnotes
You can use the global TITLE and FOOTNOTE statements to enhance the readability of
any report. These statements have options that enable you to customize the style of the
titles and footnotes when they are used with ODS. Because these options control only
the presentation of the titles and footnotes, they have no effect on objects that go to the
LISTING or OUTPUT destination. Examples of these style options are BOLD,
COLOR=, and FONT=. For a complete list of style options, detailed information about
the style options, and example code, see the TITLE statement and the FOOTNOTE
statement in SAS Statements: Reference.
When used with SAS/GRAPH, you can choose whether to render the titles and footnotes
as part of the body of the document or as part of the graphics image. Where the titles and
footnotes are rendered determines how you control the font, size, and color of the titles
and footnotes text. For details about this ODS and SAS/GRAPH interaction, see
Controlling Titles and Footnotes in SAS/GRAPH: Reference.
For information about titles and footnotes rendered with and without using the graphics
option USEGOPT, see “ODS USEGOPT Statement” in SAS Output Delivery System:
User's Guide.
11
Chapter 3
Using Selection and Exclusion
Lists
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
ODS EXCLUDE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
ODS SELECT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Overview
For each ODS destination, ODS maintains either a selection list or an exclusion list of
output objects. You can use the default output objects selected or excluded for each
destination or you can specify which output object you want to produce by selecting or
excluding them from a list.
A selection list is a list of output objects that are sent to an ODS destination. An
exclusion list is a list of output objects that are excluded from an ODS destination. ODS
also maintains an overall selection or exclusion list of output objects. By checking the
destination-specific lists and the overall list, ODS determines what output objects to
produce. These lists can be modified by using the ODS SELECT statement and the ODS
EXCLUDE statement.
You can maintain a selection list for one destination and an exclusion list for
another. However, the results are less complicated if you maintain the same types of
lists for all the destinations to which you route output.
TIP
You can view the contents of the exclusion and selection lists by using the ODS SHOW
statement. The contents information is written to the SAS log.
EXCLUDE ALL is the default setting for the ODS OUTPUT destination. SELECT ALL
is the default setting for all other destinations. To change the default selection and
exclusion lists, use the ODS SELECT or ODS EXCLUDE statements or use the exclude
and select actions that are available for some of the ODS statements. However, to set the
exclusion list for the OUTPUT destination to something other than the default, use the
“ODS OUTPUT Statement ” in SAS Output Delivery System: User's Guide. For a list of
ODS Output destinations and explanations of each, see “Understanding ODS
Destinations” in SAS Output Delivery System: User's Guide.
In order to view output objects that are selected or excluded from your program, use the
ODS TRACE statement. The ODS TRACE statement prints the output objects that are
selected and excluded and puts the information in a trace record that is written to the
SAS log. The trace provides the path, the label, and other information about output
objects that are selected and excluded. For complete documentation about viewing and
12
Chapter 3
•
Using Selection and Exclusion Lists
selecting output objects, see the “ODS SELECT Statement ” on page 19, the “ODS
EXCLUDE Statement” on page 12, and the “ODS TRACE Statement” on page 68.
Dictionary
ODS EXCLUDE Statement
Specifies output objects to exclude from ODS destinations.
Valid in:
Category:
Anywhere
ODS: Output Control
Syntax
ODS <ODS-destination> EXCLUDE exclusion(s) | ALL | NONE;
Required Arguments
exclusion(s)
specifies one or more output objects to add to an exclusion list.
By default, ODS automatically modifies exclusion lists at the end of a DATA step
that uses ODS, or at the end of a procedure step. For information about modifying
these lists, see “Selection and Exclusion Lists” in SAS Output Delivery System:
User's Guide .
Each exclusion has the following form:
output-object <(PERSIST)>
output-object
specifies one or more output objects to exclude. To specify an output object, you
need to know which output objects your SAS program produces. The ODS
TRACE statement writes to the SAS log a trace record that includes the path, the
label, and other information about each output object that is produced. You can
specify an output object in any of the following ways:
•
a full path. For example, the following is the full path of the output object:
Univariate.City_Pop_90.TestsForLocation
•
a partial path. A partial path consists of any part of the full path that begins
immediately after a period (.) and continues to the end of the full path. For
example, suppose the full path is the following:
Univariate.City_Pop_90.TestsForLocation
Then the partial paths are as follows:
City_Pop_90.TestsForLocation
TestsForLocation
•
a label that is enclosed in quotation marks.
For example:
"The UNIVARIATE Procedure"
ODS EXCLUDE Statement
•
13
a label path. For example, the following is the label path for the output
object:
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Note: The trace record shows the label path only if you specify the LABEL
option in the ODS TRACE statement.
•
a partial label path. A partial label path consists of any part of the label that
begins immediately after a period (.) and continues to the end of the label.
For example, suppose the label path is the following:
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Then the partial label paths are as follows:
"CityPop_90"."Tests For Location"
"Tests For Location"
•
a mixture of labels and paths.
•
any of the partial path specifications, followed by a pound sign (#) and a
number. For example, TestsForLocation#3 refers to the third output
object that is named TestsForLocation.
See
“ODS TRACE Statement” on page 68.
(PERSIST)
keeps the output-object that precedes the PERSIST option in the exclusion list
until you explicitly modify the list with any of the following ODS statements:
•
any ODS SELECT statement
•
ODS EXCLUDE NONE
•
ODS EXCLUDE ALL
•
an ODS EXCLUDE statement that applies to the same output object but does
not specify PERSIST
This action is true even if the DATA or procedure step ends.
Requirement
You must enclose PERSIST in parentheses.
ALL
specifies that ODS does not send any output objects to the open destination.
Alias
ODS EXCLUDE DEFAULT
Interaction
If you specify ALL without specifying a destination, ODS sets the
overall list to EXCLUDE ALL and sets all other lists to their defaults.
Tips
Using ODS EXCLUDE ALL is different from closing a destination.
The destination remains open, but no output objects are sent to it.
To temporarily suspend a destination, use ODS SELECT NONE. Use
ODS SELECT ALL when you want to resume sending output to the
suspended destination.
NONE
specifies that ODS send all of the output objects to the open destination.
14
Chapter 3
•
Using Selection and Exclusion Lists
Interaction
If you specify the NONE argument without specifying a destination,
ODS sets the overall list to EXCLUDE NONE and sets all other lists to
their defaults.
Tips
ODS EXCLUDE NONE has the same effect as ODS SELECT ALL.
To temporarily suspend a destination, use ODS SELECT NONE. Use
ODS SELECT ALL when you want to resume sending output to the
suspended destination.
Optional Arguments
NOWARN
suppresses the warning that an output object was requested but not created.
Requirement
The NOWARN option must be enclosed in parentheses.
Interaction
The NOWARN option cannot be used with the ALL option or the
NONE option.
Example
The ODS EXCLUDE statement in the following example specifies
that no warning is created if the output object Summary is requested
but not created.
ods exclude summary (nowarn);
proc contents data=sashelp.class;
run;
ODS-destination
specifies to which ODS destination's exclusion list to write, where ODS-destination
can be any valid ODS destination. For a discussion of ODS destinations, see
“Understanding ODS Destinations” in SAS Output Delivery System: User's Guide.
Default
If you omit ODS-destination, ODS writes to the overall exclusion list.
Tip
To set the exclusion list for the output destination to something other than
the default, use the “ODS OUTPUT Statement ” in SAS Output Delivery
System: User's Guide.
WHERE=where-expression
excludes output objects that meet a particular condition. For example, the following
statement excludes only output objects with the word "Histogram" in their name:
ods exclude where=(_name_ ?
'Histogram');
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. where-expression has this form:
(subsetting-variable <comparison-operator where-expression-n> )
subsetting-variable
is a special type of WHERE expression operand used by SAS to help you
find common values in items. For example, this EXCLUDE statement
excludes only output objects with the path
City_Pop_90.TestsForLocation :
ods exclude / where=(_path_ = 'City_Pop_90.TestsForLocation' );
ODS EXCLUDE Statement
15
subsetting-variable is one of the following:
_LABEL_
is the label of the output object.
_LABELPATH_
is the label path of the output object.
_NAME_
is the name of the output object.
_PATH_
is the full or partial path of the output object.
operator
compares a variable with a value or with another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
The following table lists some comparison operators:
Table 3.1
Examples of Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Details
For each ODS destination, ODS maintains either a selection list or an exclusion list of
output objects. You can use the default output objects selected or excluded for each
destination or you can specify which output object you want to produce by selecting or
excluding them from a list.
A selection list is a list of output objects that are sent to an ODS destination. An
exclusion list is a list of output objects that are excluded from an ODS destination. ODS
also maintains an overall selection or exclusion list of output objects. By checking the
destination-specific lists and the overall list, ODS determines what output objects to
produce. These lists can be modified by using the ODS SELECT statement and the ODS
EXCLUDE statement.
You can maintain a selection list for one destination and an exclusion list for
another. However, the results are less complicated if you maintain the same types of
lists for all the destinations to which you route output.
TIP
You can view the contents of the exclusion and selection lists by using the ODS SHOW
statement. The current selection list is written to the SAS log.
16
Chapter 3
•
Using Selection and Exclusion Lists
EXCLUDE ALL is the default setting for the ODS OUTPUT destination. SELECT ALL
is the default setting for all other destinations. To change the default selection and
exclusion lists, use the ODS SELECT or ODS EXCLUDE statements or use the exclude
and select actions that are available for some of the ODS statements. However, to set the
exclusion list for the OUTPUT destination to something other than the default, use the
“ODS OUTPUT Statement ” in SAS Output Delivery System: User's Guide. For a list of
ODS output destinations and explanations of each, see “Understanding ODS
Destinations” in SAS Output Delivery System: User's Guide.
In order to view output objects that are selected or excluded from your program, use the
ODS TRACE statement. The ODS TRACE statement prints the output objects that are
selected and excluded and puts the information in a trace record that is written to the
SAS log. The trace provides the path, the label, and other information about output
objects that are selected and excluded. For complete documentation about viewing and
selecting output objects, see the “ODS SELECT Statement ” on page 19, the “ODS
EXCLUDE Statement” on page 12, and the “ODS TRACE Statement” on page 68.
Example: Conditionally Excluding Output Objects and
Sending Them to Different Output Destinations
Features:
ODS EXCLUDE statement:
Options: ODS-Destination, WHERE=
ODS HTML statement options:
CONTENTS=
FRAME=
PAGE=
TEXT=
ODS PDF statement options:
TEXT=
STARTPAGE=
Other features:
PROC UNIVARIATE
Program
options nodate;
data BPressure;
length PatientID $2;
input PatientID $ Systolic Diastolic @@;
datalines;
CK 120 50 SS 96 60 FR 100 70
CP 120 75 BL 140 90 ES 120 70
CP 165 110 JI 110 40 MC 119 66
FC 125 76 RW 133 60 KD 108 54
DS 110 50 JW 130 80 BH 120 65
JW 134 80 SB 118 76 NS 122 78
GS 122 70 AB 122 78 EC 112 62
HH 122 82
;
run;
ods html text='Systolic Blood Pressure' file='Systolic-body.html'
Example 1: Conditionally Excluding Output Objects and Sending Them to Different
Output Destinations 17
frame='Systolic-frame.htm'
contents='Systolic-contents.htm'
page='Systolic-page.htm';
ods pdf file='Diastolic.pdf' text='Diastolic Blood Pressure' startpage=no;
ods html exclude where=(_path_ ? "Diastolic" ) ;
ods pdf exclude where=(_path_ ? "Systolic" ) ;
proc univariate data=BPressure;
var Systolic Diastolic;
run;
ods html close;
ods pdf close;
Program Description
Create the BPressure data set.
options nodate;
data BPressure;
length PatientID $2;
input PatientID $ Systolic Diastolic @@;
datalines;
CK 120 50 SS 96 60 FR 100 70
CP 120 75 BL 140 90 ES 120 70
CP 165 110 JI 110 40 MC 119 66
FC 125 76 RW 133 60 KD 108 54
DS 110 50 JW 130 80 BH 120 65
JW 134 80 SB 118 76 NS 122 78
GS 122 70 AB 122 78 EC 112 62
HH 122 82
;
run;
Create HTML output and add text.
ods html text='Systolic Blood Pressure' file='Systolic-body.html'
frame='Systolic-frame.htm'
contents='Systolic-contents.htm'
page='Systolic-page.htm';
Create PDF output and add text.
ods pdf file='Diastolic.pdf' text='Diastolic Blood Pressure' startpage=no;
Exclude output objects from different output destinations. The first ODS EXCLUDE
statement excludes from the HTML destination output objects that have 'Diastolic' in the
18
Chapter 3
•
Using Selection and Exclusion Lists
pathname. The second ODS EXCLUDE statement excludes from the PDF destination
output objects that have 'Systolic' in the pathname.
ods html exclude where=(_path_ ? "Diastolic" ) ;
ods pdf exclude where=(_path_ ? "Systolic" ) ;
Create the output objects. As PROC UNIVARIATE sends each output object to the
Output Delivery System, ODS does not send the output objects from PROC
UNIVARIATE that match the items in the exclusion list to the open destinations.
proc univariate data=BPressure;
var Systolic Diastolic;
run;
Close the HTML destination. The ODS HTML CLOSE statement closes the HTML
destination and all the files that are associated with it. If you do not close the destination,
then you cannot view the HTML file specified by the FRAME attribute until you close
your SAS session.
ods html close;
Close the PDF destination. This ODS PDF statement closes the PDF destination and all
the files that are associated with it.
ods pdf close;
Output
Output 3.1 Partial HTML Output with Systolic Output Objects
ODS SELECT Statement
19
Output 3.2 Partial PDF Output with Diastolic Output Objects
See Also
Statements
•
“ODS SELECT Statement ” on page 19
•
“ODS SHOW Statement” in SAS Output Delivery System: User's Guide
•
“ODS TRACE Statement” on page 68
ODS SELECT Statement
Specifies output objects for ODS destinations.
Valid in:
Category:
Anywhere
ODS: Output Control
Tip:
You can maintain a selection list for one destination and an exclusion list for another.
However, it is easier to understand the results if you maintain the same types of lists
for all of the destinations to which you route output.
See:
“ODS EXCLUDE Statement” on page 12
Example:
“Example 7: Table Header and Footer Border Formatting” on page 563
Syntax
ODS <ODS-destination> SELECT selection(s) | ALL | NONE;
20
Chapter 3
•
Using Selection and Exclusion Lists
Required Arguments
selection(s)
specifies output objects to add to a selection list. ODS sends the items in the
selection list to all active ODS destinations. By default, ODS automatically modifies
selection lists when a DATA step that uses ODS or a procedure step ends. For
information about modifying these lists, see “Selection and Exclusion Lists” in SAS
Output Delivery System: User's Guide. For information about ending DATA and
procedure steps, see the section on DATA Step Processing in SAS Language
Reference: Concepts.
Each selection has the following form:
output-object <(PERSIST)>
output-object
specifies the output object to select.
To specify an output object, you need to know which output objects your SAS
program produces. The ODS TRACE statement writes to the SAS log a trace
record that includes the path, the label, and other information about each output
object that your SAS program produces. You can specify an output object as one
of the following:
•
a full path. For example, the following is the full path of the output object:
Univariate.City_Pop_90.TestsForLocation
•
a partial path. A partial path consists of any part of the full path that begins
immediately after a period (.) and continues to the end of the full path. For
example, suppose the full path is the following:
Univariate.City_Pop_90.TestsForLocation
Then the partial paths are as follows:
City_Pop_90.TestsForLocation
TestsForLocation
•
a label that is enclosed in quotation marks.
For example:
"The UNIVARIATE Procedure"
•
a label path. For example, the label path for the output object is as follows:
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Note: The trace record shows the label path only if you specify the LABEL
option in the ODS TRACE statement.
•
a partial label path. A partial label path consists of any part of the label that
begins immediately after a period (.) and continues to the end of the label.
For example, suppose the label path is the following:
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Then the partial label paths are as follows:
"CityPop_90"."Tests For Location"
"Tests For Location"
•
a mixture of labels and paths.
ODS SELECT Statement
•
21
any of the partial path specifications, followed by a pound sign (#) and a
number. For example, TestsForLocation#3 refers to the third output
object that is named TestsForLocation.
See
“ODS TRACE Statement” on page 68
(PERSIST)
keeps the output-object that precedes the PERSIST option in the selection list,
even if the DATA or procedure step ends, until you explicitly modify the list with
one of the following:
•
any ODS EXCLUDE statement
•
ODS SELECT NONE
•
ODS SELECT ALL
•
an ODS SELECT statement that applies to the same output object but does
not specify PERSIST
Requirement
You must enclose PERSIST in parentheses.
ALL
specifies that ODS send all of the output objects to the open destination.
Alias
ODS SELECT DEFAULT
Interaction
If you specify ALL without specifying a destination, ODS sets the
overall list to SELECT ALL and sets all other lists to their defaults.
NONE
specifies that ODS does not send any output objects to the open destination.
Interaction
If you specify NONE and you do not specify a destination, ODS sets
the overall list to SELECT NONE and sets all other lists to their
defaults.
Tips
Using the NONE action is different from closing a destination. The
output destination is still open, but ODS restricts the output that it sends
to the destination.
To temporarily suspend a destination, use ODS SELECT NONE. Use
ODS SELECT ALL when you want to resume sending output to the
suspended destination.
Optional Arguments
(NOWARN)
suppresses the warning that an output object was requested but not created.
Requirement
The NOWARN option must be enclosed in parentheses.
Interaction
The NOWARN option cannot be used with the ALL option or the
NONE option.
Example
The ODS SELECT statement in the following example specifies that
no warning is created if the output object Summary is requested but
not created.
ods select summary (nowarn);
22
Chapter 3
•
Using Selection and Exclusion Lists
proc contents data=sashelp.class;
run;
ODS-destination
specifies to which ODS destination's selection list to write, where ODS-destination
can be any valid ODS destination except for the OUTPUT destination.
Default
If you omit ODS-destination, ODS writes to the overall selection list.
Restriction
You cannot write to the OUTPUT destination's selection list.
Tip
To set the selection list for the Output destination to something other
than the default, see the “ODS OUTPUT Statement ” in SAS Output
Delivery System: User's Guide.
See
“Understanding ODS Destinations” in SAS Output Delivery System:
User's Guide for a discussion of ODS destinations.
WHERE=where-expression
selects output objects that meet a particular condition. For example, the following
statement selects only output objects with the word "Histogram" in their name:
ods select where=(_name_ ?
'Histogram');
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. where-expression has this form:
(subsetting-variable <comparison-operator where-expression-n> )
subsetting-variable
Subsetting variables are a special type of WHERE expression operand used
by SAS to help you find common values in items. For example, this ODS
SELECT statement selects only output objects with the path
City_Pop_90.TestsForLocation :
ods select
/ where=(_path_ = 'City_Pop_90.TestsForLocation' );
subsetting-variable is one of the following:
_LABEL_
is the label of the output object.
_LABELPATH_
is the label path of the output object.
_NAME_
is the name of the output object.
_PATH_
is the full or partial path of the output object.
operator
compares a variable with a value or with another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
The following table lists some comparison operators:
ODS SELECT Statement
Table 3.2
23
Examples of Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Details
For each ODS destination, ODS maintains either a selection list or an exclusion list of
output objects. You can use the default output objects selected or excluded for each
destination or you can specify which output object you want to produce by selecting or
excluding them from a list.
A selection list is a list of output objects that are sent to an ODS destination. An
exclusion list is a list of output objects that are excluded from an ODS destination. ODS
also maintains an overall selection or exclusion list of output objects. By checking the
destination-specific lists and the overall list, ODS determines what output objects to
produce. These lists can be modified by using the ODS SELECT statement and the ODS
EXCLUDE statement.
You can maintain a selection list for one destination and an exclusion list for
another. However, the results are less complicated if you maintain the same types of
lists for all the destinations to which you route output.
TIP
You can view the contents of the exclusion and selection lists by using the ODS SHOW
statement. The current selection list is written to the SAS log.
EXCLUDE ALL is the default setting for the ODS OUTPUT destination. SELECT ALL
is the default setting for all other destinations. To change the default selection and
exclusion lists, use the ODS SELECT or ODS EXCLUDE statements or use the exclude
and select actions that are available for some of the ODS statements. However, to set the
exclusion list for the OUTPUT destination to something other than the default, use the
“ODS OUTPUT Statement ” in SAS Output Delivery System: User's Guide. For a list of
ODS output destinations and explanations of each, see “Understanding ODS
Destinations” in SAS Output Delivery System: User's Guide.
In order to view output objects that are selected or excluded from your program, use the
ODS TRACE statement. The ODS TRACE statement prints the output objects that are
selected and excluded and puts the information in a trace record that is written to the
SAS log. The trace provides the path, the label, and other information about output
objects that are selected and excluded. For complete documentation about viewing and
selecting output objects, see the “ODS SELECT Statement ” on page 19, the “ODS
EXCLUDE Statement” on page 12, and the “ODS TRACE Statement” on page 68.
24
Chapter 3
•
Using Selection and Exclusion Lists
Examples
Example 1: Using a Selection List with Multiple Procedure Steps
Features:
ODS SELECT statement:
with label
with name
with and without PERSIST
ALL
ODS SHOW statement
ODS HTML statement options:
BODY=
CONTENTS=
FRAME=
PAGE=
Other features:
PROC GLM
PROC PRINT
PROC PLOT
Data set:
Iron
Details
This example runs the same procedures multiple times to illustrate how ODS maintains
and modifies a selection list. The ODS SHOW statement writes the overall selection list
to the SAS log. The example does not alter selection lists for individual destinations. The
contents file that is generated by the ODS HTML statement shows which output objects
are routed to both the HTML and the LISTING destinations.
This example creates and prints data sets from the parameter estimates that PROC GLM
generates. This procedure is part of SAS/STAT software.
Program
ods html body='odspersist-body.htm'
frame='odspersist-frame.htm'
contents='odspersist-contents.htm'
page='odspersist-page.htm';
ods show;
ods select ParameterEstimates
"Type III Model ANOVA";
ods show;
proc glm data=iron;
model loss=fe;
title 'Parameter Estimates and Type III Model ANOVA';
run;
ods show;
quit;
ods show;
Example 1: Using a Selection List with Multiple Procedure Steps
25
proc glm data=iron;
model loss=fe;
title 'All Output Objects Selected';
run;
quit;
ods select OverallANOVA(persist) "Fit Statistics";
proc glm data=iron;
model loss=fe;
title 'OverallANOVA and Fitness Statistics';
run;
quit;
ods show;
proc glm data=iron;
model loss=fe;
title 'OverallANOVA';
title2 'Part of the Selection List Persists';
run;
quit;
proc print data=iron;
title 'The IRON Data Set';
run;
ods select all;
proc plot data=iron;
plot fe*loss='*' / vpos=25 ;
label fe='Iron Content'
loss='Weight Loss';
title 'Plot of Iron Versus Loss';
run;
quit;
ods html close;
Program Description
Create HTML output. The ODS HTML creates the body, contents, frame, and page files.
The output from the procedures is sent to the file odspersist-body.htm. The FRAME=,
CONTENTS=, and PAGE= options create the files OdsPersist-Frame.htm, OdsPersistContents.htm, and OdsPersist-Page.htm, respectively. These files, together with the file
OdsPersist-Body.htm, create a frame that includes a table of contents and a table of
pages that link to the contents of the body file.
ods html body='odspersist-body.htm'
frame='odspersist-frame.htm'
contents='odspersist-contents.htm'
page='odspersist-page.htm';
Write the overall selection list to the SAS log. The ODS SHOW statement writes to
the SAS log the overall list, which is set to SELECT ALL by default. See the “SAS Log”
on page 29.
ods show;
26
Chapter 3
•
Using Selection and Exclusion Lists
Specify the output objects that will be sent to the open destinations. The ODS
SELECT statement determines which output objects ODS sends to the LISTING and
HTML destinations. In this case, ODS sends all output objects that are named
ParameterEstimates and all output objects that are labeled "Type III Model ANOVA" to
the two destinations.
ods select ParameterEstimates
"Type III Model ANOVA";
Write the modified overall selection list to the SAS log. The ODS SHOW statement
writes to the SAS log the overall selection list, which now contains the two items that
were specified in the ODS SELECT statement. See the “SAS Log” on page 29.
ods show;
Create the output objects and send the selected output objects to the open
destinations. As PROC GLM sends each output object to the Output Delivery System,
ODS sends the two output objects from PROC GLM that match the items in the
selection list to the open destinations. See 1. in the table of contents in “HTML Output”
on page 29. Note that it is the label of an output object, not its name, that appears in the
table of contents. The label for ParameterEstimates is "Solution".
proc glm data=iron;
model loss=fe;
title 'Parameter Estimates and Type III Model ANOVA';
run;
Write the overall selection list to the SAS log. PROC GLM supports run-group
processing. Therefore, the RUN statement does not end the procedure, and ODS does
not automatically modify the selection list. See the “SAS Log” on page 29.
ods show;
End the GLM procedure. The QUIT statement ends the procedure. ODS removes all
objects that are not specified with PERSIST from the selection list. Because this action
removes all objects from the list, ODS sets the list to its default, SELECT ALL.
quit;
Write the current selection list to the SAS log. The ODS SHOW statement writes the
current selection list to the SAS log. See the “SAS Log” on page 29.
ods show;
Create the output objects, send the selected output objects to the open
destinations, and end the procedure. As PROC GLM sends each output object to the
Output Delivery System, ODS sends all the output objects to the HTML and LISTING
destinations. See 2. in the table of contents in “HTML Output” on page 29. The QUIT
statement ends the procedure. Because the list uses the argument ALL, ODS does not
automatically modify it when the PROC step ends.
proc glm data=iron;
model loss=fe;
title 'All Output Objects Selected';
run;
quit;
Example 1: Using a Selection List with Multiple Procedure Steps
27
Modify the overall selection lists. This ODS SELECT statement modifies the overall
selection list. It sends all output objects that are named OverallANOVA, and all output
objects that are labeled Fit Statistics, to both the HTML and LISTING destinations. The
PERSIST option specifies that OverallANOVA should remain in the selection list when
ODS automatically modifies it.
ods select OverallANOVA(persist) "Fit Statistics";
Create the output objects and send the selected output objects to the open
destinations. As PROC GLM sends each output object to the Output Delivery System,
ODS sends the two output objects from PROC GLM that match the items in the
selection list to the HTML and LISTING destinations. See 3. in the table of contents in
“HTML Output” on page 29.
proc glm data=iron;
model loss=fe;
title 'OverallANOVA and Fitness Statistics';
run;
End the GLM procedure and automatically modify the selection list. When the QUIT
statement ends the procedure, ODS automatically modifies the selection list. Because
OverallANOVA was specified with the PERSIST option, it remains in the selection list.
Because Fitness Statistics was not specified with the PERSIST option, ODS removes it
from the selection list.
quit;
Write the current selection list to the SAS log. The ODS SHOW statement writes the
current selection list to the SAS log. See the “SAS Log” on page 29.
ods show;
Create the output objects and send the selected output objects to the open
destinations. As PROC GLM sends each output object to the Output Delivery System,
ODS sends only the output object that is named OverallANOVA to the HTML and
LISTING destinations. See 4. in the table of contents in “HTML Output” on page 29.
proc glm data=iron;
model loss=fe;
title 'OverallANOVA';
title2 'Part of the Selection List Persists';
run;
End the GLM procedure and automatically modify the selection list. When the QUIT
statement ends the procedure, ODS automatically modifies the selection list. Because
OverallANOVA was specified with the PERSIST option, it remains in the selection list.
quit;
PROC PRINT does not produce any output that is named OverallANOVA. Therefore,
no PROC PRINT output is sent to the ODS destinations.
proc print data=iron;
title 'The IRON Data Set';
run;
Reset all selection lists. This ODS SELECT statement resets all selection lists to their
defaults.
28
Chapter 3
•
Using Selection and Exclusion Lists
ods select all;
Create the plots. As PROC PLOT creates and sends each output object to the Output
Delivery System, ODS sends each one to the HTML and LISTING destinations because
their lists and the overall list are set to SELECT ALL (the default).
proc plot data=iron;
plot fe*loss='*' / vpos=25 ;
label fe='Iron Content'
loss='Weight Loss';
title 'Plot of Iron Versus Loss';
run;
End the PLOT procedure. The QUIT statement ends the PLOT procedure. Because the
list uses the argument ALL, ODS does not automatically modify the list when the PROC
step ends.
quit;
Close the HTML destination. This ODS HTML statement closes the HTML destination
and all the files that are associated with it.
ods html close;
Example 1: Using a Selection List with Multiple Procedure Steps
29
SAS Log
Output 3.3 The ODS SHOW Statement Writes the Current Selection List to the SAS Log.
HTML Output
The contents file shows the output objects from each procedure that ODS sent to the
open ODS destinations. You can see that no output was written to the HTML destination
for PROC PRINT (because PROC PRINT did not produce anything whose name
matched the name in the selection list). You can also see that the PROC PLOT output
was written to the HTML destination after the ODS SELECT ALL statement was
executed.
30
Chapter 3
•
Using Selection and Exclusion Lists
Output 3.4 Contents File Produced by the ODS HTML Statement
Example 2: Conditionally Selecting Output Objects
Features:
ODS SELECT statement option:
WHERE=
ODS TRACE statement options:
LABEL
EXCLUDED
ODS HTML statement
Other features:
PROC UNIVARIATE
Program
data BPressure;
length PatientID $2;
Example 2: Conditionally Selecting Output Objects
input PatientID $
datalines;
120 50 SS 96 60
120 75 BL 140 90
165 110 JI 110 40
125 76 RW 133 60
110 50 JW 130 80
134 80 SB 118 76
122 70 AB 122 78
122 82
CK
CP
CP
FC
DS
JW
GS
HH
;
run;
31
Systolic Diastolic @@;
FR
ES
MC
KD
BH
NS
EC
100
120
119
108
120
122
112
70
70
66
54
65
78
62
title 'Systolic and Diastolic Blood Pressure';
ods trace on / label excluded;
ods select where=(_path_ ? "Diastolic" and
_name_='Moments') ;
proc univariate data=BPressure;
var Systolic Diastolic;
run;
Program Description
Create the BPressure data set.
data BPressure;
length PatientID $2;
input PatientID $ Systolic Diastolic @@;
datalines;
CK 120 50 SS 96 60 FR 100 70
CP 120 75 BL 140 90 ES 120 70
CP 165 110 JI 110 40 MC 119 66
FC 125 76 RW 133 60 KD 108 54
DS 110 50 JW 130 80 BH 120 65
JW 134 80 SB 118 76 NS 122 78
GS 122 70 AB 122 78 EC 112 62
HH 122 82
;
run;
Add a title.
title 'Systolic and Diastolic Blood Pressure';
Specify that SAS write the trace record to the SAS log. This ODS TRACE statement
writes the trace record to the SAS log. The LABEL option includes label paths in the
trace record. The EXCLUDED option includes information about output objects that
SAS excludes from the output destination.
ods trace on / label excluded;
Select output objects. The ODS SELECT statement with the WHERE = option
specified selects output objects that are named 'Moments' and that have 'Diastolic' in the
pathname.
ods select where=(_path_ ? "Diastolic" and
_name_='Moments') ;
32
Chapter 3
•
Using Selection and Exclusion Lists
Create the output objects and send the selected output objects to the open
destination. As PROC UNIVARIATE sends each output object to the Output Delivery
System, ODS sends the output object from PROC UNIVARIATE that matches the items
in the selection list to the open destination.
proc univariate data=BPressure;
var Systolic Diastolic;
run;
SAS Log: Trace Record
Output 3.5 SAS Log Including Trace Record
Example 2: Conditionally Selecting Output Objects
HTML Output
See Also
Statements
•
“ODS EXCLUDE Statement” on page 12
•
“ODS SHOW Statement” in SAS Output Delivery System: User's Guide
•
“ODS TRACE Statement” on page 68
33
34
Chapter 3
•
Using Selection and Exclusion Lists
35
Chapter 4
Other SAS Statements That Are
Used with ODS Procedures
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ODS GRAPHICS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ODS PREFERENCES Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ODS RESULTS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ODS TEXT= Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ODS TRACE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
ODS PROCLABEL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Dictionary
ODS GRAPHICS Statement
Enables or disables ODS Graphics processing and sets graphics environment options. This statement
affects ODS template-based (ODS Graphics) graphics only. The ODS GRAPHICS statement does not
affect device-based graphics (SAS/GRAPH).
Valid in:
Category:
Default:
Interaction:
See:
Anywhere
ODS: Output Control
ON. Beginning in SAS 9.4, ODS Graphics is enabled by default on all platforms
except z/OS. When running SAS in batch mode, the default is OFF.
SAS/GRAPH device-based global statements such as GOPTIONS, SYMBOL,
PATTERN, AXIS, and LEGEND do not affect template-based graphics. The ODS
GRAPHICS statement does not affect device-based graphics.
For information about common tasks for managing ODS Graphics output, see SAS
Graph Template Language: User's Guide.
For information about SVG and Universal Printing, see “Creating SVG (Scalable
Vector Graphics) Files Using Universal Printing” in SAS Language Reference:
Concepts.
Syntax
ODS GRAPHICS <OFF | ON> </ option(s)> ;
36
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Summary of Optional Arguments
ANTIALIAS | NOANTIALIAS | ANTIALIAS= ON | OFF
specifies whether anti-aliasing is applied to the rendering of the line and
markers in any graph.
ANTIALIASMAX= n
specifies the maximum number of graphics elements before anti-aliasing is
disabled.
ATTRPRIORITY=COLOR | NONE
specifies a priority for cycling of the group attributes.
BORDER | NOBORDER | BORDER=ON | OFF
specifies whether to draw a border around each graph.
BYLINE=NOBYLINE | TITLE | FOOTNOTE
specifies how the BY line is displayed in graphs.
DATASKINMAX=n
specifies the maximum number of skinned graphical elements allowed per
plot.
DISCRETEMAX=n
specifies the maximum number of discrete values to be shown in any graph.
DRILLTARGET="_blank" | "_self" | "_parent" | "_top" | "frame-name"
specifies the window that displays the drill-down output.
GROUPMAX=n
specifies the maximum number of group values to be shown in any graph.
HEIGHT=dimension
specifies the height of a graph.
IMAGEMAP | NOIMAGEMAP | IMAGEMAP=ON | OFF
specifies whether data tips are generated.
IMAGENAME="filename"
specifies the base image filename.
LABELMAX= n
specifies the maximum number of labeled areas before labeling is disabled.
LABELPLACEMENT= GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in the
graphs.
LEGENDAREAMAX= n
specifies an integer that is interpreted as the maximum percentage of the
overall graphics area that a legend can occupy.
LOESSOBSMAX= n
specifies an upper limit for the number of observations that can be used with
a loess plot.
OUTPUTFMT= file–type | STATIC
specifies the output format used to generate image or vector graphic files.
PANELCELLMAX=n
specifies the maximum number of cells in a graph panel where the number of
cells is determined dynamically by classification variables.
PUSH | POP
pushes and pops ODS GRAPHICS settings in a stack.
RESET | RESET= option
Reset one or more ODS GRAPHICS options to its default.
SCALE | NOSCALE | SCALE=ON | OFF
specifies whether the content of any graph is scaled proportionally.
ODS GRAPHICS Statement
37
SCALEMARKERS | NOSCALEMARKERS | SCALEMARKERS=ON | OFF
specifies whether the plot markers are to be scaled with the graph size.
SHOW
writes the current ODS GRAPHICS settings to the SAS log.
STACKDEPTHMAX=n
specifies the maximum stack depth for PUSH and POP requests.
SUBPIXEL | NOSUBPIXEL | SUBPIXEL=ON | OFF
specifies whether subpixel rendering should be used for rendering ODS
Graphics.
TIPMAX=n
specifies the maximum number of distinct mouse-over areas allowed before
data tips are disabled.
WIDTH=dimension
specifies the width of any graph.
Without Arguments
If the ODS automatic graphic capabilities are currently disabled, then specifying the
ODS GRAPHICS statement without options enables them. If the ODS automatic graphic
capabilities are currently enabled, then specifying the ODS GRAPHICS statement leaves
them enabled.
Required Arguments
ON
enables ODS Graphics processing. This is the default if no argument is used.
Note: Beginning in SAS 9.4, ODS Graphics is enabled by default on all platforms
except z/OS.
Alias
YES
OFF
disables ODS Graphics processing.
Alias
NO
Optional Arguments
ANTIALIAS | NOANTIALIAS | ANTIALIAS= ON | OFF
specifies whether anti-aliasing is applied to the rendering of the line and markers in
any graph. Anti-aliasing smooths the appearance of lines and some markers. Text
displayed in the graph is always anti-aliased. For graphical displays that plot large
numbers of points it is recommended that ANTIALIAS=OFF be specified for
performance considerations.
ANTIALIAS
smooths jagged edges of all components in the graph.
NOANTIALIAS
does not smooth jagged edges of components other than text in the graph.
ANTIALIAS=ON | OFF
specifies whether anti-aliasing is applied to the rendering of the line and markers
in the graph.
ON
smooths jagged edges of all components in the graph.
38
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Alias
YES
OFF
does not smooth jagged edges of components other than text in the graph.
Alias
NO
Default
ANTIALIAS or ANTIALIAS=ON | YES
Restriction
If the number of markers or lines in the plot exceeds the number
specified by the ANTIALIASMAX= option, then the ANTIALIAS
option is turned off. This is true even if you specify the option
ANTIALIAS=ON or ANTIALIAS.
ANTIALIASMAX= n
specifies the maximum number of graphics elements before anti-aliasing is disabled.
For example, if there are more than 400 scatter point markers to be anti-aliased and
ANTIALIASMAX=400, then no markers are anti-aliased. The default value is 4000.
Note: Prior to the third maintenance release of SAS 9.4, the ANTIALIASMAX=
option specifies the maximum number of observations in the graph data to be
anti-aliased before anti-aliasing is disabled. The default is 4000. When the graph
data contains more than 4000 observations, anti-aliasing is disabled for the entire
graph. Starting with the third maintenance release of SAS 9.4, the
ANTIALIASMAX= option specifies the maximum number of graphics elements
to be anti-aliased in each plot on a per-plot basis. The default remains at 4000. If
any plot in a graph contains more than 4000 elements, anti-aliasing is disabled
for that plot. Anti-aliasing is enabled for the rest of the graph in that case.
n
specifies a positive integer.
Default
4000
ATTRPRIORITY=COLOR | NONE
specifies a priority for cycling of the group attributes.
COLOR
assigns priority to the color attribute rotation by cycling through the list of colors
while holding the marker symbol and line pattern constant. When all of the
colors are exhausted, the marker symbol and line style attributes increment to the
next element, and then the colors in the list are repeated. This pattern repeats as
needed.
NONE
does not use an attribute priority in the rotation pattern, even if one is set in the
active style’s AttrPriority attribute. The rotation pattern cycles progressively
through the attribute lists.
Default
The AttrPriority attribute of the graph style element, or NONE if the
current style does not define the AttrPriority style attribute.
Interaction
The default lists of data colors, contrast colors, marker symbols, and
line patterns are set in the active style’s GraphData1–GraphDataN
elements.
BORDER | NOBORDER | BORDER=ON | OFF
specifies whether to draw a border around each graph.
ODS GRAPHICS Statement
39
BORDER
specifies whether to draw a border around the graph.
NOBORDER
specifies not to draw a border around any graph.
BORDER=ON | OFF
specifies whether to draw the graph with a border on the outermost layout.
ON
specifies to draw a border around the graph.
Alias
YES
OFF
specifies not to draw a border around the graph.
Alias
Default
NO
BORDER or BORDER=ON | YES
BYLINE=NOBYLINE | TITLE | FOOTNOTE
specifies how the BY line is displayed in graphs when an analysis is run with a BY
statement. By default, no BY line is displayed.
The following code is an example of how the placement of the BY line is controlled
in each graph template:
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GraphValueText;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
You can modify the graph template if you want to change how the BY line is
displayed. Because most graphs have titles and few graphs have footnotes, the BY
line looks better when it is displayed as a footnote. For complete documentation
about the Graph Template Language, see SAS Graph Template Language: User's
Guide.
When the BYLINE= option is specified, and there are BY groups, ODS creates a BY
line and sets the appropriate special dynamic variables. The following table lists the
special dynamic variables for BY lines. For complete documentation about special
dynamic variables, see “Special Dynamic Variables” in SAS Graph Template
Language: User's Guide.
Table 4.1
Special Dynamic Variables for BY Lines
_BYFOOTNOTE_
This variable is set to 1 when you specify a BY statement and the
ODS GRAPHICS BYLINE= option is set to FOOTNOTE.
Otherwise, the variable is set to 0 or is NULL.
_BYTITLE_
This variable is set to 1 when you specify a BY statement and the
ODS GRAPHICS BYLINE= option is set to TITLE. Otherwise, the
variable is set to 0 or is NULL.
40
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
The variables in the table are set automatically only for analytical procedures that
support ODS GRAPHICS. For a list of these procedures, see “Automatic Graphics
from SAS Analytical Procedures” in SAS Graph Template Language: User's Guide.
For all other procedures, the variables are not set automatically (NULL).
NOBYLINE
specifies that no BY line is displayed. NOBYLINE is the default.
FOOTNOTE
specifies that the BY line is displayed as a left-justified graph footnote. This is
the recommended setting.
TITLE
specifies that the BY line is displayed as a centered graph title. Specifying
TITLE is not recommended because graphs are not designed to have additional
title lines.
Default
NOBYLINE
DATASKINMAX=n
specifies the maximum number of skinned graphical elements allowed per plot.
Note: This feature applies to the first maintenance release of SAS 9.4 and to later
releases.
n
specifies a positive integer.
Default
200
DISCRETEMAX=n
specifies the maximum number of discrete values to be shown in any graph. Bar
charts and box plots are examples of affected plot types. Scatter plots and other plot
types can be affected if the data to be plotted is discrete or the axis is discrete.
n
specifies a positive integer.
Default
1000
Tips
Some plot layers might be unaffected by the DISCRETEMAX= option,
and those layers are rendered. If all layers are affected, a blank graph is
rendered.
If the value specified by the DISCRETEMAX= option is exceeded by any
plot layer in the graph, that layer is not drawn and a warning message is
issued.
DRILLTARGET="_blank" | "_self" | "_parent" | "_top" | "frame-name"
specifies the window that displays the drill-down output.
Note: This option is supported only for HTML.
"_blank"
opens a new browser window to display the drilldown output.
Default
_blank is the default.
Requirements
You must enclose _blank in quotation marks.
You must specify _blank in lowercase.
ODS GRAPHICS Statement
41
"_self"
opens the drill-down output in the same window.
Requirements
You must enclose _self in quotation marks.
You must specify _self in lowercase.
"_parent"
opens the drill-down output in the parent frame.
Requirements
You must enclose _parent in quotation marks.
You must specify _parent in lowercase.
"_top"
opens the drill-down output in the full body of the window.
Requirements
You must enclose _top in quotation marks.
You must specify _top in lowercase.
"frame-name"
opens the drill down output in the named frame in the current window. If the
name does not exist, the output is opened in a new window.
Requirement
You must enclose frame–name in quotation marks.
GROUPMAX=n
specifies the maximum number of group values to be shown in any graph. Any graph
that supports the GROUP= option is affected.
n
specifies a positive integer.
Default
1000
Tip
If the value specified by the GROUPMAX= option is exceeded by any plot
layer in the graph, that layer is rendered. The system ignores the GROUP=
option and issues a warning message.
HEIGHT=dimension
specifies the height of a graph.
dimension
is a nonnegative number followed by one of these units of measure:
Table 4.2
Units of Measure for Dimension
cm
Centimeters
in
Inches
mm
Millimeters
pct or %
Percentage
pt
Point size (72 points = 1 inch)
42
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
px
Pixels
Defaults
The value of the SAS registry entry "ODS > ODS GRAPHICS >
Design Height" or the value of the DesignHeight= option in a
STATGRAPH template. Typically, the value is 480px.
For the PRINTER destination, units of 1/150 of an inch
Tip
If only the HEIGHT= option is specified, then the default aspect of the graph is
maintained.
IMAGEMAP | NOIMAGEMAP | IMAGEMAP=ON | OFF
controls data tips and drill down generation. Data tips are pieces of explanatory text
that appear when you hold the mouse pointer over the data portions of a graph
contained in an HTML page.
IMAGEMAP
specifies to generate data tips.
NOIMAGEMAP
specifies not to generate data tips.
IMAGEMAP= ON | OFF
controls data tips generation.
ON
specifies to generate data tips.
Alias
YES
OFF
specifies not to generate data tips.
Alias
NO
Default
NOIMAGEMAP or IMAGEMAP=OFF | NO
Restrictions
This option applies only when the ODS HTML destination is used.
An image map is not generated using SVG with ODS Graphics. The
image map data that is used to produce tooltips and links is written
directly in the SVG and is not part of the HTML. Using HTML5 with
the inline SVG mode (the default value), the tooltips and links are
written in the SVG portion of the document.
Interaction
When IMAGEMAP | IMAGEMAP=ON is specified and the ODS
HTML destination is used, the IMAGE_DPI option in the ODS
HTML destination is ignored, if specified, and the default image
resolution of 96 DPI is used.
IMAGENAME="filename"
specifies the base image filename. If more than one image is generated, each is
assigned filename as a base name followed by a number in order to create unique
names. This numbering can be reset with the RESET=INDEX option. Path
information (if needed) can be set with the GPATH= option on the ODS destination
ODS GRAPHICS Statement
43
statement. The default path is the current output directory. A file extension for
filename is automatically generated based on the OUTPUTFMT= option.
Default
The name of the output object.
Restriction
filename must be a single name. It must not include any path
specification or image-format name extension.
Requirement
You must enclose filename in quotation marks.
See
“Specifying and Resetting the Image Name” on page 53
LABELMAX= n
specifies the maximum number of labeled areas before labeling is disabled. For
example, if there are more than 50 points to be labeled and LABELMAX=50, then
no points are labeled.
n
specifies a positive integer.
Default
200
Restriction
Data label collision avoidance is turned off under the following
conditions:
• The number of observations with nonmissing labels exceeds the
value specified by LABELMAX=.
• The number of observations exceeds five times the value
specified by LABELMAX=.
A message is then sent to the SAS log.
Tip
To turn off collision avoidance specify LABELMAX=0.
LABELPLACEMENT= 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
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.
44
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Restriction
Default
For BANDPLOT and LINECHART, the SA method has no effect
on the curve labels when the CURVELABELPOSITION= option
specifies START or END.
GREEDY
LEGENDAREAMAX= n
specifies an integer that is interpreted as the maximum percentage of the overall
graphics area that a legend can occupy.
Note: Starting with the third maintenance release for SAS 9.4,
LEGENDAREAMAX= replaces MAXLEGENDAREA=. However,
MAXLEGENDAREA= is supported as an alias. It is recommended that you use
LEGENDAREAMAX=.
n
specifies a positive integer.
Alias
MAXLEGENDAREA=
Default
20
Range
0–100
Tip
To turn off the legend, specify LEGENDAREAMAX=0. No warning is
issued when the legend is turned off in this way.
LOESSOBSMAX= n
specifies an upper limit for the number of observations that can be used with a loess
plot.
Note: Starting with the third maintenance release for SAS 9.4, LOESSOBSMAX=
replaces LOESSMAXOBS=. However, LOESSMAXOBS= is supported as an
alias. It is recommended that you use LOESSOBSMAX=.
If the number of observations of the loess plot exceeds the specified limit, the loess
plot is not drawn.
For example, the following specifies that the most observations a loess plot can have
is 1000.
LOESSOBSMAX=1000
Alias
LOESSMAXOBS=
Default
5000
OUTPUTFMT= file–type | STATIC
specifies the output format used to generate image or vector graphic files. If the
image or vector graphic format is not valid for the active output destination, the
format is automatically changed to the default format for that destination.
file-type
is the image or vector graphic format to be generated. See “Supported File Types
for Output Destinations” on page 55.
STATIC
uses the best quality static image format for the active output destination. This is
the default output format.
ODS GRAPHICS Statement
45
The STATIC keyword can be used to reset the output format to its default
state.
TIP
Default
STATIC
See
“Specifying the Image Format” on page 54
PANELCELLMAX=n
specifies the maximum number of cells in a graph panel where the number of cells is
determined dynamically by classification variables. If the number of cells in the
panel exceeds the specified limit, the panel is not drawn.
n
specifies a positive integer.
Default
10000
Note
Graphs with DataPanel or DataLattice templates layouts are affected. In the
ODS Graphics Procedures, this option affects graphs that are created with
the SGPANEL procedure. If the value specified by the
PANELCELLMAX= option is exceeded by any of these layouts, an empty
graph is rendered and a warning message is issued.
PUSH | POP
pushes and pops ODS GRAPHICS settings in a stack. This feature enables you to
temporarily save your custom settings in a stack and later restore those settings.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
PUSH
pushes the current ODS GRAPHICS settings to a stack.
POP
restores the most recently pushed settings from the stack. For each PUSH action,
you can specify a POP request. ODS issues a warning if you specify POP without
a corresponding PUSH. In that case, nothing is popped because nothing has been
pushed.
The pushed settings remain in the stack in the current SAS session until they are
popped or the stack is emptied.
Interaction
You can specify PUSH as many times as you like up to the limit that is
defined by the STACKDEPTHMAX= option. You can also use
STACKDEPTHMAX= to empty the stack. For more information, see
“Managing the Stack Depth” on page 59.
Note
Order of specification is important when using the PUSH and POP
options. For more information, see “About PUSH and POP” on page
58.
Tip
Use the SHOW option to show the current ODS GRAPHICS settings.
See
“Temporarily Saving and Restoring ODS GRAPHICS Settings” on
page 58
RESET | RESET= option
Reset one or more ODS GRAPHICS options to its default.
46
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
RESET
resets all options to their defaults.
RESET=
resets one of the following to its default:
ALL
resets all reset-options to their defaults.
ANTIALIAS
resets the ANTIALIAS= option to its default.
See
ANTIALIAS= on page 37
ANTIALIASMAX
resets the ANTIALIASMAX= option to its default.
See
ANTIALIASMAX= on page 38
ATTRPRIORITY
resets the ATTRPRIORITY= option to its default.
See
ATTRPRIORITY= on page 38
BORDER
resets the BORDER= option to its default.
See
BORDER= on page 38
BYLINE
resets the BYLINE= option to its default.
See
BYLINE= on page 39
DATASKINMAX
resets the DATASKINMAX= option to its default.
See
DATASKINMAX= on page 40
DISCRETEMAX
resets the DISCRETEMAX= option to its default.
See
DISCRETEMAX= on page 40
DRILLTARGET
resets the DRILLTARGET= option to its default.
See
DRILLTARGET= on page 40
GROUPMAX
resets the GROUPMAX= option to its default.
See
GROUPMAX= on page 41
HEIGHT
resets the HEIGHT= option to its default.
See
HEIGHT= on page 41
ODS GRAPHICS Statement
47
IMAGEMAP
resets the IMAGEMAP= option to its default.
Note
Not all output destinations support this feature.
See
IMAGEMAP= on page 42
IMAGENAME
resets the IMAGENAME= option to its default.
Note: This feature applies to the third maintenance release of SAS 9.4 and to
later releases.
See
IMAGENAME= on page 42
INDEX <(positive-integer)>
resets the index counter that is appended to static image files.
When specifying this option, you can also specify the value for the index
counter. The number that you specify must be enclosed in parentheses.
positive-integer determines the suffix for the next subsequent image, and
increments with each new image. This feature applies to the third
maintenance release of SAS 9.4 and to later releases.
See
“Resetting the Image Name” on page 53
LABELMAX
resets the LABELMAX= option to its default.
See
LABELMAX= on page 43
LABELPLACEMENT
specifies the label-placement algorithm to use for positioning labels in the
graphs.
See
LABELPLACEMENT= on page 43
LEGENDAREAMAX
resets the LEGENDAREAMAX= option to its default.
See
LEGENDAREAMAX= on page 44
LOESSOBSMAX
resets the LOESSOBSMAX= option to its default.
See
LOESSOBSMAX= on page 44
OUTPUTFMT
resets the OUTPUTFMT= option to its default.
Note: This feature applies to the third maintenance release of SAS 9.4 and to
later releases.
See
OUTPUTFMT= on page 44
PANELCELLMAX
resets the PANELCELLMAX= option to its default.
See
PANELCELLMAX= on page 45
48
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
SCALE
resets the SCALE= option to its default.
See
SCALE= on page 48
SCALEMARKERS
resets the SCALEMARKERS= option to its default.
See
SCALEMARKERS= on page 49
STACKDEPTHMAX
resets the STACKDEPTHMAX= option to its default.
Note: This feature applies to the third maintenance release of SAS 9.4 and to
later releases.
See
STACKDEPTHMAX= on page 50
SUBPIXEL
resets the SUBPIXEL option to its default.
Note: This feature applies to the third maintenance release of SAS 9.4 and to
later releases.
See
SUBPIXEL on page 51
TIPMAX
resets the TIPMAX= option to its default.
See
TIPMAX = on page 51
WIDTH
resets the WIDTH= option to its default.
See
WIDTH= on page 52
SCALE | NOSCALE | SCALE=ON | OFF
specifies whether the content of any graph is scaled proportionally.
SCALE
scales the components of graph proportionally.
NOSCALE
does not scale the components of graph proportionally.
SCALE=ON | OFF
specifies whether the content of the graph is scaled proportionally.
ON
scales the components of graph proportionally.
Alias
YES
OFF
does not scale the components of graph proportionally.
Aliases
NOSCALE
NO
ODS GRAPHICS Statement
49
SCALE or SCALE=ON | YES
Default
SCALEMARKERS | NOSCALEMARKERS | SCALEMARKERS=ON | OFF
specifies whether the plot markers are to be scaled with the graph size. The scaling
factor is based on the height of the graph cells and the height of the graph.
SCALEMARKERS
scales the markers with the graph size.
NOSCALE
does not scale the markers with the graph size.
SCALEMARKERS=ON | OFF
specifies whether the plot markers are to be scaled with the graph size.
ON
scales the markers with the graph size.
YES
Alias
OFF
does not scale the markers with the graph size.
Aliases
NOSCALE
NO
Default
SCALEMARKERS or SCALEMARKERS=ON | YES
Restriction
Scaling is done only if the graph contains multiple cells or single
nested cells.
SHOW
writes the current ODS GRAPHICS settings to the SAS log. This option enables you
to verify which settings are in effect. The option is especially useful when you use
the PUSH and POP options to restore settings. For more information, see
“Temporarily Saving and Restoring ODS GRAPHICS Settings” on page 58.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
If no options have been specified, then SHOW lists those options for which ODS
currently knows the default values.
The following statement resets all settings and shows the default values.
ods graphics / reset=all show;
Here are the default values displayed in the SAS log:
If you have specified the settings for one or more options, then SHOW includes
those settings along with the defaults.
50
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Order of specification is important when using the SHOW option. For example, the
following statement shows the current settings and then sets the NOBORDER
option.
ods graphics / show noborder;
However, the following statement sets the NOBORDER option and then shows the
settings. The NOBORDER setting is shown in the log along with the other settings
that are in effect.
ods graphics / noborder show;
The following statement resets all settings. It then sets the image width and shows
the default settings along with the specified width.
ods graphics / reset=all width=5in show;
Here are the default values plus the image width, as displayed in the SAS log:
If you have specified the settings for some options but want to see the default
values without losing your specified settings, issue the following two
statements. The first statement pushes your specified settings, resets all
settings, and then lists options for which ODS currently knows the default
values. The second statement restores your previous settings.
Tip
ods graphics / push reset=all show;
ods graphics / pop;
STACKDEPTHMAX=n
specifies the maximum stack depth for PUSH and POP requests. The stack is used to
temporarily store ODS GRAPHICS settings when you issue PUSH requests. PUSH
saves the current settings to the stack and increments the stack depth. POP restores
the most recently saved settings from the stack and decrements the stack depth.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
n
specifies a positive integer.
If n is less than the current stack depth, then the stack is popped until its depth
equals n. Popping the stack does not affect other option settings.
Defaults
1024 is the default maximum depth
0 is the default depth
Tips
To empty the stack and then reset it to the default maximum depth, issue
the following statement:
ods graphics / stackdepthmax=0 reset=stackdepthmax;
You can use any of the following commands to reset the stack to its
default maximum depth:
reset=stackdepthmax
reset=all
ODS GRAPHICS Statement
51
reset
stackdepthmax=1024
“Managing the Stack Depth” on page 59
See
SUBPIXEL | NOSUBPIXEL | SUBPIXEL=ON | OFF
specifies whether subpixel rendering should be used for rendering ODS Graphics.
Subpixel rendering produces smoother curves and more precise bar spacing.
Note: This feature applies to the third maintenance release of SAS 9.4 and to later
releases.
SUBPIXEL
always uses subpixel rendering, when applicable, for rendering lines and bars.
NOSUBPIXEL
never uses subpixel rendering.
SUBPIXEL=ON | OFF
specifies whether subpixel rendering should be used.
ON
always uses subpixel rendering, when applicable, for rendering lines and
bars.
Alias
YES
OFF
never uses subpixel rendering.
Alias
NO
Default
Subpixel rendering is always enabled for vector-graphics output. It is
enabled by default for image output, unless the graph contains a
scatter plot or a scatter-plot matrix. In those cases, subpixel rendering
is disabled by default.
Requirement
Antialiasing must be enabled for this option to have any effect.
Antialiasing is enabled by default. To re-enable antialiasing, use the
ANTIALIAS=ON option in the ODS GRAPHICS statement.
Tip
For a large amount of data, antialiasing is disabled when the number
of observations exceeds the default maximum of 4000 observations.
In that case, subpixel rendering is also disabled. To increase the
maximum, use the ANTIALIASMAX= option in the ODS
GRAPHICS statement.
See
“Subpixel Rendering” in SAS ODS Graphics: Procedures Guide
TIPMAX=n
specifies the maximum number of distinct mouse-over areas allowed before data tips
are disabled. For example, if there are more than 400 points in a scatterplot, and
TIPMAX=400, then no data tips appear. The default maximum value is 500.
Note: Prior to the third maintenance release of SAS 9.4, the TIPMAX= option
specifies the maximum number of observations in the graph data to be allowed
before data tips are disabled. The default is 500. When the graph data contains
more than 500 observations, data tips are disabled for the entire graph. Starting
with the third maintenance release of SAS 9.4, the TIPMAX= option specifies
52
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
the maximum number of mouse-over areas allowed before data tips are disabled.
This threshold is applied separately for each plot. The default remains at 500. If
any plot in a graph contains more than 500 mouse-over areas, data tips are
disabled for that plot. Data tips are enabled for the remaining plots in the graph.
n
specifies a positive integer.
500
Default
WIDTH=dimension
specifies the width of any graph.
dimension
is a nonnegative number followed by one of these units of measure:
Table 4.3
Units of Measure for Dimension
cm
Centimeters
in
Inches
mm
Millimeters
pct or %
Percentage
pt
Point size (72 points = 1 inch)
px
Pixels
Defaults
The value of the SAS registry entry "ODS > ODS GRAPHICS >
Design Width" or the value of the DesignWidth= option in a
STATGRAPH template. Typically, this value is 640px.
For the PRINTER destination, units of 1/150 of an inch
Tip
If only the WIDTH= option is specified, then the default aspect of the graph is
maintained.
Details
Using the ODS GRAPHICS Statement
You can enable ODS Graphics by using one of the following equivalent statements:
ods graphics on;
ods graphics;
When you specify one of these statements before your procedure invocation, Base,
SAS/STAT, SAS/ETS, and SAS/QC procedures support ODS Graphics, either by
default, or when you specify procedure options for requesting particular graphs.
To disable ODS Graphics, specify the following statement:
ods graphics off;
ODS GRAPHICS Statement
53
Note: ODS Graphics is ON by default for procedures SGPLOT, SGPANEL,
SGSCATTER, SGDESIGN, and SGRENDER. For other products, the initial state of
ODS Graphics is determined by a SAS Registry setting.
Using the ODS GRAPHICS Statement for Batch Jobs
To generate device-based graphics output in UNIX batch jobs, you must set the
DISPLAY system option before creating the output. To set the display, enter the
following command:
export DISPLAY=<ip_address>:0
The ip_address is the TCP/IP address, or the name of a UNIX terminal. Usually, the IP
address of the UNIX system where SAS is running would be used. If you do not set the
DISPLAY variable, then you get an error message in the SAS log.
Specifying and Resetting the Image Name
Specifying the Image Name
For ODS Graphics output, by default, the ODS object name is used as the “root” name
for the image output file. The following example creates a GIF image named
REGPLOT:
ods graphics / imagename="regplot" outputfmt=gif;
The assigned name REGPLOT is treated as a "root" name and the first output created is
named REGPLOT. Subsequent graphs are named REGPLOT1, REGPLOT2, and so on,
with an increasing index counter. This numbering can be reset with the RESET=INDEX
option.
Resetting the Image Name
The RESET=INDEX option enables you to reset the filename numbering sequence. For
example, if you are developing a template and it takes several submissions to get the
desired output, you can use the RESET or RESET=INDEX option to force each output
to replace itself:
ods graphics / reset=index ... ;
This specification causes all subsequent images to be created with the default or current
image name.
When specifying this option, you can also specify the value for the index counter. The
value that you specify determines the suffix for the next subsequent image. For example:
ods graphics / reset=index(100) imagename="MyName";
The next graph that you produce is named MYNAME100.
This feature is useful for creating animated graphics. For example, for a sequence of 100
images, you might begin with the following statement:
ods graphics / reset=index(1) imagename="MyName";
In the example, your program produces 100 images named MYNAME1,
MYNAME2, ..., MYNAME100. If you later add more images to the animation, you
might submit the following:
ods graphics / reset=index(101) imagename="MyName";
The next generated image is named MYNAME101.
Note: The ability to specify the value for the index counter applies to the third
maintenance release in SAS 9.4 and later releases.
54
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Specifying the Image Format
Each ODS destination uses a default format for its output. You can use the
OUTPUTFMT= option in the ODS GRAPHICS statement to change the output format.
Note: Unless you have a special requirement for changing the image format, we
recommend that you not change it. The default PNG or vector graphic format is far
superior to other formats, such as GIF, in support for transparency and a large
number of colors. Also, PNG and vector graphics images require much less disk
storage space than JPEG or TIFF formats.
If you want to generate vector graphics images, you can use the following
OUTPUTFMT= values for each destination:
Table 4.4
Generating Vector Graphics Output with ODS
ODS Destination
OUTPUTFMT=value
ODS EPUB
OUTPUTFMT=SVG
ODS destination for Excel
OUTPUTFMT=EMF
ODS HTML
OUTPUTFMT=SVG
ODS LISTING
OUTPUTFMT=EMF
OUTPUTFMT=PDF
OUTPUTFMT=PS | EPS | EPSI
OUTPUTFMT=SVG
OUTPUTFMT=PCL
ODS PDF
Vector graphics images are generated by
default
ODS PCL
OUTPUTFMT=PCL (for PCL output)
ODS PS
OUTPUTFMT=PS (for PostScript output)
ODS destination for PowerPoint
OUTPUTFMT=EMF
ODS PRINTER
OUTPUTFMT=PCL (for PCL output)
OUTPUTFMT=PDF (for PDF output)
OUTPUTFMT=PS | EPS | EPSI (for
PostScript output)
OUTPUTFMT=SVG
ODS RTF
OUTPUTFMT=EMF
ODS Measured RTF
OUTPUTFMT=EMF
When a vector graphics image cannot be generated for the format that you specify, a
PNG image is generated instead and is embedded in the specified output file. The output
file format and extension are not changed in that case. In the following cases, a vector
graphics image cannot be generated:
ODS GRAPHICS Statement
•
surface plots
•
bivariate histograms
•
graphs that use smooth gradient contours
•
graphs that include continuous legends
•
graphs that use data skins
•
graphs that use transparency (EMF and PS ODS destinations only)
•
graphs that contain one or more rotated images
•
graphs that have a broken axis
•
graphs that contain outline marker characters
55
Starting with the second maintenance release of SAS 9.4, additional cases for which
vector graphics output cannot be generated for graphs are as follows:
•
graphs that use gradient fill for bars in a bar chart, histogram, or waterfall chart
•
graphs that use the back-light effect on text
•
graphs that include a text plot that displays text with an outlined bounding box or
text with a filled bounding-box background
•
graphs that include images (PostScript output only)
Starting with the third maintenance release of SAS 9.4, vector graphics output can be
generated in the EMF, PDF, and SVG output formats for the following cases:
•
graphs that use data skins
Note: For the EMF, PDF, and SVG formats, vector graphics output is not supported
for graphs that use transparency and data skins. An image is generated in that
case.
•
graphs that include one or more rotated images
•
graphs that use gradient fills (except PDF)
•
graphs that use a continuous legend
Note: For the PDF output format, vector graphics output is not supported for graphs
that use a continuous legend and data transparency. An image is generated in that
case.
Supported File Types for Output Destinations
The following table lists all of the supported file types for some ODS output
destinations.
Table 4.5
Supported File Types for Output Destinations
Output Destination
Supported File Types
EPUB, EPUB2
PNG (default), GIF, JPG, SVG
56
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Output Destination
Supported File Types
EPUB3
SVG (default), PNG, GIF, JPG
Note: EPUB3 was added in the first maintenance release of
SAS 9.4.
Note: Starting with the third maintenance release of SAS 9.4,
EPUB3 is an alias for EPUB, and the EPUB3 supported file
types supersede the EPUB supported file types.
ODS destination for Excel
PNG (default), JPEG, JPG, EMF
HTML
PNG (default), GIF, JPEG, JPG, SVG
HTML5
SVG (default), PNG, GIF, JPEG, JPG
LISTING
PNG (default), BMP, EMF, EPSI, GIF, JFIF, JPEG, JPG, PDF,
PS, SASEMF, STATIC, TIFF, WMF, PSL, SVG
PDF
Native PDF (default), JPEG, JPG, GIF, PNG
ODS destination for
PowerPoint
PNG (default), JPEG, JPG, GIF, EMF, TIFF, BMP
PS
PNG (default), JPEG, JPG, GIF, EPS, PDF, PCL, PS
RTF and Measured RTF
EMF (default), PNG, JPEG, JPG, JFIF
Description of Supported File Types
The following table provides descriptions of the supported file types for ODS output
destinations.
Table 4.6
Description of Supported File Types
File Type
Description
BMP (Microsoft Windows Device
Independent Bitmap)
Supports color-mapped and true color images
that are stored as uncompressed or run-length
encoded data. BMP was developed by
Microsoft Corporation.
CGM (Computer Graphics Metafile)
A free and open international standard file
format for 2-D vector graphics, raster
graphics, and text. This format is defined by
ISO/IEC 8632.
DIB (Microsoft Windows Device Independent
Bitmap)
See the description of BMP.
EMF ( Enhanced Metafile Format)
Supports standard Enhanced Metafile Format.
ODS GRAPHICS Statement
57
File Type
Description
EMF Plus (Enhanced Metafile Format Plus
Extensions)
Supports Enhanced Metafile Plus Extensions
that provides additional functionality, such as
support of RGBA colors.
EMF Dual (Enhanced Metafile Format and
Enhanced Metafile Format Plus Extensions)
Produces both EMF and EMF Plus formats
simultaneously in the same output.
EPS
Encapsulated PostScript
EPSI (Microsoft NT Enhanced Metafile)
An extended version of the standard
PostScript (PS) format. Files that use this
format can be printed on PostScript printers
and can also be imported into other
applications. Notice that EPSI files can be
read, but PS files cannot be read.
GIF (Graphics Interchange Format)
Supports only color-mapped images. GIF is
owned by CompuServe, Inc.
JFIF (JPEG File Interchange Format)
Supports JPEG image compression. JFIF
software is developed by the Independent
JPEG Group.
JPEG or JPG (Joint Photographic Experts
Group)
A file format that is used for storing
noninteractive images.
PBM (Portable Bitmap Utilities)
Supports gray-scale, color, RGB, and bitmap
files. The Portable Bitmap Utilities are a set of
free utility programs that were developed
primarily by Jef Poskanzer.
PCL
Printer Control Language
PDF (Portable Document Format)
A file format for electronic distribution and
exchange of documents.
PNG (Portable Network Graphic)
Supports true color, gray-scale, and 8-bit
images.
PS (PostScript Image File Format)
The Image classes use only PostScript image
operators. A level II PS printer is required for
color images. PostScript was developed by
Adobe Systems, Inc.
PSL (PostScript)
PostScript
STATIC
Chooses the best image format for the current
ODS destination.
SVG (Scalable Vector Graphics)
Is an XML language for describing twodimensional vector graphics.
58
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
File Type
Description
TIFF (Tagged Image File Format)
Internally supports a number of compression
types and image types, including bitmapped,
color-mapped, gray-scaled, and true color.
TIFF was developed by Aldus Corporation
and Microsoft Corporation and is used by a
wide variety of applications (available if
licensed).
XBM
X Window Bitmap
XPM
X Window Pixmap
Temporarily Saving and Restoring ODS GRAPHICS Settings
This feature applies to the third maintenance release of SAS 9.4 and to later releases.
About PUSH and POP
Although you can use the RESET option to restore the default ODS GRAPHICS
settings, there might be times when you want to save your current custom settings and
later restore them. ODS enables you to temporarily store your custom settings in a stack
created for this purpose, perform some other task with different settings, and then restore
the previous settings.
The PUSH option saves the current ODS GRAPHICS settings to the stack and
increments the stack depth. The POP option restores the most recently stored settings
from the stack and decrements the stack depth.
This feature is useful when you run macros. Within a macro you can PUSH at the start of
the macro and POP at the end. This enables your macro to have custom ODS
GRAPHICS behaviors without affecting the calling environment.
You can specify PUSH as many times as you like up to the limit that is defined by the
STACKDEPTHMAX= option. The pushed settings remain in the stack in the current
SAS session until they are popped or the stack is emptied. For more information, see
“Managing the Stack Depth” on page 59. For each PUSH request, you can specify a
POP request. ODS issues a warning if you specify POP without a corresponding PUSH.
In that case, nothing is popped because nothing has been pushed to the stack.
Order of specification is important when using the PUSH option. For example, the
following statement pushes the NOBORDER option to the stack along with any other
custom settings that are in effect.
ods graphics / noborder push;
A subsequent POP request restores the pushed settings including NOBORDER.
However, the following statement pushes the current custom settings and then sets the
NOBORDER option.
ods graphics / push noborder;
Here, the subsequent POP request restores whatever border setting was in effect when
the PUSH request was made.
Use the SHOW option to show the ODS GRAPHICS settings that are currently
in effect.
TIP
ODS PREFERENCES Statement
59
Settings That Can Be Pushed
The PUSH and POP commands apply to all ODS GRAPHICS options except the
following: PUSH, POP, RESET=INDEX, and SHOW.
How Code Errors Affect the PUSH Operation
If the ODS GRAPHICS statement contains a syntax error, then the PUSH request is
ignored.
For example, the PUSH request is ignored in the following statement:
ods graphics / antialias=bogus push;
A syntax error (BOGUS) in ANTIALIAS causes the parser to ignore the remaining
options. However, a simple semantics error does not prevent the remaining options from
being handled. In the following statement, the PUSH request is honored.
ods graphics / antialiasmax=-1 push;
In this statement, ANTIALIASMAX= –1 is invalid. The option expects a zero or a
positive integer. In this case, a warning is issued to the log, but the PUSH occurs.
Note: Syntax errors in your code can have other unexpected results that are not
described here.
Managing the Stack Depth
By default, the stack supports up to 1024 pushes. You can change the default by using
the STACKDEPTHMAX= option.
If the specified STACKDEPTHMAX= value is less than the current stack depth, then the
stack is popped until its depth equals the specified value. Popping the stack does not
affect other option settings.
If you want to empty the stack, issue the following statement:
ods graphics / stackdepthmax=0 reset=stackdepthmax;
This statement first empties the stack of all PUSH requests and then restores the stack
size to 1024.
ODS PREFERENCES Statement
Reverts the ODS settings back to start-up defaults.
Valid in:
Category:
Tip:
Anywhere
ODS: Output Control
It is useful to specify this statement if you are creating graphics and have changed
your default output directory to something other than Work. When you specify the
ODS PREFERENCES statement, the default directory is set to Work, which is the
original default. Any output is then generated in your Work folder.
Syntax
ODS PREFERENCES;
Without Arguments
The ODS PREFERENCES statement reverts the ODS back to the default behavior:
•
HTML output is created.
60
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
•
LISTING output is not created.
•
Both HTML and graph image files are saved in the Work folder (and not your
current directory).
•
Default style is HTMLBlue.
•
ODS Graphics is enabled.
The changes made by the ODS PREFERENCES statement last only for the duration of
your SAS session, or until you change them with an ODS statement or option. The ODS
PREFERENCES statement does not change the settings in the TOOLS ð Options ð
Preferences ð Results dialog box.
ODS RESULTS Statement
Tracks ODS output in the Results window.
Valid in:
Category:
Alias:
Restriction:
Anywhere
ODS: Output Control
ODS RESULTS|NORESULTS;
Valid in a windowing environment only, not in batch mode.
Syntax
ODS RESULTS ON | OFF;
ODS RESULTS= ON | OFF;
Required Arguments
ON
tracks output that ODS generates in the Results window.
OFF
turns off the tracking of output that ODS generates in the Results window.
Details
Using ODS RESULTS ON sends all output to the Results window. This is the default
setting. Using ODS RESULTS OFF disables ODS tracking, and output is not sent to the
Results window. The OFF option is recommended for long-running jobs, such as
regression analyses, when you do not want to track all of the output.
ODS TEXT= Statement
Inserts text into your ODS output.
Valid in:
Category:
Tip:
Anywhere
ODS: Output Control
The ODS TEXT= statement is sent only to output destinations that are open.
Therefore, it must be specified after an ODS destination statement.
Example 1: Adding Text to Multiple Destinations
61
Syntax
ODS TEXT= 'text-string'
Required Argument
text-string
specifies the text to insert into your output. This text is sent to all open supported
output destinations.
Restriction
The ODS TEXT= statement does not support the OUTPUT
destination or the LISTING destination. All other ODS destinations
are supported.
Requirement
You must enclose 'text-string' in quotes.
Tip
The UserText style element controls text specified with the TEXT=
statement.
Examples
Example 1: Adding Text to Multiple Destinations
Features:
ODS HTML statement
ODS PDF statement
ODS RTF statement
ODS TEXT= statement
PROC TEMPLATE:
DEFINE STYLE statement
PARENT= statement
STYLE statement
Other features:
PROC PRINT
Data set:
Exprev
Details
The following example uses a single ODS TEXT= statement to add text to PDF, HTML,
and traditional RTF output. PROC TEMPLATE modifies the UserText style element that
controls the font style, font color, and other attributes of the text that the ODS TEXT=
statement adds.
Program
options obs=10;
proc template;
define style Styles.MyStyle;
parent=styles.htmlblue;
style usertext from usertext /
foreground=red;
end;
62
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
run;
ods html file="text.html" style=Styles.MyStyle ;
ods pdf file="text.pdf" startpage=never notoc style=Styles.MyStyle ;
ods rtf file="text_trad.rtf" style=Styles.MyStyle ;
title "January Orders ";
footnote " For All Employees";
ods text="My Text 1";
ods text="My Text 2";
proc print data=exprev;
run;
ods text="My Text 3";
ods pdf close;
ods rtf close;
ods html close;
title;
footnote;
proc template;
delete Styles.MyStyle ;
run;
Program Description
options obs=10;
Create the Styles.MyStyle style template. The Styles.MyStyle style templates modifies
the Usertext style element to change the font color of text created by the TEXT=
statement to red.
proc template;
define style Styles.MyStyle;
parent=styles.htmlblue;
style usertext from usertext /
foreground=red;
end;
run;
Send output to multiple ODS destinations. The following statements open the HTML,
PDF, and RTF destinations. The STYLE= options specifies that the style Styles.MyStyle
is applied to the output.
ods html file="text.html" style=Styles.MyStyle ;
ods pdf file="text.pdf" startpage=never notoc style=Styles.MyStyle ;
ods rtf file="text_trad.rtf" style=Styles.MyStyle ;
Add a title and footnote. The TITLE and FOOTNOTE statements specify the title and
footnote. You must place the TITLE and FOOTNOTE statements before the ODS
TEXT= statements.
title "January Orders ";
footnote " For All Employees";
Add text strings before the output is printed. The ODS TEXT= statements add the
text strings "My Text 1" and "My Text 2" The text is added to the output before the data
set is printed.
Example 1: Adding Text to Multiple Destinations
63
ods text="My Text 1";
ods text="My Text 2";
Print the data set Exprev. The PRINT procedure prints the Exprev data set.
proc print data=exprev;
run;
Add a third text string after the data set. The third ODS TEXT= statement adds the
text string "My Text 3" after the data set is printed.
ods text="My Text 3";
Close the RTF, HTML, and PRINTER destinations and remove the titles and
footnotes. The ODS RTF CLOSE statement closes the RTF destination. The ODS PDF
CLOSE statement closes the PRINTER destination. The ODS HTML CLOSE statement
closes the HTML destination. The TITLE and FOOTNOTE statements remove any titles
and footnotes previously specified.
ods pdf close;
ods rtf close;
ods html close;
title;
footnote;
After your output is created, you can delete the Styles.MyStyle style template. The
DELETE statement deletes the Styles.MyStyle style template.
proc template;
delete Styles.MyStyle ;
run;
Output
Output 4.1 HTML Output with Text Added
64
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
Output 4.2
PDF Output with Text Added
Output 4.3
Traditional RTF Output with Text Added
Example 2: Adding Text That Imitates a System Title
Features:
ODS PDF statement option
FILE=
NOTOC
STARTPAGE=NO
STYLE=
ODS NOPROCTITLE statement
ODS HTML
ODS TEXT statement
PROC TEMPLATE
Other features:
Example 2: Adding Text That Imitates a System Title
65
OPTIONS statement
PROC MEANS
PROC PRINT
TITLE statement
Details
SAS titles and footnotes are displayed once per page in the PDF destination. Therefore,
when the STARTPAGE= option is set to NO (OFF) and output from more than one
procedure or DATA _NULL_ step is routed to ODS PDF, only the first set of titles and
footnotes are written to the output file. This example shows how to use the TEXT=
option to mimic an interim title, displayed above the second procedure output. PROC
TEMPLATE is used to create a custom style template that mimics the style of the
Systemtitle element. Systemtitle is the style element that controls the appearance of
titles.
This example requires some knowledge of style templates, style elements, and style
attributes. For complete documentation about styles, see “Understanding Styles, Style
Elements, and Style Attributes ” on page 779. For a table of style elements affecting the
table of contents and table of pages, see Table 21.4 on page 833. For a table of style
attributes, see Table 15.3 on page 474.
Program
ods html close;
options nodate;
proc template;
define style styles.mimictitle;
parent=styles.pearl;
class usertext from systemtitle /
just=c;
end;
run;
ods pdf file="file.pdf" notoc startpage=no style=styles.mimictitle;
title "Overriding the Default Procedure Title";
ods noproctitle;
proc means data=sashelp.cars;
class cylinders;
var mpg_city mpg_highway;
run;
ods text="My Custom PROC PRINT Output Title";
proc print data=sashelp.cars noobs;
where mpg_highway gt 45;
run;
ods pdf close;
ods html;
66
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
proc template;
delete Styles.Mimictitle;
run;
Program Description
Close the HTML destination so that no HTML output is produced. The HTML
destination is open by default. The ODS HTML CLOSE statement closes the HTML
destination to conserve resources. If the destination were left open, then ODS would
produce both HTML and PDF output.
ods html close;
Set the SAS system options.
options nodate;
Create a custom style template. The Usertext style element controls the appearance of
user text, which includes text specified by the TEXT= option. The Systemtitle style
element controls the appearance of the default SAS titles, which include the text
specified by the TITLE= statement. This PROC TEMPLATE step creates a new style
named Styles.Mimictitle, which contains all of the style elements and style attributes that
Styles.Pearl contains. However, the CLASS statement modifies the Usertext style
element to produce center-justified text, just as the Systemtitle style element does. This
ensures that text specified by the TEXT= option will look the same as the text specified
by the TITLE= statement.
proc template;
define style styles.mimictitle;
parent=styles.pearl;
class usertext from systemtitle /
just=c;
end;
run;
Open the PDF destination and specify the ODS PDF statement options. The ODS
PDF statement opens the PDF destination and the FILE= option specifies the PDF
filename. The NOTOC option specifies that no table of contents is created. The
STARTPAGE=NO option specifies that no new pages are inserted at the beginning of
each procedure, or within certain procedures, even if new pages are requested by the
procedure code. The STYLE= option specifies the style to use for the output, which is
Styles.Mimictitle in this example.
ods pdf file="file.pdf" notoc startpage=no style=styles.mimictitle;
Specify a title.
title "Overriding the Default Procedure Title";
Create the MEANS procedure output and suppress the procedure title. The ODS
NOPROCTITLE statement suppresses the writing of the procedure title that produces
the results.
ods noproctitle;
proc means data=sashelp.cars;
class cylinders;
Example 2: Adding Text That Imitates a System Title
67
var mpg_city mpg_highway;
run;
Specify the text to use as the second procedure title. The TEXT= option specifies
the text that appears above the PRINT procedure output. Because the custom style
Styles.Mimictitle was specified in the ODS PDF statement, this text will look like a title
specified by the TITLE= statement.
ods text="My Custom PROC PRINT Output Title";
Create the PRINT procedure output.
proc print data=sashelp.cars noobs;
where mpg_highway gt 45;
run;
Close the PDF destination and open the HTML destination. The ODS PDF CLOSE
statement closes the PDF destination and all of the files that are associated with it. You
must close the destinations before you can view the output with a browser or before you
can send the output to a physical printer. The ODS HTML statement opens the HTML
destination and returns SAS to the default ODS destination.
ods pdf close;
ods html;
After your output is produced, you can remove the custom style. The DELETE
statement in PROC TEMPLATE removes the custom style.
proc template;
delete Styles.Mimictitle;
run;
68
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
PDF Output
The following image shows the text “My Custom PROC PRINT Output Title” above the
PROC PRINT table in the same style as the title.
Output 4.4 PDF Output with Custom Procedure Title
ODS TRACE Statement
Writes to the SAS log a record of each output object that is created, or suppresses the writing of this
record.
Valid in:
Category:
Default:
Example:
Anywhere
ODS: Output Control
OFF
“Creating a Data Set with and without the MATCH_ALL Option” in SAS Output
Delivery System: User's Guide
Syntax
ODS TRACE ON </option(s)> ;
ODS TRACE OFF;
Required Arguments
OFF
turns off the writing of the trace record.
ODS TRACE Statement 69
NO
Alias
ON
turns on the writing of the trace record.
Aliases
OUTPUT
YES
Optional Arguments
DOM<="external-file">
specifies that the ODS document object model is written to the SAS log or an
external file.
external-file
is the name of an external output file.
Requirement
See
You must enclose external-file in quotation marks.
For complete documentation about the ODS document object model, see
“Working with the ODS Document Object Model” in SAS Output Delivery
System: Advanced Topics.
EXCLUDED
includes, in the trace record, information for excluded output objects.
Example
“Example 2: Conditionally Selecting Output Objects” on page 30
LABEL
includes the label path for the output object in the record. You can use a label path
anywhere that you can use a path.
Tip
This option is helpful for users who are running a localized version of SAS,
because the labels are translated from English to the local language. The names
and paths of output objects are not translated because they are part of the
syntax of the Output Delivery System.
LISTING
writes the trace record to the LISTING destination, so that each part of the trace
record immediately precedes the output object that it describes.
Details
Contents of the Trace Record
ODS produces an output object by combining data from the data component with a table
template. The trace record provides information about the data component, the table
template, and the output object. By default, the record that the ODS TRACE statement
produces contains these items:
Name
is the name of the output object. You can use the name to reference this output object
and others with the same name. For details about how to reference an output object,
see “How ODS Determines the Destinations for an Output Object” in SAS Output
Delivery System: User's Guide. For example, you could use this name in an ODS
70
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
OUTPUT statement to make a data set from the output object. You could also use
this name in an ODS SELECT or an ODS EXCLUDE statement.
TIP
The name is the rightmost part of the path that appears in the trace record.
Label
briefly describes the contents of the output object. This label also identifies the
output object in the Results window.
Data name
is the name of the data component that was used to create this output object. The data
name appears only if it differs from the name of the output object.
Data label
describes the contents of the data.
Template
is the name of the table template that ODS uses to format the output object. You can
modify this definition with PROC TEMPLATE. See the “EDIT Statement” on page
598 for more information.
Path
is the path of the output object. You can use the path to reference this output object.
For example, you could use the path in the ODS OUTPUT statement to make a data
set from the output. You could also use the path in an ODS SELECT or an ODS
EXCLUDE statement.
The LABEL option modifies the trace record by including the label path for the object in
the record. See the discussion of the option LABEL on page 70.
Specifying an Output Object
After you have determined which output objects your SAS program produces, you can
specify the output objects in statements such as ODS EXCLUDE, ODS SELECT, and so
on. You can specify an output object by using one of the following:
•
a full path. For example, the following is the full path of the output object:
Univariate.City_Pop_90.TestsForLocation
•
a partial path. A partial path consists of any part of the full path that begins
immediately after a period (.) and continues to the end of the full path. For example,
suppose the full path is the following:
Univariate.City_Pop_90.TestsForLocation
Then the partial paths are as follows:
City_Pop_90.TestsForLocation
TestsForLocation
•
a label that is enclosed in quotation marks. For example:
"The UNIVARIATE Procedure"
•
a label path. For example, the following is the label path for the output object:
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Note: The trace record shows the label path only if you specify the LABEL option
in the ODS TRACE statement.
•
a partial label path. A partial label path consists of any part of the label that begins
immediately after a period (.) and continues to the end of the label. For example,
suppose the label path is the following:
Example 1: Determining Which Output Objects a Procedure Creates
71
"The UNIVARIATE Procedure"."CityPop_90"."Tests For Location"
Then the partial label paths are as follows:
"CityPop_90"."Tests For Location"
"Tests For Location"
•
a mixture of labels and paths.
•
any of the partial path specifications, followed by a pound sign (#) and a number. For
example, TestsForLocation#3 refers to the third output object that is named
TestsForLocation.
Example: Determining Which Output Objects a Procedure
Creates
Features:
ODS TRACE statement:
LABEL
OFF
ON
Other features:
PROC UNIVARIATE
Data set:
StatePop
Details
This example shows how to determine the names and labels of the output objects that a
procedure creates. You can use this information to select and exclude output objects.
Program
ods trace on / label;
proc univariate data=statepop mu0=3.5;
var citypop_90 citypop_80;
run;
ods trace off;
Program Description
Specify that SAS write the trace record to the SAS log and include label paths. This
ODS TRACE statement writes the trace record to the SAS log. The LABEL option
includes label paths in the trace record.
ods trace on / label;
Create descriptive statistics for two variables. PROC UNIVARIATE computes
descriptive statistics for two variables, CityPop_80 and CityPop_90. As PROC
UNIVARIATE sends each output object to the Output Delivery System, ODS writes the
pertinent information for that output object to the trace record.
proc univariate data=statepop mu0=3.5;
var citypop_90 citypop_80;
72
Chapter 4
•
Other SAS Statements That Are Used with ODS Procedures
run;
Specify that SAS stop writing the trace record. The ODS TRACE OFF statement
stops the writing of the trace record to the SAS log.
ods trace off;
SAS Log
This partial SAS log shows the trace record that the ODS TRACE statement creates. For
each analysis variable, PROC UNIVARIATE creates five output objects : Moments,
BasicMeasures, TestsForLocation, Quantiles, and ExtremeObs. Notice that
an output object has the same name and label, regardless of which variable is analyzed.
Therefore, you can select all the moments tables that PROC UNIVARIATE produces by
using the name or label in an ODS SELECT statement. The path and label path are
unique for each output object because they include the name of the variable that is
analyzed. You can, therefore, select an individual moments table by using the path or the
label path in an ODS SELECT statement.
Output Added:
------------Name:
Moments
Label:
Moments
Template:
base.univariate.Moments
Path:
Univariate.CityPop_90.Moments
Label Path: "The Univariate Procedure"."CityPop_90"."Moments"
------------Output Added:
------------Name:
BasicMeasures
Label:
Basic Measures of Location and Variability
Template:
base.univariate.Measures
Path:
Univariate.CityPop_90.BasicMeasures
Label Path: "The Univariate Procedure"."CityPop_90"."Basic Measures of Location
and Variability"
------------Output Added:
------------Name:
TestsForLocation
Label:
Tests For Location
Template:
base.univariate.Location
Path:
Univariate.CityPop_90.TestsForLocation
Label Path: "The Univariate Procedure"."CityPop_90"."Tests For Location"
------------Output Added:
------------Name:
Quantiles
Label:
Quantiles
Template:
base.univariate.Quantiles
Path:
Univariate.CityPop_90.Quantiles
Label Path: "The Univariate Procedure"."CityPop_90"."Quantiles"
------------Output Added:
------------Name:
ExtremeObs
Label:
Extreme Observations
Template:
base.univariate.ExtObs
Path:
Univariate.CityPop_90.ExtremeObs
Label Path: "The Univariate Procedure"."CityPop_90"."Extreme Observations"
-------------
ODS PROCLABEL Statement
73
Output Added:
------------Name:
Moments
Label:
Moments
Template:
base.univariate.Moments
Path:
Univariate.CityPop_80.Moments
Label Path: "The Univariate Procedure"."CityPop_80"."Moments"
------------Output Added:
------------Name:
BasicMeasures
Label:
Basic Measures of Location and Variability
Template:
base.univariate.Measures
Path:
Univariate.CityPop_80.BasicMeasures
Label Path: "The Univariate Procedure"."CityPop_80"."Basic Measures of Location
and Variability"
------------Output Added:
------------Name:
TestsForLocation
Label:
Tests For Location
Template:
base.univariate.Location
Path:
Univariate.CityPop_80.TestsForLocation
Label Path: "The Univariate Procedure"."CityPop_80"."Tests For Location"
------------Output Added:
------------Name:
Quantiles
Label:
Quantiles
Template:
base.univariate.Quantiles
Path:
Univariate.CityPop_80.Quantiles
Label Path: "The Univariate Procedure"."CityPop_80"."Quantiles"
------------Output Added:
------------Name:
ExtremeObs
Label:
Extreme Observations
Template:
base.univariate.ExtObs
Path:
Univariate.CityPop_80.ExtremeObs
Label Path: "The Univariate Procedure"."CityPop_80"."Extreme Observations"
-------------
See Also
Statements
•
“ODS EXCLUDE Statement” on page 12
•
“ODS SELECT Statement ” on page 19
ODS PROCLABEL Statement
Enables you to change a procedure label.
Valid in:
Category:
Interaction:
Anywhere
ODS: Output Control
This statement applies to all open destinations, except for the output destination,
where a procedure label is not an option. However, this setting lasts for only one
procedure step. You must issue an ODS PROCLABEL statement for each procedure
step that you have.
74
Chapter 4
•
Examples:
Other SAS Statements That Are Used with ODS Procedures
“Example 2: Adding Text That Imitates a System Title” on page 64
“Customizing the Table of Contents” in SAS Output Delivery System: User's Guide
Syntax
ODS PROCLABEL 'string';
ODS PROCLABEL= 'string';
Required Argument
'string'
is the procedure label that you specify.
Interaction
The NOLABEL system option overrides the ODS PROCLABEL
statement. Therefore, to produce labels using the ODS PROCLABEL
statement, you must specify the LABEL system option also.
Details
ODS PROCLABEL affects the item names in the outer list of the table of contents.
See Also
System Option
•
LABEL System Option
75
Part 3
The DOCUMENT Procedure
Chapter 5
The ODS DOCUMENT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Chapter 6
The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
76
77
Chapter 5
The ODS DOCUMENT Statement
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
ODS DOCUMENT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Dictionary
ODS DOCUMENT Statement
Opens, manages, or closes the DOCUMENT destination, which produces a hierarchy of output objects that
enables you to produce multiple ODS output formats without rerunning a PROC or DATA step.
Valid in:
Category:
Interaction:
Anywhere
ODS: Output Control
The combination of the ODS DOCUMENT statement and the DOCUMENT
procedure enables you to store a report’s individual components and then modify
and replay the report. The ODS DOCUMENT statement stores the actual ODS
objects that are created when running a report. You can then use the DOCUMENT
procedure to rearrange, duplicate, or remove output from the results of a procedure
or a database query without invoking the procedures from the original report. For
complete documentation about the DOCUMENT procedure, see Chapter 6, “The
DOCUMENT Procedure,” on page 81.
Syntax
ODS DOCUMENT action;
ODS DOCUMENT
< NAME=<libref.> member-name <(access–option)> >
< DIR=(< PATH=path<(access-option)> < LABEL="label"> > )>
< CATALOG=permanent-catalog | _NULL_> ;
Actions
The following actions are available for the ODS DOCUMENT statement:
CLOSE
closes the destination and any files that are associated with it.
78
Chapter 5
•
The ODS DOCUMENT Statement
When an ODS destination is closed, ODS does not send output to that
destination. Closing an unneeded destination frees some system resources.
Tip
EXCLUDE exclusion(s)| ALL | NONE
excludes one or more output objects from the DOCUMENT destination.
Default
NONE
Restriction
The DOCUMENT destination must be open for this action to take
effect.
See
“ODS EXCLUDE Statement” on page 12
SELECT selection(s) | ALL | NONE
selects one or more output objects for the DOCUMENT destination.
Default
ALL
Restriction
The DOCUMENT destination must be open for this action to take
effect.
See
“ODS SELECT Statement ” on page 19
SHOW
writes the current selection or exclusion list for the destination to the SAS log.
Restriction
The destination must be open for this action to take effect.
Tip
If the selection or exclusion list is the default list (SELECT ALL), then
SHOW also writes the entire selection or exclusion list.
See
“ODS SHOW Statement” in SAS Output Delivery System: User's
Guide
Optional Arguments
CATALOG=permanent-catalog | _NULL_
CAUTION:
If you do not specify a value (other than _NULL_) for this option, then you
can replay temporary GRSEGs only during the session in which they are
created, not in subsequent sessions.
permanent-catalog
copies any temporary GRSEG to the specified permanent catalog and keeps a
reference to the permanent GRSEG in the document. This value persists until the
ODS DOCUMENT statement is closed, or until you delete it by specifying
CATALOG=_NULL_.
The permanent catalog has the following form:
<libref.> < member-name> ;
_NULL_
deletes the catalog name that was previously specified for the CATALOG=
option. Thereafter, temporary GRSEGs are not copied into the permanent catalog
and thus are unavailable in subsequent sessions.
Alias
CAT=
ODS DOCUMENT Statement 79
Default
By default, no value is assigned to CATALOG=, which means that
temporary GRSEGs are not copied to a permanent catalog.
DIR=(<PATH=path<(access-option)>><LABEL='label'>);
specifies the directory path and/or label for ODS output.
LABEL=label
assigns a label to a path.
Requirement
The label that you assign must be enclosed in quotation marks.
Interaction
If LABEL= is used with the PATH= option, then the label applies
to the path. If LABEL= is used without the PATH= option, then
the label applies to the entire document.
PATH=path <(access-option)>
is specified as a sequence of entries that are delimited by backslashes.
path
can have the following form:
path<#sequence–number>
path
is the name of the path.
#sequence–number
is a number which, when combined with a pathname, uniquely identifies
the entry in the directory that contains it.
Default
The default path is "\" (root).
Tip
You can specify a directory that contains entries that do not exist in
the document.
access-option
specifies the access mode for the ODS document.
WRITE
opens a document and provides Write access as well as Read access.
Interaction
If a label is specified with the LABEL= option, then
overrides any existing label assigned to the document.
Tip
If the ODS document does not exist, then it is created.
CAUTION
If the ODS document already exists, then it is
overwritten.
UPDATE
opens an ODS document and appends new content to the document.
UPDATE provides Update access as well as Read access.
Interaction
If a label is specified with the LABEL= option, then it is
assigned to the document.
Tip
If the ODS document does not exist, then the document is
created.
80
Chapter 5
•
The ODS DOCUMENT Statement
CAUTION
Default
Note
If the document already exists, then its contents are not
changed.
UPDATE
Procedure output or data queries are added at the end of the directory.
NAME= <libref.> member-name<(access-option)>
libref
specifies the SAS library where the document is stored.
Default
If no library name is specified, the Work library is used.
member-name
specifies the document name.
Defaults
If no NAME= is specified, the specified options apply to the currently
open document.
If you do not specify an access-option with NAME=, then your
directories will open in UPDATE mode.
access-option
specifies the access mode for the ODS document.
WRITE
opens a document and provides Write access as well as Read access.
Interaction
If a label is specified with the LABEL= option, then it overrides
any existing label assigned to the document.
Tip
If the ODS document does not exist, then it is created.
CAUTION
If the ODS document already exists, then it is overwritten.
UPDATE
opens an ODS document and appends new content to the document.
UPDATE provides Update access as well as Read access.
Interaction
If a label has been specified with the LABEL= option, then it is
assigned to the document.
Tip
If the ODS document does not exist, then the document is
created.
CAUTION
If the document already exists, then its contents is not
changed.
Default
Interaction
UPDATE
When a DOCUMENT destination is open, using the NAME= option in
an ODS DOCUMENT statement forces ODS to close the destination
and all files associated with it, and to open a new instance of the
destination.
81
Chapter 6
The DOCUMENT Procedure
Overview: DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Using the DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
DOCUMENT Procedure Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
About ODS Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Items Included in an ODS Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Items Not Included in an ODS Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
ODS Document Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Understanding an ODS Document Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Definition of ODS Document Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Entry Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Understanding Sequence Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
ODS Documents and Base SAS Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Getting Familiar with Output Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Compatibility across SAS Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Syntax: The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
PROC DOCUMENT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
COPY TO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
DELETE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
DIR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
DOC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
DOC CLOSE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
HIDE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
IMPORT TO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
LINK Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
LIST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
MAKE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
MOVE TO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
NOTE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
OBANOTE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
OBBNOTE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
OBFOOTN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
OBPAGE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
OBSTITLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
OBTEMPL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
OBTITLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
RENAME TO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
REPLAY Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
82
Chapter 6
•
The DOCUMENT Procedure
SETLABEL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
UNHIDE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Advanced ODS DOCUMENT Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Viewing the Contents of an ODS Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Replaying Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Customizing Labels, Titles, and Footnotes with BY Variables . . . . . . . . . . . . . . . . 141
Results: DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
ODS Documents in the Documents Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
ODS Documents in the Results Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Comparisons between the Documents Window and the Results Window . . . . . . . 145
Viewing the Properties of an Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Creating Shortcuts in the Documents Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Comparisons between the Documents Window and the DOCUMENT Procedure 147
Examples: The DOCUMENT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 1: Replaying a Document Using the Document Window . . . . . . . . . . . .
Example 2: Navigating the Directory and Listing the Entries . . . . . . . . . . . . . . . .
Example 3: Managing Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 4: Listing BY-Group Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 5: Importing LISTING Output and a SAS Program . . . . . . . . . . . . . . . .
149
149
152
156
162
168
Overview: DOCUMENT Procedure
Using the DOCUMENT Procedure
The combination of the ODS DOCUMENT statement and the DOCUMENT procedure
enables you to store a report’s individual components and then modify and replay the
report. The ODS DOCUMENT statement stores the actual ODS objects (or references to
those objects) that are created when running a report. You can then use the DOCUMENT
procedure to rearrange, duplicate, or remove output from the results of a procedure or a
database query without invoking the procedures from the original report. You can also
use the DOCUMENT procedure to do the following:
•
transform a report without rerunning an analysis or repeating a database query
•
modify the structure of output
•
display output to any ODS output format
•
navigate the current directory and list entries
•
open and list ODS documents
•
manage output
With the DOCUMENT procedure, you are not limited to simply regenerating the same
report. You can change the order in which objects are rendered, the table of contents, the
templates that are used, macro variables, and ODS system options.
Unlike other ODS destinations, the DOCUMENT destination has a graphical user
interface (GUI), called the Documents window, for performing tasks. However, you can
perform the same tasks with batch statement syntax using the DOCUMENT procedure.
For a comparison of the Documents window and the DOCUMENT procedure, see
“Comparisons between the Documents Window and the Results Window” on page 145.
About ODS Documents
83
For an example of using the Documents window to rearrange output, see “Restructuring
Output” in SAS Output Delivery System: Advanced Topics. For an example of replaying
output with the Documents window, see “Example 1: Replaying a Document Using the
Document Window” on page 149.
DOCUMENT Procedure Terminology
current document
is the open document.
current directory
is your current location in the open document. The '^' symbol represents the current
directory.
entry
is a directory, output object, note, or link.
graph segment
is an output object that contains a graph. Graphs are created in some SAS
procedures, including those in SAS/GRAPH. The graph output object is referenced
as a GRSEG. For more information about GRSEG and SAS/GRAPH procedures, see
SAS/GRAPH: Reference
ODS document
is the hierarchy of output objects that are created by the DOCUMENT procedure.
These objects are unformatted and are placed in a SAS item store.
path
is the route through an ODS document, leading to a particular entry. The ‘^’ symbol
represents the current directory and the ‘^^’ symbol represents the parent directory.
replay
is the regeneration of output, in the same or different format, without rerunning
analyses or data queries.
root directory
is the top level of an ODS document. The root is not contained within another
directory and it does not have a name assigned. The root is similar to the root
directory of a Windows file system.
About ODS Documents
Overview
An ODS document is a hierarchical file of output objects that is created from a
procedure or data query. The ODS document holds these output objects in their original
structures, but you can rearrange the hierarchy and structure of these objects. ODS
documents are stored in a proprietary format (a document store) and can be viewed only
with SAS software. To view or modify what is in the document store, you must use
either the Documents window or the DOCUMENT procedure.
To create an ODS document, you must use the Documents window or “ODS
DOCUMENT Statement”. The following code creates the ODS document Work.Prddoc
within a document store:
84
Chapter 6
•
The DOCUMENT Procedure
proc sort data=sashelp.prdsale out=prdsale;
by Country;
run;
ods document name=work.prddoc(write);
proc tabulate data=prdsale;
by Country;
var predict;
class prodtype;
table prodtype all,
predict*(min mean max);
run;
ods select ExtremeObs;
proc univariate data=prdsale;
by Country;
var actual;
run;
ods document close;
About ODS Documents
The following display shows the document Work.Prddoc and its contents. To view the
Documents window, submit this command in the command bar: odsdocuments
Figure 6.1 SAS Documents Window Showing Document and Documents Icon
The following display shows the properties of the first Table 1, which is the summary
report for Canada. To view the properties of an entry, right-click on the highlighted
85
86
Chapter 6
•
The DOCUMENT Procedure
object and select Properties from the pop-up list. In the Table Properties window, you
can see the document name and the document path, among other information.
Figure 6.2
Table Properties for Table 1
An ODS document store is not a SAS data set, as you can see by the document icon in
the preceding display. This ODS document was written to the Work library. However, if
it had been written to a permanent location (such as c:\temp\output), you would see in
Windows Explorer that the document store has a file extension of SAS7BITM.
Items Included in an ODS Document
In an ODS document, each level of the hierarchical file represents a path that refers to
the location of a file, link, or output object. An output object can be one of the following:
•
table
•
graph
•
equation
•
note
•
SAS/GRAPH external graph titles
Items Not Included in an ODS Document
An ODS document does not store the following items:
•
GRSEGs (References to GRSEGs, but not GRSEGs themselves, are stored.)
•
ODS options
•
procedure options
•
Report Writing Interface output
Understanding Sequence Numbers
•
SAS logs
•
SAS/GRAPH options
•
SAS system options
87
ODS Document Persistence
An ODS document persists in the SAS system until the document, or the SAS library
containing the document, is deleted. An ODS document that was created in the Sasuser
library, or in another permanent SAS library, can persist indefinitely. It is considered a
permanent archive of SAS procedure output. However, an ODS document that is created
in the Work library does not persist longer than the SAS session that created it. For
information about SAS libraries, see SAS Language Reference: Concepts.
Understanding an ODS Document Path
Definition of ODS Document Path
An ODS document is stored as an item store. This file format enables client applications
to define a hierarchical file system within a file. This is similar to a directory system in a
UNIX or Windows operating environment. Therefore, an ODS document path indicates
the location of an entry. In the preceding output, the document path for the entry
Country=Canada is \Tabulate#1\ByGroup1#1.
Entry Names
Entry names follow these rules:
•
must be alphanumeric
•
must begin with an alphabetical character
•
can contain underscores
•
can have no more than 32 characters
•
are preserved with casing that is specified in the operating environment
•
can have labels that are no more than 256 characters
Entries in an ODS document can be displayed in the following three ways:
•
ordered by insertion, which is the default order
•
ordered by ascending date-and-time stamp
•
ordered alphabetically
Understanding Sequence Numbers
Entry names are not required to be unique within an ODS document. However, they are
uniquely identifiable because they contain sequence numbers. Every entry in an ODS
88
Chapter 6
•
The DOCUMENT Procedure
document, except for the root directory, has a sequence number. A sequence number is a
positive integer that is unique with respect to the name of the entry within the same
directory. Entries are assigned sequence numbers according to the sequence in which
they are added to a directory. For example, the first entry myname is assigned a sequence
number 1, myname#1. The second entry myname is assigned a sequence number 2,
myname#2. Sequence numbers are never reassigned, unless all entries with the same
name are deleted. In this case, the sequence numbers are reset to have an initial number
of 1.
ODS Documents and Base SAS Procedures
You can create an ODS document from almost any Base SAS procedure. The PRINT,
REPORT, and TABULATE procedures use table templates that are created by the user
and not defined by an external template in ODS. These procedures use custom table
templates, custom data components, and custom formats for their output objects.
Nevertheless, the ODS document and all of its features are supported for the PRINT,
TABULATE, and REPORT procedures.
Getting Familiar with Output Objects
An output object is one of the following:
•
equation
•
graph
•
note
•
table
Output objects have associated information and attributes. Some or all of the following
attributes pertain to output objects:
after-note
is the note assigned to the output object by the procedure that produced the object.
This note is displayed every time the output object is displayed. After-notes are
displayed after the output object.
before-note
is the note assigned to the output object by the procedure that produced the object.
This note is displayed every time the output object is displayed. Before-notes are
displayed before the output object.
footnote
is created by the FOOTNOTE statement and is displayed at the bottom of the page.
page break
causes a page break before displaying the output object and any associated titles and
notes.
subtitle
is the title that is assigned to the output object by the procedure that produced the
output object. This title is displayed every time a new page of output is started.
title
is created by the TITLE statement and is displayed at the top of the page.
Compatibility across SAS Versions
89
Here is the order in which the attributes of an output object are displayed:
1. page break
2. titles
3. subtitles
4. before-notes
5. output object
6. after-notes
7. footnotes
Compatibility across SAS Versions
An ODS document that is created in the current version of SAS is compatible with later
versions of SAS. In most cases, an ODS document created in a later version of SAS will
still be compatible with an earlier version of SAS.
ODS documents are not portable across operating environments. For example, an ODS
document created in a Windows operating environment cannot be used in a mainframe
operating environment.
90
Chapter 6
•
The DOCUMENT Procedure
Syntax: The DOCUMENT Procedure
PROC DOCUMENT <options>;
COPY path <(where-expression)> <, path-2 <(where-expression-2)>, …> TO path </ option(s)>;
DELETE path <(where-expression)> <, path-2 <(where-expression-2)>, …>
< / LEVELS= ALL | value>;
DIR <path>;
DOC <options>;
DOC CLOSE;
HIDE path <, path-2, …>;
IMPORT DATA= data-set-name | GRSEG=grseg TO path </ options>;
LINK path TO path </ options >;
LIST path <(where-expression)> <, path-2 <(where-expression-2)>, …> </ option(s)>;
MAKE path <, path-2, …> </ options>;
MOVE path <(where-expression)> <, path-2 <(where-expression-2)>, …> TO path </ option(s) >;
NOTE path <'text'> </ option(s)>;
OBANOTE<n> output-object <'text'> </ option>;
OBBNOTE<n> output-object <'text'> </ option>;
OBFOOTN<n> output-object <'text'>;
OBPAGE output-object </ option(s)>;
OBSTITLE<n> output-object <'text'> </ options>;
OBTEMPL output-object;
OBTITLE<n> output-object <'text'>;
RENAME path-1 TO path-2;
REPLAY path <(where-expression)> <, path-2 <(where-expression-2)>, …> </ options>;
SETLABEL path 'label';
UNHIDE path <, path-2, …>;
QUIT;
Statement
Task
Example
PROC
DOCUMENT
Render ODS output without rerunning procedures and
gain more control over the structure and hierarchy of the
output
Ex. , Ex. 3, Ex.
4
COPY TO
Insert a copy of an entry into a specified path
DELETE
Delete entries from a specified path or paths
DIR
Set or display the current directory
Ex. 2, Ex. , Ex.
3
DOC
Open a document and its contents to browse or edit
Ex. 2
DOC CLOSE
Close the current document
PROC DOCUMENT Statement 91
Statement
Task
Example
HIDE
Prevent output from being displayed when the document
is replayed
IMPORT TO
Import a data set or graph segment into the current
directory
LINK
Create a symbolic link from one output object to another
output object
LIST
List the content of one or more entries
MAKE
Create one or more new directories
MOVE TO
Move entries from one directory to another directory
NOTE
Create text strings in the current directory
Ex. 3
OBANOTE
Create or modify lines of text after the specified output
object
Ex. 3
OBBNOTE
Create or modify lines of text before the specified output
object
Ex. 3
OBFOOTN
Create or modify lines of text at the bottom of the page in
which the output object is displayed
Ex. 3
OBPAGE
Create or delete a page break for an output object
Ex. 3
OBSTITLE
Create or modify subtitles
Ex. 3
OBTEMPL
Write the source code of the ODS template that is
associated with a specified output object
Ex. 4
OBTITLE
Create or modify lines of text at the top of the page where
the output object is displayed
Ex. 3
RENAME TO
Assign a different name to a directory or output object
REPLAY
Replay one or more entries to the specified open ODS
destinations
SETLABEL
Assign a label to the current entry
UNHIDE
Enable the output of a hidden entry to be displayed when
it is replayed
Ex. 5
Ex. 2, Ex. , Ex.
3, Ex. 4
Ex. , Ex. 3
PROC DOCUMENT Statement
Creates or opens a document to modify.
Default:
Restriction:
Documents are opened in the UPDATE access mode.
User-defined format names must be unique within an ODS DOCUMENT.
92
Chapter 6
•
Note:
The DOCUMENT Procedure
If the DOCUMENT destination is not closed with an ODS DOCUMENT CLOSE
statement, then ODS continues to append files to the document.
Syntax
PROC DOCUMENT <options <access-option(s)>>;
Optional Arguments
NAME= <libref.>member-name <access-option(s)>
specifies the name of a new or existing document and its access mode.
<libref.>member-name
identifies a new or existing ODS document.
Default
If no library is specified, then the Work library is used.
Restriction
The ODS document must be a SAS library member.
access-option(s)
specifies the access mode for the ODS document. For example, the following
PROC DOCUMENT statement opens the document Work.MyDoc in Update
mode:
proc document name=mydoc;
run;
Default
UPDATE
READ
is an access-option that opens a document and provides Read-Only access.
Requirement
To open a document in the READ access mode, the document
must already exist.
Interaction
If a label has been specified with the LABEL= option, then the
label is ignored.
WRITE
is an access-option that opens a document and provides Read and Write access.
For example, the following PROC DOCUMENT statement opens the document
Work.YourDoc in Write mode:
proc document name=yourdoc(write);
run;
Interaction
If a label has been specified with the LABEL= option, then it
overrides any existing label assigned to the document.
Tip
If the ODS document does not exist, then it is created.
CAUTION
If the ODS document already exists, then it is overwritten.
UPDATE
is an access-option that opens an ODS document and appends new content to the
document. UPDATE provides Update access as well as Read access.
COPY TO Statement 93
Interaction
If a label has been specified with the LABEL= option, then it is
assigned to the document.
Tip
If the ODS document does not exist, then the document is created.
CAUTION
If the document already exists, then its contents is not changed.
LABEL= 'label'
assigns a label to a document. For example, the following PROC DOCUMENT
statement opens the document Work.YourDoc in Write mode and assigns a label to
it:
proc document name=yourdoc(write) label='repeated measures results';
run;
Restriction
Labels can be assigned only to documents with Write-access
permissions.
Requirement
Enclose labels in quotation marks.
COPY TO Statement
Copies an entry into the specified path.
Default:
Example:
If you do not specify a location to insert the entry into the path, then the entry is
inserted at the end of the path.
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
Syntax
COPY path <(where-expression)> <, path-2 <(where-expression-2)>, …> TO path </ option(s)>;
Required Argument
path
is the location where a link, output object, or file is copied.
Requirement
Separate multiple paths with commas.
Tip
The '^' symbol represents the current directory and the '^^' symbol
represents the parent directory.
Optional Arguments
AFTER= path
inserts a copy of an entry after the specified path.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
BEFORE= path
inserts a copy of an entry before the specified path.
94
Chapter 6
•
The DOCUMENT Procedure
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
FIRST
inserts a copy of an entry at the beginning of the specified directory. For example,
the following COPY TO statement inserts a copy of the entry Monday_Report at the
beginning of the root directory:
copy weekly\monday_report to \ / first;
run;
LAST
inserts a copy of an entry at the end of the specified directory.
LEVELS= ALL | value
specifies the number of levels that you want to copy.
ALL
specifies all levels.
value
specifies the numeric value of the path level. For example, the following COPY
TO statement copies two levels of the entry Weekly to the entry Monthly:
copy weekly to \work.mydoc\monthly / levels = 2;
run;
Default
ALL
Restriction
The LEVELS= option is valid only when you specify a directory.
(WHERE=(where-expression-1<operator >))
conditionally selects a subset of entries in an ODS document.
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
operand
is one of the following:
constant
is a fixed value such as a date literal, a value, or a BY variable value.
SAS function
For information about SAS functions, see SAS Functions and CALL
Routines: Reference.
subsetting variable
is a special type of WHERE expression operand used by the
DOCUMENT procedure to help you find common values in ODS
documents. Here are the subsetting variables:
_CDATE_
is the creation date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of 16JUL2004 to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\ work.mydoc\monthly;
run;
COPY TO Statement 95
_CDATETIME_
is the creation datetime of the current entry.
Example
The following COPY TO statement copies all entries with a
creation datetime of May 1, 2003, at 9:30 to the Monthly
directory of Work.MyDoc:
copy ^(where=(_cdatetime_ = '01may04:9:30:00'dt))
to \work.mydoc\monthly;
run;
_CTIME_
is the creation time of the current entry.
Example
The following DELETE statement deletes all entries with a
creation time of 9:25:19 PM:
delete ^(where=(_ctime_ = '9:25:19pm't));
run;
_LABEL_
is the label of the current entry.
Example
The following LIST statement lists all tables containing the label 'Type
III Model' within the GLM procedure:
list glm(where=(_type_ = 'table' _label_ ? 'Type III Model'));
run;
_LABELPATH_
is the path to the label of the current entry. Document label paths are
formed by concatenating the labels and sequence numbers, and then
separating them with the forward slash (/) symbol. Document label
paths are similar to the label paths specified by the ODS TRACE
statement.
For example, suppose that this is the ODS TRACE label path:
'The Univariate Procedure'.'Normal_x'.'Histogram 1'
The corresponding document label path would be as follows:
'The Univariate Procedure'#1\'Normal_x'#1\'Histogram 1'#1
Note that in document label paths, the instances of '.' are replaced with
'\'.
See
“ODS TRACE Statement” on page 68
Example
The following LIST statement lists all items containing “Fit Statistics”
in the label path.
list gml(where=(_labelpath_ ? "Fit Statistics"))/ levels=all;
run;
_MAX_
is the last observation.
Restrictions
_MAX_ is used only for output objects.
_MAX_ is used only in the REPLAY statement.
Example
The following REPLAY statement replays all observations
except the last observation:
96
Chapter 6
• The DOCUMENT Procedure
replay class(where=(_obs_ < _max_));
_MDATE_
is the modification date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a modification date of 16JUL2004 to the Monthly directory
of Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _mdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
_MDATETIME_
is the modification datetime of the current entry.
Example
The following REPLAY statement replays all entries with a
modification datetime of May 1, 2003, at 9:30:
replay ^(where=(_mdatetime_ = '01may04:9:30:00'dt));
run;
_MIN_
is the first observation.
Restrictions
_MIN_ is used only for output objects.
_MIN_ is always set to 1
_MIN_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the first observation:
Example
replay class(where=(_obs_ <
_min_));
_MTIME_
is the modification time of the current entry.
Example
The following COPY TO statement copies all entries with a
modification time of 9:25:19 PM to the Monthly directory of
Work.MyDoc:
copy ^(where=(_mtime_ = '9:25:19pm't)) to \work.mydoc\monthly;
run;
_NAME_
is the name of the current entry.
Example
The following DELETE statement deletes all entries that
contain the name “stemleng” within the GLM procedure:
delete glm(where=(_name_ ? 'stemleng'));
_OBS_
is the current observation number in an output object.
Restrictions
_OBS_ is used only for output objects.
_OBS_ is used only in the REPLAY statement.
Examples
The following REPLAY statement replays all but the first
ten observations:
COPY TO Statement 97
replay class(where=(_obs_ > 10));
The following REPLAY statement replays all observations
except the last observation:
replay class(where=(_obs_ < _max_));
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observations:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-number
is the observation number to be replayed.
Restrictions
observation-number is used only for output objects.
observation-number is used only in the REPLAY
statement.
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observation:
Example
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-variable
is the name of an observation.
Restrictions
observation-variable is used only for output objects.
observation-variable is used only in the REPLAY
statement.
Examples
The following REPLAY statement replays all observations
where the variable Weight is greater than 100:
replay class(where=(weight>100));
The following REPLAY statement replays all observations
where the variable Sex is equal to ‘F’.
replay class(where=(sex='F'));
_PATH_
is the path of the current entry.
Example
The following LIST statement lists all entries with a path
containing the substring 'Anova' at all levels of the current
directory:
list ^(where=(_path_ ? 'Anova'));
run;
_SEQNO_
is the sequence number of the current entry.
See
“Understanding Sequence Numbers ” on page 87
Example
The following REPLAY statement replays all entries that have
a sequence number of 2 in the GLM procedure:
replay glm(where=(_seqno_ = 2));
_TYPE_
is the type of the current entry.
98
Chapter 6
• The DOCUMENT Procedure
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of July 16, 2004, to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
variable- name
is the name of a BY variable.
Example
The following MOVE TO statement moves all entries where
the value of the variable Gender is 'F' to the Monthly directory
of Work.MyDoc:
move ^(where=(gender='F')) to \work.mydoc\monthly;
run;
operator
compares one variable with a value or another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
Table 6.1
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
For the REPLAY statement, the WHERE= option applies to
directories and output objects. For the following statements, the
WHERE= option applies to directories only:
• COPY TO
• DELETE
• LIST
• MOVE TO
Requirement
Enclose where-expression in quotation marks.
See
For advanced information about using where-expressions, see “Using
WHERE Expressions in PROC DOCUMENT” in SAS Output
Delivery System: Advanced Topics.
DELETE Statement 99
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Opening and Listing ODS Documents Using WHERE Expressions”
in SAS Output Delivery System: Advanced Topics
DELETE Statement
Deletes entries from the current directory.
Restriction:
Note:
The root directory cannot be deleted or moved.
The DELETE statement affects all levels of a directory below the specified path.
Syntax
DELETE path <(where-expression)> <, path-2 <(where-expression-2)>, …>
</ LEVELS=ALL | value>;
Required Argument
path
specifies the location of one or more links, output objects, or directories. For
example, the following DELETE statement removes the ClassLevels and Nobs
entries from the current directory:
delete classlevels, nobs;
run;
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
Optional Arguments
LEVELS= ALL | value
specifies the number of levels that you want to delete.
ALL
specifies all levels.
value
specifies the numeric value of the path level.
Default
ALL
Restriction
The LEVELS= option is valid only when you specify a directory.
(WHERE=(where-expression-1<operator >))
conditionally selects a subset of entries in an ODS document.
100
Chapter 6
•
The DOCUMENT Procedure
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
operand
is one of the following:
constant
is a fixed value such as a date literal, a value, or a BY variable value.
SAS function
For information about SAS functions, see SAS Functions and CALL
Routines: Reference.
subsetting variable
is a special type of WHERE expression operand used by the
DOCUMENT procedure to help you find common values in ODS
documents. Here are the subsetting variables:
_CDATE_
is the creation date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of 16JUL2004 to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\ work.mydoc\monthly;
run;
_CDATETIME_
is the creation datetime of the current entry.
Example
The following COPY TO statement copies all entries with a
creation datetime of May 1, 2003, at 9:30 to the Monthly
directory of Work.MyDoc:
copy ^(where=(_cdatetime_ = '01may04:9:30:00'dt))
to \work.mydoc\monthly;
run;
_CTIME_
is the creation time of the current entry.
Example
The following DELETE statement deletes all entries with a
creation time of 9:25:19 PM:
delete ^(where=(_ctime_ = '9:25:19pm't));
run;
_LABEL_
is the label of the current entry.
Example
The following LIST statement lists all tables containing the label 'Type
III Model' within the GLM procedure:
list glm(where=(_type_ = 'table' _label_ ? 'Type III Model'));
run;
_LABELPATH_
is the path to the label of the current entry. Document label paths are
formed by concatenating the labels and sequence numbers, and then
separating them with the forward slash (/) symbol. Document label
DELETE Statement 101
paths are similar to the label paths specified by the ODS TRACE
statement.
For example, suppose that this is the ODS TRACE label path:
'The Univariate Procedure'.'Normal_x'.'Histogram 1'
The corresponding document label path would be as follows:
'The Univariate Procedure'#1\'Normal_x'#1\'Histogram 1'#1
Note that in document label paths, the instances of '.' are replaced with
'\'.
See
“ODS TRACE Statement” on page 68
Example
The following LIST statement lists all items containing “Fit Statistics”
in the label path.
list gml(where=(_labelpath_ ? "Fit Statistics"))/ levels=all;
run;
_MAX_
is the last observation.
Restrictions
_MAX_ is used only for output objects.
_MAX_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the last observation:
Example
replay class(where=(_obs_ < _max_));
_MDATE_
is the modification date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a modification date of 16JUL2004 to the Monthly directory
of Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _mdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
_MDATETIME_
is the modification datetime of the current entry.
Example
The following REPLAY statement replays all entries with a
modification datetime of May 1, 2003, at 9:30:
replay ^(where=(_mdatetime_ = '01may04:9:30:00'dt));
run;
_MIN_
is the first observation.
Restrictions
_MIN_ is used only for output objects.
_MIN_ is always set to 1
_MIN_ is used only in the REPLAY statement.
102
Chapter 6
•
The DOCUMENT Procedure
The following REPLAY statement replays all observations
except the first observation:
Example
replay class(where=(_obs_ <
_min_));
_MTIME_
is the modification time of the current entry.
Example
The following COPY TO statement copies all entries with a
modification time of 9:25:19 PM to the Monthly directory of
Work.MyDoc:
copy ^(where=(_mtime_ = '9:25:19pm't)) to \work.mydoc\monthly;
run;
_NAME_
is the name of the current entry.
Example
The following DELETE statement deletes all entries that
contain the name “stemleng” within the GLM procedure:
delete glm(where=(_name_ ? 'stemleng'));
_OBS_
is the current observation number in an output object.
Restrictions
_OBS_ is used only for output objects.
_OBS_ is used only in the REPLAY statement.
Examples
The following REPLAY statement replays all but the first
ten observations:
replay class(where=(_obs_ > 10));
The following REPLAY statement replays all observations
except the last observation:
replay class(where=(_obs_ < _max_));
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observations:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-number
is the observation number to be replayed.
Restrictions
observation-number is used only for output objects.
observation-number is used only in the REPLAY
statement.
Example
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observation:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-variable
is the name of an observation.
Restrictions
observation-variable is used only for output objects.
DELETE Statement 103
observation-variable is used only in the REPLAY
statement.
Examples
The following REPLAY statement replays all observations
where the variable Weight is greater than 100:
replay class(where=(weight>100));
The following REPLAY statement replays all observations
where the variable Sex is equal to ‘F’.
replay class(where=(sex='F'));
_PATH_
is the path of the current entry.
Example
The following LIST statement lists all entries with a path
containing the substring 'Anova' at all levels of the current
directory:
list ^(where=(_path_ ? 'Anova'));
run;
_SEQNO_
is the sequence number of the current entry.
See
“Understanding Sequence Numbers ” on page 87
Example
The following REPLAY statement replays all entries that have
a sequence number of 2 in the GLM procedure:
replay glm(where=(_seqno_ = 2));
_TYPE_
is the type of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of July 16, 2004, to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
variable- name
is the name of a BY variable.
Example
The following MOVE TO statement moves all entries where
the value of the variable Gender is 'F' to the Monthly directory
of Work.MyDoc:
move ^(where=(gender='F')) to \work.mydoc\monthly;
run;
operator
compares one variable with a value or another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
Table 6.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
104
Chapter 6
•
The DOCUMENT Procedure
Symbol
Mnemonic Equivalent
Definition
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
For the REPLAY statement, the WHERE= option applies to
directories and output objects. For the following statements, the
WHERE= option applies to directories only:
• COPY TO
• DELETE
• LIST
• MOVE TO
Requirement
Enclose where-expression in quotation marks.
See
For advanced information about using where-expressions, see “Using
WHERE Expressions in PROC DOCUMENT” in SAS Output
Delivery System: Advanced Topics.
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Opening and Listing ODS Documents Using WHERE Expressions”
in SAS Output Delivery System: Advanced Topics
DIR Statement
Sets or displays the current directory.
Examples:
“Example 2: Navigating the Directory and Listing the Entries” on page 152
“Opening and Listing ODS Documents Using WHERE Expressions” in SAS Output
Delivery System: Advanced Topics
“Example 3: Managing Entries” on page 156
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
DOC Statement 105
Syntax
DIR <path>;
Without Arguments
If no options are specified, then the DIR statement displays the current path.
Optional Argument
path
sets the current directory. For example, the following DIR statement sets the current
directory to '\report\glm' within the current document:
dir \report\glm;
run;
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
DOC Statement
Opens a document and its contents to browse or edit.
Default:
Examples:
Documents are opened in the UPDATE access mode.
“Example 2: Navigating the Directory and Listing the Entries” on page 152
“Opening and Listing ODS Documents Using WHERE Expressions” in SAS Output
Delivery System: Advanced Topics
Syntax
DOC <options < access-option(s)>>;
Without Arguments
If no options are specified, then the DOC statement lists the ODS documents in all SAS
libraries in alphabetical order. Document labels, if any, are displayed.
Optional Arguments
LABEL= 'label'
assigns a label to a document. For example, the following DOC statement opens the
document Work.YourDoc in Write mode and assigns a label to it:
doc name=yourdoc(write) label='repeated measures results';
run;
Restriction
A label can be assigned only to documents with Write access
permission.
Requirements
To use the LABEL= option, specify the NAME= option in the DOC
statement.
Enclose labels in quotation marks.
106
Chapter 6
•
The DOCUMENT Procedure
LIBRARY=library-name
specifies that only the documents in the specified library-name are listed.
Alias
LIB=
Interaction
The LIBRARY= option cannot be specified with the NAME= or
LABEL= options.
NAME= libref.member-name <access-option(s)>
specifies the name that you assign to a document and its access mode.
<libref.>member-name
identifies a document.
Default
If no library is specified, then the Work library is used.
Restriction
The document must be a SAS library member.
access-option(s)
specifies the access mode for the document.
READ
opens a document and provides Read-Only access.
Interaction
If a label has been specified with the LABEL= option, then the
label is ignored.
WRITE
opens a document and provides Write access, but only if you have Write
permission.
CAUTION:
If the document already exists, then it is overwritten. If the document
does not exist, then it is created.
Interaction
If a label has been specified with the LABEL= option, then it
overrides any existing label assigned to the document.
UPDATE
opens a document and provides Update access, but only if you have Update
permission.
Interaction
If a label has been specified with the LABEL= option, then it is
assigned to the document.
Tip
If the document already exists, then its contents is not changed
and the new contents is appended to the document. If the
document does not exist, then it is created.
DOC CLOSE Statement
Closes the current document.
Syntax
DOC CLOSE;
IMPORT TO Statement 107
HIDE Statement
Prevents output from being displayed when the document is replayed.
Tip:
To see entries that might be hidden in the current document, use the LIST statement.
Syntax
HIDE path <, path-2, …>;
Required Argument
path
specifies the location of the file or files that you want to hide.
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
IMPORT TO Statement
Imports the specified SAS data set or graph segment to the specified path.
Example:
“Example 5: Importing LISTING Output and a SAS Program ” on page 168
Syntax
IMPORT DATA= data-set-name <data-set-option(s)> | GRSEG=grseg TO path </ option(s)>;
Required Arguments
DATA= data-set-name
specifies an existing SAS data set that you want to import.
GRSEG= grseg
stores a reference to a graph segment.
grseg
specifies the 3-level catalog pathname. For example,
GRSEG=Sasuser.grseg.mygraph.
See
GRSEG= option in SAS/GRAPH: Reference
path
specifies the location where you want to import the data set or graph segment.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
108
Chapter 6
•
The DOCUMENT Procedure
Optional Arguments
AFTER= path
imports the data set or graph segment into the directory after the specified path.
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
Tip
BEFORE= path
imports the data set or graph segment into the directory before the specified path. For
example, the following IMPORT TO statement imports the data set Sashelp.Class to
the current directory, and inserts the data set before the entry MyInfo:
import data=sashelp.class to ^ / before=MyInfo;
run;
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
Tip
data-set-option(s)
specify actions that apply only to the SAS data set.
See
SAS Data Set Options: Reference for information about SAS data sets and their
options
FIRST
imports the data set or graph segment at the beginning of the directory.
LAST
imports the data set or graph segment at the end the directory.
TEXTFILE= <filename | fileref>
imports a text file into an ODS document that can be replayed to open ODS
destinations.
filename
specifies the filename. filename can be a listing file, a SAS program, or any other
text file.
Requirement
filename must be enclosed in quotation marks.
fileref
is a file reference that has been assigned to an external file. Use the FILENAME
statement to assign a fileref.
See
Example
For information about the FILENAME statement, see SAS Statements:
Reference
“Example 5: Importing LISTING Output and a SAS Program ” on page
168
LINK Statement
Creates a symbolic link from one specified entry to another specified entry.
See:
For information about LINK statement advanced options, see “Restructuring Output
with PROC DOCUMENT” in SAS Output Delivery System: Advanced Topics.
LINK Statement
109
Syntax
LINK path TO path </ option(s)>;
Required Argument
path
specifies the locations of the entries that you want to link to one another.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
Optional Arguments
AFTER= path
links to the entry that follows the specified path in the current directory.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
BEFORE= path
links to the entry that precedes the specified path in the current directory.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
FIRST
links to the first entry in the current directory.
HARD
specifies a type of link that refers to a copy of an output object within the ODS
document. All data is shared between the link and the target, except names and
labels.
For example, the following LINK statement creates a hard link from the output
object ErrorSSCP to the output object LinkedErrorSSCP in the current directory:
link errorSSCP to linkederrorSSCP / hard;
run;
Restriction
A hard link can reference only an output object, and the source and
target paths must be in the same ODS document. The target must exist
when you create the hard link.
Interaction
A hard link and its target exist independently. Deleting a hard link does
not affect the target. Similarly, deleting a target does not affect the link.
LABEL
copies the source label to the link.
Default
The source label is not copied unless the LABEL option is specified.
LAST
links to the last entry in the current directory.
110
Chapter 6
•
The DOCUMENT Procedure
LIST Statement
Lists the contents of one or more entries.
Defaults:
Only summary information is displayed if the DETAILS option is omitted.
If the ORDER= option is omitted, then the contents of the specified entries are listed
in the order specified by the INSERT option.
Tip:
Examples:
To see any entries that might be hidden in the current directory, use the LIST
statement.
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
“Example 2: Navigating the Directory and Listing the Entries” on page 152
“Opening and Listing ODS Documents Using WHERE Expressions” in SAS Output
Delivery System: Advanced Topics
“Example 3: Managing Entries” on page 156
“Example 4: Listing BY-Group Entries” on page 162
Syntax
LIST path <(where-expression)> <, path-2 <(where-expression-2)>, …> </ option(s)>;
Required Argument
path
specifies the location of an entry. An entry can be one or more directories, links, or
output objects. For example, the following LIST statement lists all of the entries
within the Report entry:
list \sasuser.imports\report;
run;
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
Optional Arguments
BYGROUPS
creates, in the entry list, columns for BY variables. The name of the BY variable
becomes the column name. The values of the BY variables are listed in the columns.
Note: When you specify the BYGROUPS option, only entries containing BY group
information are listed.
Interaction
It is recommended that when you specify the BYGROUPS option,
specify the LEVELS=ALL option also. If the LEVELS=ALL option is
not specified, then ODS cannot find BY group information within all
levels of the directories.
Example
“Example 4: Listing BY-Group Entries” on page 162
LIST Statement 111
DETAILS
specifies the properties of the entries. For example, the following LIST statement
lists the details of three levels of the Report entry:
list \sasuser.imports\report / details levels=3;
run;
Specifying list/levels=all details; generates a table with the following
columns:
Created
shows the date on which the entry was created.
Label
shows the entry’s label.
Modified
shows the date on which the entry was last modified.
Page Break
shows before or after page breaks, if present.
Path
shows the entry’s path.
Size in Bytes
shows the entry’s size in bites.
Symbolic Link
shows a symbolic link associated with the entry, if present.
Template
shows the template associated with the entry, if present.
Type
shows the entry’s type.
FOLLOW
resolves all links and lists the contents of the entries.
LEVELS= ALL | value
specifies the number of levels that you want to list.
ALL
specifies all levels.
value
specifies the numeric value of the path level. For example, the following LIST
statement lists the details of three levels of the Report entry:
list \sasuser.imports\report / details levels=3;
run;
Default
If you omit the LEVELS= option, then the default value of the level is
1.
Restriction
The LEVELS= option is valid only when you specify a directory.
ORDER= ALPHA | DATE | INSERT
specifies the order in which the entries are listed.
ALPHA
lists the entries in alphabetical order.
DATE
lists the directories in ascending order based on the date and time the files were
created.
INSERT
lists the directories in the order in which the entries were inserted.
(WHERE=(where-expression-1<operator >))
conditionally selects a subset of entries in an ODS document.
112
Chapter 6
•
The DOCUMENT Procedure
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
operand
is one of the following:
constant
is a fixed value such as a date literal, a value, or a BY variable value.
SAS function
For information about SAS functions, see SAS Functions and CALL
Routines: Reference.
subsetting variable
is a special type of WHERE expression operand used by the
DOCUMENT procedure to help you find common values in ODS
documents. Here are the subsetting variables:
_CDATE_
is the creation date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of 16JUL2004 to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\ work.mydoc\monthly;
run;
_CDATETIME_
is the creation datetime of the current entry.
Example
The following COPY TO statement copies all entries with a
creation datetime of May 1, 2003, at 9:30 to the Monthly
directory of Work.MyDoc:
copy ^(where=(_cdatetime_ = '01may04:9:30:00'dt))
to \work.mydoc\monthly;
run;
_CTIME_
is the creation time of the current entry.
Example
The following DELETE statement deletes all entries with a
creation time of 9:25:19 PM:
delete ^(where=(_ctime_ = '9:25:19pm't));
run;
_LABEL_
is the label of the current entry.
Example
The following LIST statement lists all tables containing the label 'Type
III Model' within the GLM procedure:
list glm(where=(_type_ = 'table' _label_ ? 'Type III Model'));
run;
_LABELPATH_
is the path to the label of the current entry. Document label paths are
formed by concatenating the labels and sequence numbers, and then
separating them with the forward slash (/) symbol. Document label
LIST Statement
113
paths are similar to the label paths specified by the ODS TRACE
statement.
For example, suppose that this is the ODS TRACE label path:
'The Univariate Procedure'.'Normal_x'.'Histogram 1'
The corresponding document label path would be as follows:
'The Univariate Procedure'#1\'Normal_x'#1\'Histogram 1'#1
Note that in document label paths, the instances of '.' are replaced with
'\'.
See
“ODS TRACE Statement” on page 68
Example
The following LIST statement lists all items containing “Fit Statistics”
in the label path.
list gml(where=(_labelpath_ ? "Fit Statistics"))/ levels=all;
run;
_MAX_
is the last observation.
Restrictions
_MAX_ is used only for output objects.
_MAX_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the last observation:
Example
replay class(where=(_obs_ < _max_));
_MDATE_
is the modification date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a modification date of 16JUL2004 to the Monthly directory
of Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _mdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
_MDATETIME_
is the modification datetime of the current entry.
Example
The following REPLAY statement replays all entries with a
modification datetime of May 1, 2003, at 9:30:
replay ^(where=(_mdatetime_ = '01may04:9:30:00'dt));
run;
_MIN_
is the first observation.
Restrictions
_MIN_ is used only for output objects.
_MIN_ is always set to 1
_MIN_ is used only in the REPLAY statement.
114
Chapter 6
•
The DOCUMENT Procedure
The following REPLAY statement replays all observations
except the first observation:
Example
replay class(where=(_obs_ <
_min_));
_MTIME_
is the modification time of the current entry.
Example
The following COPY TO statement copies all entries with a
modification time of 9:25:19 PM to the Monthly directory of
Work.MyDoc:
copy ^(where=(_mtime_ = '9:25:19pm't)) to \work.mydoc\monthly;
run;
_NAME_
is the name of the current entry.
Example
The following DELETE statement deletes all entries that
contain the name “stemleng” within the GLM procedure:
delete glm(where=(_name_ ? 'stemleng'));
_OBS_
is the current observation number in an output object.
Restrictions
_OBS_ is used only for output objects.
_OBS_ is used only in the REPLAY statement.
Examples
The following REPLAY statement replays all but the first
ten observations:
replay class(where=(_obs_ > 10));
The following REPLAY statement replays all observations
except the last observation:
replay class(where=(_obs_ < _max_));
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observations:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-number
is the observation number to be replayed.
Restrictions
observation-number is used only for output objects.
observation-number is used only in the REPLAY
statement.
Example
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observation:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-variable
is the name of an observation.
Restrictions
observation-variable is used only for output objects.
LIST Statement
115
observation-variable is used only in the REPLAY
statement.
Examples
The following REPLAY statement replays all observations
where the variable Weight is greater than 100:
replay class(where=(weight>100));
The following REPLAY statement replays all observations
where the variable Sex is equal to ‘F’.
replay class(where=(sex='F'));
_PATH_
is the path of the current entry.
Example
The following LIST statement lists all entries with a path
containing the substring 'Anova' at all levels of the current
directory:
list ^(where=(_path_ ? 'Anova'));
run;
_SEQNO_
is the sequence number of the current entry.
See
“Understanding Sequence Numbers ” on page 87
Example
The following REPLAY statement replays all entries that have
a sequence number of 2 in the GLM procedure:
replay glm(where=(_seqno_ = 2));
_TYPE_
is the type of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of July 16, 2004, to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
variable- name
is the name of a BY variable.
Example
The following MOVE TO statement moves all entries where
the value of the variable Gender is 'F' to the Monthly directory
of Work.MyDoc:
move ^(where=(gender='F')) to \work.mydoc\monthly;
run;
operator
compares one variable with a value or another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
Table 6.3
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
116
Chapter 6
•
The DOCUMENT Procedure
Symbol
Mnemonic Equivalent
Definition
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
For the REPLAY statement, the WHERE= option applies to
directories and output objects. For the following statements, the
WHERE= option applies to directories only:
• COPY TO
• DELETE
• LIST
• MOVE TO
Requirement
Enclose where-expression in quotation marks.
See
For advanced information about using where-expressions, see “Using
WHERE Expressions in PROC DOCUMENT” in SAS Output
Delivery System: Advanced Topics.
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Opening and Listing ODS Documents Using WHERE Expressions”
in SAS Output Delivery System: Advanced Topics
MAKE Statement
Creates one or more new directories.
Default:
If no location is specified, the newly created directory is appended to the end of the
current directory.
Example:
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
Syntax
MAKE path <, path-2, …> </ option(s)>;
MOVE TO Statement 117
Required Argument
path
specifies the newly created directory.
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
Optional Arguments
AFTER= path
adds the newly created directory after the specified path in the current directory.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
BEFORE= path
adds the newly created directory before the specified path in the current directory.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
FIRST
adds the newly created directory to the beginning of the current directory.
LAST
adds the newly created directory to the end of the current directory.
MOVE TO Statement
Moves entries from the specified location to another location.
Restriction:
Requirement:
Tip:
The root directory cannot be moved or deleted.
Separate multiple paths with commas.
The MOVE TO statement affects all levels of a directory below the specified starting
level.
Syntax
MOVE path <(where-expression)> <, path-2 <(where-expression-2)>, …> TO path </ option(s)>;
Required Argument
path
specifies the location of links, output objects, or files that you want to move.
CAUTION:
The MOVE TO statement affects all levels of a directory below the specified
starting level.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
118
Chapter 6
•
The DOCUMENT Procedure
Optional Arguments
AFTER= path
moves the entry after the specified entry in the path.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
BEFORE= path
moves the entry before the specified entry in the path.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
FIRST
moves the entry to the beginning of the specified directory.
LAST
moves the entry to the end of the specified directory.
LEVELS= ALL | value
specifies the number of levels that you want to move.
ALL
specifies all levels.
value
specifies the numeric value of the path level. For example, the following MOVE
TO statement moves two levels of the directory Weekly to the Monthly directory
of Work.MyDoc:
move weekly to \work.mydoc\monthly / levels = 2;
run;
Default
ALL
Restriction
The LEVELS= option is valid only when you specify a directory.
(WHERE=(where-expression-1<operator >))
conditionally selects a subset of entries in an ODS document.
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
operand
is one of the following:
constant
is a fixed value such as a date literal, a value, or a BY variable value.
SAS function
For information about SAS functions, see SAS Functions and CALL
Routines: Reference.
subsetting variable
is a special type of WHERE expression operand used by the
DOCUMENT procedure to help you find common values in ODS
documents. Here are the subsetting variables:
_CDATE_
is the creation date of the current entry.
MOVE TO Statement 119
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of 16JUL2004 to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\ work.mydoc\monthly;
run;
_CDATETIME_
is the creation datetime of the current entry.
Example
The following COPY TO statement copies all entries with a
creation datetime of May 1, 2003, at 9:30 to the Monthly
directory of Work.MyDoc:
copy ^(where=(_cdatetime_ = '01may04:9:30:00'dt))
to \work.mydoc\monthly;
run;
_CTIME_
is the creation time of the current entry.
Example
The following DELETE statement deletes all entries with a
creation time of 9:25:19 PM:
delete ^(where=(_ctime_ = '9:25:19pm't));
run;
_LABEL_
is the label of the current entry.
Example
The following LIST statement lists all tables containing the label 'Type
III Model' within the GLM procedure:
list glm(where=(_type_ = 'table' _label_ ? 'Type III Model'));
run;
_LABELPATH_
is the path to the label of the current entry. Document label paths are
formed by concatenating the labels and sequence numbers, and then
separating them with the forward slash (/) symbol. Document label
paths are similar to the label paths specified by the ODS TRACE
statement.
For example, suppose that this is the ODS TRACE label path:
'The Univariate Procedure'.'Normal_x'.'Histogram 1'
The corresponding document label path would be as follows:
'The Univariate Procedure'#1\'Normal_x'#1\'Histogram 1'#1
Note that in document label paths, the instances of '.' are replaced with
'\'.
See
“ODS TRACE Statement” on page 68
Example
The following LIST statement lists all items containing “Fit Statistics”
in the label path.
list gml(where=(_labelpath_ ? "Fit Statistics"))/ levels=all;
run;
120
Chapter 6
•
The DOCUMENT Procedure
_MAX_
is the last observation.
Restrictions
_MAX_ is used only for output objects.
_MAX_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the last observation:
Example
replay class(where=(_obs_ < _max_));
_MDATE_
is the modification date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a modification date of 16JUL2004 to the Monthly directory
of Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _mdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
_MDATETIME_
is the modification datetime of the current entry.
Example
The following REPLAY statement replays all entries with a
modification datetime of May 1, 2003, at 9:30:
replay ^(where=(_mdatetime_ = '01may04:9:30:00'dt));
run;
_MIN_
is the first observation.
Restrictions
_MIN_ is used only for output objects.
_MIN_ is always set to 1
_MIN_ is used only in the REPLAY statement.
Example
The following REPLAY statement replays all observations
except the first observation:
replay class(where=(_obs_ <
_min_));
_MTIME_
is the modification time of the current entry.
Example
The following COPY TO statement copies all entries with a
modification time of 9:25:19 PM to the Monthly directory of
Work.MyDoc:
copy ^(where=(_mtime_ = '9:25:19pm't)) to \work.mydoc\monthly;
run;
_NAME_
is the name of the current entry.
Example
The following DELETE statement deletes all entries that
contain the name “stemleng” within the GLM procedure:
delete glm(where=(_name_ ? 'stemleng'));
MOVE TO Statement 121
_OBS_
is the current observation number in an output object.
Restrictions
_OBS_ is used only for output objects.
_OBS_ is used only in the REPLAY statement.
The following REPLAY statement replays all but the first
ten observations:
Examples
replay class(where=(_obs_ > 10));
The following REPLAY statement replays all observations
except the last observation:
replay class(where=(_obs_ < _max_));
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observations:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-number
is the observation number to be replayed.
Restrictions
observation-number is used only for output objects.
observation-number is used only in the REPLAY
statement.
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observation:
Example
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-variable
is the name of an observation.
Restrictions
observation-variable is used only for output objects.
observation-variable is used only in the REPLAY
statement.
Examples
The following REPLAY statement replays all observations
where the variable Weight is greater than 100:
replay class(where=(weight>100));
The following REPLAY statement replays all observations
where the variable Sex is equal to ‘F’.
replay class(where=(sex='F'));
_PATH_
is the path of the current entry.
Example
The following LIST statement lists all entries with a path
containing the substring 'Anova' at all levels of the current
directory:
list ^(where=(_path_ ? 'Anova'));
run;
_SEQNO_
is the sequence number of the current entry.
122
Chapter 6
•
The DOCUMENT Procedure
See
“Understanding Sequence Numbers ” on page 87
Example
The following REPLAY statement replays all entries that have
a sequence number of 2 in the GLM procedure:
replay glm(where=(_seqno_ = 2));
_TYPE_
is the type of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of July 16, 2004, to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
variable- name
is the name of a BY variable.
Example
The following MOVE TO statement moves all entries where
the value of the variable Gender is 'F' to the Monthly directory
of Work.MyDoc:
move ^(where=(gender='F')) to \work.mydoc\monthly;
run;
operator
compares one variable with a value or another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
Table 6.4
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
For the REPLAY statement, the WHERE= option applies to
directories and output objects. For the following statements, the
WHERE= option applies to directories only:
• COPY TO
• DELETE
• LIST
NOTE Statement 123
•
MOVE TO
Requirement
Enclose where-expression in quotation marks.
See
For advanced information about using where-expressions, see “Using
WHERE Expressions in PROC DOCUMENT” in SAS Output
Delivery System: Advanced Topics.
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Opening and Listing ODS Documents Using WHERE Expressions”
in SAS Output Delivery System: Advanced Topics
NOTE Statement
Creates text strings in the current directory.
Default:
Example:
If you omit the JUST= option, then the note is centered between the left and right
margins.
“Example 3: Managing Entries” on page 156
Syntax
NOTE path <'text'> </ option(s)>;
Without Arguments
If no text string is specified, then the NOTE statement creates a blank note.
Required Argument
path
specifies the location where the note is stored.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
Optional Arguments
AFTER= path
inserts the text string after the specified path.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
BEFORE= path
inserts the text string before the specified path.
124
Chapter 6
•
The DOCUMENT Procedure
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
FIRST
inserts the text string at the beginning of the directory.
JUST= LEFT | CENTER | RIGHT
specifies the alignment of the text string.
LEFT
aligns the text string with the left margin.
CENTER
centers the text string between the left and right margins.
RIGHT
aligns the text string with the right margin.
LAST
inserts the text string at the end of the directory.
'text'
specifies the text string.
Requirement
All text strings must be enclosed in quotation marks.
OBANOTE Statement
Creates or modifies an object footer (lines of text) after the specified output object.
Example:
“Example 3: Managing Entries” on page 156
Syntax
OBANOTE <n> output-object <'text '> <SHOW></ JUST= LEFT | CENTER | RIGHT>;
Required Argument
output-object
specifies the name of the ODS output object.
Optional Arguments
JUST= LEFT | CENTER | RIGHT
specifies the alignment of the object footer.
LEFT
aligns the object footer with the left margin.
CENTER
centers the object footer between the left and right margins.
RIGHT
aligns the object footer with the right margin.
n
specifies the relative line that contains the object footer.
OBBNOTE Statement 125
Default
If you omit n, then SAS assumes a value of 1. Therefore, specify either
OBANOTE or OBANOTE1 for the first text line.
Range
1–10
Tips
The OBANOTE line with the highest number appears on the bottom line.
You can create notes that contain blank lines between them. For example, if
you specify a text string with an OBANOTE1 statement that is followed by
an OBANOTE3 statement, then a blank line separates the two lines of text.
SHOW
specifies that a table containing the output object’s heading is written to active
destinations.
'text'
specifies the text string that becomes the object footer.
You can customize object footers by inserting BY variable values (#BYVALn), BY
variable names (#BYVARn), or BY lines (#BYLINE) into object footers that are
specified in PROC DOCUMENT steps. After you specify the object footer, embed
the items at the position where you want them to appear. For more information, see
“Customizing Labels, Titles, and Footnotes with BY Variables ” on page 141.
Length
The maximum text length is 32000 characters.
Requirement
All text strings must be enclosed in quotation marks.
CAUTION
If no text string is specified, then the OBANOTE statement
deletes all object footers for the specified output object only.
OBBNOTE Statement
Creates or modifies an object heading (lines of text) before the output object.
Example:
“Example 3: Managing Entries” on page 156
Syntax
OBBNOTE <n> output-object <'text'> <SHOW></ JUST= LEFT | CENTER | RIGHT>;
Required Argument
output-object
specifies the name of the ODS output object.
Optional Arguments
JUST= LEFT | CENTER | RIGHT
specifies the alignment of the object heading.
LEFT
aligns the object heading with the left margin.
CENTER
centers the object heading between the left and right margins.
126
Chapter 6
•
The DOCUMENT Procedure
RIGHT
aligns the object heading with the right margin.
n
specifies the relative line that contains the object heading.
Default
If you omit n, then SAS assumes a value of 1. Therefore, specify either
OBBNOTE or OBBNOTE1 for the first text line.
Range
1– 10
Tips
The OBBNOTE line with the highest number appears on the bottom line.
You can create notes that contain blank lines between them. For example, if
you specify a text string with an OBBNOTE statement that is followed by
an OBBNOTE3 statement, then a blank line separates the two lines of text.
SHOW
specifies that a table containing the output object’s footers is written to active
destinations.
'text'
specifies the text string that becomes the object heading.
You can customize object headings by inserting BY variable values (#BYVALn), BY
variable names (#BYVARn), or BY lines (#BYLINE) into object headings that are
specified in PROC DOCUMENT steps. After you specify the object heading text,
embed the items at the position where you want them to appear. For more
information, see “Customizing Labels, Titles, and Footnotes with BY Variables ” on
page 141 .
Length
The maximum text length is 32000 characters.
Requirement
All text strings must be enclosed in quotation marks.
CAUTION
If no text string is specified, then the OBBNOTE statement
deletes all existing object headings for the specified output object
only.
OBFOOTN Statement
Creates or modifies lines of text at the bottom of the page on which the output object is displayed.
Restriction:
Tip:
Example:
You can print up to ten lines of text.
The OBFOOTN statement is similar to the global FOOTNOTE statement.
“Example 3: Managing Entries” on page 156
Syntax
OBFOOTN <n> output-object <SHOW><'text'>;
Required Argument
output-object
specifies the ODS output object.
OBPAGE Statement
127
Optional Arguments
n
specifies the relative line that contains the footnote.
Range
1–10
Tips
The OBFOOTN line with the highest number appears on the bottom line. If
you omit n, then SAS assumes a value of 1. Therefore, specify OBFOOTN
or OBFOOTN1 for the first text line.
You can create footnotes that contain blank lines between them. For
example, if you specify a text string with an OBFOOTN statement that is
followed by an OBFOOTN3 statement, then a blank line separates the two
lines of text.
SHOW
specifies that a table containing the output object’s footnotes is written to active
destinations.
'text'
specifies the text string that becomes the footnote.
You can customize footnotes by inserting BY variable values (#BYVALn), BY
variable names (#BYVARn), or BY lines (#BYLINE) into footnotes that are
specified in PROC DOCUMENT steps. After you specify the text, embed the items
at the position where you want them to appear. For more information, see
“Customizing Labels, Titles, and Footnotes with BY Variables ” on page 141 .
Length
The maximum text length is 32000 characters.
Requirement
All text strings must be enclosed in quotation marks.
CAUTION
If you use the OBFOOTN statement without a text string, then all
existing footnotes for the specified output object are deleted.
OBPAGE Statement
Creates or deletes a page break for an output object.
Example:
“Example 3: Managing Entries” on page 156
Syntax
OBPAGE output-object < / <DELETE > <AFTER>>;
Without Arguments
If no options are specified, then the OBPAGE statement inserts a page break before an
output object.
Required Argument
output-object
specifies the name of the output object.
128
Chapter 6
•
The DOCUMENT Procedure
Optional Arguments
AFTER
inserts a page break after an output object.
To delete a page break after an output object, use the AFTER option as well as
the DELETE option.
Tip
DELETE
removes the page break for an output object.
There is an initial page break for each destination for each use of the
REPLAY statement. There might be subsequent page breaks depending on the
destination and the output being generated.
TIP
OBSTITLE Statement
Create or modify subtitles.
Example:
“Example 3: Managing Entries” on page 156
Syntax
OBSTITLE<n> output-object <'text'> <SHOW></ JUST= LEFT | CENTER | RIGHT>;
Required Argument
output-object
specifies the ODS output object.
Optional Arguments
JUST= LEFT | CENTER | RIGHT
specifies the alignment of the text string.
LEFT
aligns the text string with the left margin.
CENTER
aligns the text string in the center between the left and right margins.
RIGHT
aligns the text string with the right margin.
n
specifies the relative line that contains the subtitle.
Range
1–10
Tips
The OBSTITLE line with the highest number appears on the bottom line. If
you omit n, then SAS assumes a value of 1. Therefore, you can specify
OBSTITLE or OBSTITLE1 for the first text line.
You can create subtitles that contain blank lines between them. For
example, if you specify a text string with an OBSTITLE statement that is
followed by an OBSTITLE3 statement, then a blank line separates the two
lines of text.
OBTITLE Statement
129
SHOW
specifies that a table containing the output object’s subtitles is written to active
destinations.
'text'
specifies the text string.
You can customize subtitles by inserting BY variable values (#BYVALn), BY
variable names (#BYVARn), or BY lines (#BYLINE) into subtitles that are specified
in PROC DOCUMENT steps. After you specify text, embed the items at the position
where you want them to appear. For more information, see “Customizing Labels,
Titles, and Footnotes with BY Variables ” on page 141.
Length
The maximum text length is 32000 characters.
Requirement
All text strings must be enclosed in quotation marks.
Tip
If no arguments are specified, then the OBSTITLE statement deletes
all existing subtitles for the specified output object only.
OBTEMPL Statement
Writes, to any open ODS destination, the source code of the ODS template, if any, that is associated with
the specified output object.
Restriction:
See:
If the output object that is specified has no ODS template associated with it, then no
output is created.
For advanced OBTEMPL statement topics, see “Working with Output Objects and
Table Templates” in SAS Output Delivery System: Advanced Topics.
Syntax
OBTEMPL output-object;
Required Argument
output-object
specifies the pathname of the output object.
See
“Getting Familiar with Output Objects” on page 88
Example
“Example 4: Listing BY-Group Entries” on page 162
OBTITLE Statement
Creates or modifies title lines for the output.
Tip:
Example:
The OBTITLE is similar to the global TITLE statement.
“Example 3: Managing Entries” on page 156
130
Chapter 6
•
The DOCUMENT Procedure
Syntax
OBTITLE<n> output-object <SHOW><'text'>;
Required Argument
output-object
specifies the name of the output object.
Optional Arguments
n
specifies the relative line that contains the title.
Range
1–10
Tips
The OBTITLE line with the highest number appears on the bottom line. If
you omit n, then SAS assumes a value of 1. Therefore, specify OBTITLE or
OBTITLE1 for the first text line.
You can create titles that contain blank lines between them. For example, if
you specify a text string with an OBTITLE statement that is followed by an
OBTITLE3 statement, then a blank line separates the two lines of text.
SHOW
specifies that a table containing the output object’s titles is written to active
destinations.
'text'
specifies the text string.
You can customize titles by inserting BY variable values (#BYVALn), BY variable
names (#BYVARn), or BY lines (#BYLINE) into output titles that are specified in
PROC DOCUMENT steps. After you specify the text, embed the items at the
position where you want them to appear. For more information, see “Customizing
Labels, Titles, and Footnotes with BY Variables ” on page 141 .
Length
The maximum text length is 32000 characters.
Requirement
All text strings must be enclosed in quotation marks.
CAUTION
If no text is specified, then the OBTITLE statement deletes all
existing titles for the specified output object only.
RENAME TO Statement
Renames an entry.
Syntax
RENAME path-1 TO path-2;
REPLAY Statement
131
Required Arguments
path-1
specifies the current directory or output object.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
path-2
specifies the new name of the directory or output object.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
REPLAY Statement
Displays one or more entries to the specified open ODS destination(s).
Default:
Restrictions:
If you omit the LEVELS= option, then all levels of the file are displayed to all open
destinations.
User-defined format names must be unique within an ODS DOCUMENT.
When replaying an ODS document, values created by the MVAR statement must be
recreated in the same session that is replaying the document.
Tip:
Examples:
There is an initial page break for each destination for each use of the REPLAY
statement. There might be subsequent page breaks depending on the destination
and the output being generated.
“Example 3: Managing Entries” on page 156
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
Syntax
REPLAY path <(where-expression)> <, path-2 <(where-expression-2)>, …> </ option(s)>;
Optional Arguments
ACTIVEFOOTN
specifies that footnotes that are active in a SAS session override the footnotes that
are stored in an ODS document.
Alias
ACFOOTN
ACTIVETITLE
specifies that titles that are active in a SAS session override the titles that are stored
in an ODS document.
Alias
ACTITLE
DEST= (ODS-destination(s))
specifies one or more ODS destinations to display the output objects. For example,
the following REPLAY statement replays two levels of the entry Data to the HTML
and RTF destinations:
132
Chapter 6
•
The DOCUMENT Procedure
replay \Report\GLM#1\Data / levels=2 dest=(html rtf);
run;
Requirement
When you specify the DEST= option, enclose the ODS destinations
in parentheses and separate each destination with a blank space. For
example, DEST=(HTML RTF LISTING)
Tip
When you specify only one destination, you do not need to use
parentheses. For example, DEST=HTML
See
For information about ODS destinations, see “Understanding ODS
Destinations” in SAS Output Delivery System: User's Guide .
LEVELS= ALL | value
specifies the number of levels that you want to replay.
ALL
specifies that all levels of the directory are displayed to all open destinations.
value
specifies the numeric value of the path level. For example, the following
REPLAY statement replays two levels of the entry Data to the HTML and RTF
destinations:
replay \Report\GLM#1\Data / levels=2 dest=(html rtf);
run;
Default
ALL
Restriction
The LEVELS= option is valid only when you specify a directory.
path
specifies the location of an entry. An entry can be one or more directories, links, or
output objects.
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
STORE=template-store
specifies the template store when replaying output objects from the path. If the
replayed path is an output object, the template store applies only to that output
object. If the path is a directory, the template store applies to any output objects
contained within the directory.
Restriction
The STORE= option applies only to output objects with external
templates. Output objects with internal templates, such as those
generated by PROC PRINT, PROC REPORT, PROC TABULATE,
and PROC SGPLOT, are unaffected by STORE=.
Requirement
The STORE= option can be used only if the path option is also
specified in the REPLAY statement.
Tip
The STORE= option is useful if you want to use different templates
with a single or multiple output objects.
Example
“Using PROC DOCUMENT to Work with Table Templates ” in SAS
Output Delivery System: Advanced Topics
REPLAY Statement
133
(WHERE=(where-expression-1<operator >))
conditionally selects a subset of entries in an ODS document.
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
operand
is one of the following:
constant
is a fixed value such as a date literal, a value, or a BY variable value.
SAS function
For information about SAS functions, see SAS Functions and CALL
Routines: Reference.
subsetting variable
is a special type of WHERE expression operand used by the
DOCUMENT procedure to help you find common values in ODS
documents. Here are the subsetting variables:
_CDATE_
is the creation date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of 16JUL2004 to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\ work.mydoc\monthly;
run;
_CDATETIME_
is the creation datetime of the current entry.
Example
The following COPY TO statement copies all entries with a
creation datetime of May 1, 2003, at 9:30 to the Monthly
directory of Work.MyDoc:
copy ^(where=(_cdatetime_ = '01may04:9:30:00'dt))
to \work.mydoc\monthly;
run;
_CTIME_
is the creation time of the current entry.
Example
The following DELETE statement deletes all entries with a
creation time of 9:25:19 PM:
delete ^(where=(_ctime_ = '9:25:19pm't));
run;
_LABEL_
is the label of the current entry.
Example
The following LIST statement lists all tables containing the label 'Type
III Model' within the GLM procedure:
list glm(where=(_type_ = 'table' _label_ ? 'Type III Model'));
run;
134
Chapter 6
•
The DOCUMENT Procedure
_LABELPATH_
is the path to the label of the current entry. Document label paths are
formed by concatenating the labels and sequence numbers, and then
separating them with the forward slash (/) symbol. Document label
paths are similar to the label paths specified by the ODS TRACE
statement.
For example, suppose that this is the ODS TRACE label path:
'The Univariate Procedure'.'Normal_x'.'Histogram 1'
The corresponding document label path would be as follows:
'The Univariate Procedure'#1\'Normal_x'#1\'Histogram 1'#1
Note that in document label paths, the instances of '.' are replaced with
'\'.
See
“ODS TRACE Statement” on page 68
Example
The following LIST statement lists all items containing “Fit Statistics”
in the label path.
list gml(where=(_labelpath_ ? "Fit Statistics"))/ levels=all;
run;
_MAX_
is the last observation.
Restrictions
_MAX_ is used only for output objects.
_MAX_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the last observation:
Example
replay class(where=(_obs_ < _max_));
_MDATE_
is the modification date of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a modification date of 16JUL2004 to the Monthly directory
of Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _mdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
_MDATETIME_
is the modification datetime of the current entry.
Example
The following REPLAY statement replays all entries with a
modification datetime of May 1, 2003, at 9:30:
replay ^(where=(_mdatetime_ = '01may04:9:30:00'dt));
run;
_MIN_
is the first observation.
Restrictions
_MIN_ is used only for output objects.
_MIN_ is always set to 1
REPLAY Statement
135
_MIN_ is used only in the REPLAY statement.
The following REPLAY statement replays all observations
except the first observation:
Example
replay class(where=(_obs_ <
_min_));
_MTIME_
is the modification time of the current entry.
Example
The following COPY TO statement copies all entries with a
modification time of 9:25:19 PM to the Monthly directory of
Work.MyDoc:
copy ^(where=(_mtime_ = '9:25:19pm't)) to \work.mydoc\monthly;
run;
_NAME_
is the name of the current entry.
Example
The following DELETE statement deletes all entries that
contain the name “stemleng” within the GLM procedure:
delete glm(where=(_name_ ? 'stemleng'));
_OBS_
is the current observation number in an output object.
Restrictions
_OBS_ is used only for output objects.
_OBS_ is used only in the REPLAY statement.
Examples
The following REPLAY statement replays all but the first
ten observations:
replay class(where=(_obs_ > 10));
The following REPLAY statement replays all observations
except the last observation:
replay class(where=(_obs_ < _max_));
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observations:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-number
is the observation number to be replayed.
Restrictions
observation-number is used only for output objects.
observation-number is used only in the REPLAY
statement.
Example
The following REPLAY statement replays the first, third,
fifth, seventh, and ninth observation:
replay class(where=(_obs_ in (1,3,5,7,9)));
observation-variable
is the name of an observation.
Restrictions
observation-variable is used only for output objects.
136
Chapter 6
•
The DOCUMENT Procedure
observation-variable is used only in the REPLAY
statement.
Examples
The following REPLAY statement replays all observations
where the variable Weight is greater than 100:
replay class(where=(weight>100));
The following REPLAY statement replays all observations
where the variable Sex is equal to ‘F’.
replay class(where=(sex='F'));
_PATH_
is the path of the current entry.
Example
The following LIST statement lists all entries with a path
containing the substring 'Anova' at all levels of the current
directory:
list ^(where=(_path_ ? 'Anova'));
run;
_SEQNO_
is the sequence number of the current entry.
See
“Understanding Sequence Numbers ” on page 87
Example
The following REPLAY statement replays all entries that have
a sequence number of 2 in the GLM procedure:
replay glm(where=(_seqno_ = 2));
_TYPE_
is the type of the current entry.
Example
The following MOVE TO statement moves all entries of the type
'Graph' with a creation date of July 16, 2004, to the Monthly directory of
Work.MyDoc:
move ^(where=(_type_ = 'Graph' and _cdate_ = '16JUL2004'd)) to
\work.mydoc\monthly;
run;
variable- name
is the name of a BY variable.
Example
The following MOVE TO statement moves all entries where
the value of the variable Gender is 'F' to the Monthly directory
of Work.MyDoc:
move ^(where=(gender='F')) to \work.mydoc\monthly;
run;
operator
compares one variable with a value or another variable. operator can be
AND, OR NOT, OR, AND NOT, or a comparison operator.
Table 6.5
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
SETLABEL Statement 137
Symbol
Mnemonic Equivalent
Definition
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
For the REPLAY statement, the WHERE= option applies to
directories and output objects. For the following statements, the
WHERE= option applies to directories only:
• COPY TO
• DELETE
• LIST
• MOVE TO
Requirement
Enclose where-expression in quotation marks.
See
For advanced information about using where-expressions, see “Using
WHERE Expressions in PROC DOCUMENT” in SAS Output
Delivery System: Advanced Topics.
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Opening and Listing ODS Documents Using WHERE Expressions”
in SAS Output Delivery System: Advanced Topics
SETLABEL Statement
Assigns a label to the specified path.
Example:
“Using PROC DOCUMENT to Work with Table Templates ” in SAS Output Delivery
System: Advanced Topics
Syntax
SETLABEL path 'label';
138
Chapter 6
•
The DOCUMENT Procedure
Required Arguments
'label'
specifies the text of the label. You can customize labels by inserting BY variable
values (#BYVAL), BY variable names (#BYVAR), or BY lines (#BYLINE) into
labels that are specified in PROC DOCUMENT steps.
Requirement
The label must be enclosed in quotation marks.
See
For more information, see “Customizing Labels, Titles, and
Footnotes with BY Variables ” on page 141.
path
specifies the location of a link, output object, or directory.
Tip
You can use the symbol '^' to represent the current directory and the symbol '^^'
to represent the parent directory.
UNHIDE Statement
Enables the output of a hidden entry to be displayed when it is replayed.
Syntax
UNHIDE path <,path-2, …path-n>;
Required Argument
path
specifies the location of a link, output object, or file.
Requirement
Separate multiple paths with commas.
Tip
You can use the symbol '^' to represent the current directory and the
symbol '^^' to represent the parent directory.
Advanced ODS DOCUMENT Features
The ODS DOCUMENT destination enables you to store the output objects from your
procedure or process in a special type of item store called a document store. With the
DOCUMENT procedure, you are not limited to simply regenerating the same report.
You can change the order in which objects are rendered, the table of contents, the
templates that are used, macro variables, and ODS and system options. The following
sections show you some of the more advanced features of PROC DOCUMENT.
•
For information about rearranging your output with PROC DOCUMENT, see
“Restructuring Output with PROC DOCUMENT” in SAS Output Delivery System:
Advanced Topics.
Viewing the Contents of an ODS Document
139
•
For information about using WHERE expressions with PROC DOCUMENT, see
“Using WHERE Expressions in PROC DOCUMENT” in SAS Output Delivery
System: Advanced Topics.
•
For information about using PROC DOCUMENT to modify output objects, see
“Working with Output Objects and Table Templates” in SAS Output Delivery System:
Advanced Topics.
Viewing the Contents of an ODS Document
After you have created a document with the ODS DOCUMENT statement, you can use
PROC DOCUMENT to view the contents of your document. You can rearrange,
duplicate, or remove output from the results of a procedure or a database query without
invoking the procedures from the original report. The first step is to view your
document’s contents by using the LIST statement. The LIST statement enables you to
look at the object list and folder structure within the ODS document. The following code
creates a list of all levels of the document Work.Prddoc:
proc document name=work.prddoc;
list / levels=all;
run;
quit;
The LIST statement can be used to list what is in an entire document or just one of the
entries. For more information about the LIST statement, see “LIST Statement” on page
110.
140
Chapter 6
•
The DOCUMENT Procedure
In the following display, every folder icon in the Results window corresponds to an item
with a type of "Dir" in the LIST statement output. Every table created by a procedure
corresponds to an item with a type of "Table" in the LIST statement output.
Figure 6.3
PROC DOCUMENT List Output Compared to Results Window
Replaying Graphics
When replaying graphics created by a device driver from the following list, you must
also specify a device driver from the list with the DEVICE= option in the GOPTIONS
statement:
•
ACTIVEX
•
ACTXIMG
•
JAVA
•
JAVAIMG
See “GOPTIONS Statement” in SAS/GRAPH: Reference in SAS/GRAPH: Reference for
more information.
Customizing Labels, Titles, and Footnotes with BY Variables
141
Customizing Labels, Titles, and Footnotes with
BY Variables
You can customize labels, titles, and footnotes with these statements by inserting BY
variable values (#BYVAL), BY variable names (#BYVAR), or BY lines (#BYLINE) in
labels that are specified in the following PROC DOCUMENT statements:
•
“OBANOTE Statement” on page 124
•
“OBBNOTE Statement” on page 125
•
“OBFOOTN Statement” on page 126
•
“OBSTITLE Statement” on page 128
•
“OBTITLE Statement” on page 129
•
“SETLABEL Statement” on page 137
Note: The #BYVAL, #BYVAR, and #BYLINE substitutions show up only for output
objects that belong to a BY group. Examples of output objects that do not belong to a
BY group are data sets that are imported into a document with the IMPORT TO
statement, and notes that are created with the NOTES statement.
To create these substitutions, embed the items in the specified object text string at the
position where you want the substitution text to appear. The #BYVAL, #BYVAR, and
#BYLINE substitutions have this form:
#BYVALn | #BYVAL(variable-name)
substitutes the current value of the specified BY variable for #BYVAL in the text
string and displays the value in the label.
Follow these rules when you use #BYVAL in a statement of a PROC DOCUMENT
step:
•
Specify the variable that is used by #BYVAL in the BY statement.
•
Insert #BYVAL in the specified text string at the position where you want the
substitution text to appear.
•
Follow #BYVAL with a delimiting character, either a space or other nonalphanumeric character (for example, a quotation mark) that ends the text string.
•
To immediately follow the #BYVAL substitution with other text and no
delimiter, use a trailing dot (as with macro variables).
•
Specify the variable with one of the following:
n
specifies which variable in the BY statement #BYVAL should use. The value of
n indicates the position of the variable in the BY statement.
Example
#BYVAL2 specifies the second variable in the BY statement.
variable-name
names the BY variable.
Requirement
You must enclose variable-name in parentheses.
Tip
variable-name is not case sensitive.
142
Chapter 6
•
The DOCUMENT Procedure
#BYVAL(YEAR) specifies the BY variable, YEAR.
Example
#BYVARn | #BYVAR(variable-name)
substitutes the name of the BY variable or label that is associated with the variable
(whatever the BY line would normally display) for #BYVAR in the text string and
displays the name or label.
Follow these rules when you use #BYVAR in a statement of a PROC DOCUMENT
step:
•
Specify the variable that is used by #BYVAR in the BY statement.
•
Insert #BYVAR in the specified text string at the position where you want the
substitution text to appear.
•
Follow #BYVAR with a delimiting character, either a space or other nonalphanumeric character (for example, a quotation mark) that ends the text string.
•
To immediately follow the #BYVAR substitution with other text and no
delimiter, use a trailing dot (as with macro variables).
•
Specify the variable with one of the following:
n
specifies the variable in the BY statement that #BYVAR should use. The value of
n indicates the position of the variable in the BY statement.
Example
#BYVAR2 specifies the second variable in the BY statement.
variable-name
names the BY variable.
Requirement
You must enclose variable-name in parentheses.
Tip
variable-name is not case sensitive.
Example
#BYVAR(SITES) specifies the BY variable SITES.
#BYLINE
substitutes the entire BY line without leading or trailing blanks for #BYLINE in the
text string and displays the BY line in the label.
Results: DOCUMENT Procedure
ODS Documents in the Documents Window
Understanding When to Use the Documents Window
The Documents window displays ODS documents in a hierarchical tree structure. The
Documents window does the following:
•
displays all ODS documents, including ODS documents stored in SAS libraries
•
organizes, manages, and customizes the layout of the entries contained in ODS
documents
•
displays the property information of ODS documents
Results: DOCUMENT Procedure
•
replays entries
•
renames, copies, moves, or deletes ODS documents
•
creates shortcuts to ODS documents
143
For a comparison of the Documents window to the Results Window, see “Comparisons
between the Documents Window and the Results Window” on page 145.
Note: There is no DOCUMENTS window in SAS Studio. If you are using SAS Studio,
you must use PROC DOCUMENT statements to accomplish these tasks.
Viewing an ODS Document in the Documents Window
To view the Documents window, submit this command in the command bar:
odsdocuments
This display shows the Documents window that contains the ODS document named
Sasuser.Univ. In the display, notice that Sasuser.Univ contains several directory levels.
The Exponential_x directory contains the Exp output object. When you double-click an
output object, such as Exp, that output object is replayed in the Results window to all
open destinations.
Figure 6.4 Documents Window
A Documents window contains these items:
entry
is an output object, link, or directory.
Note: Only output objects of the type Document are displayed in the Documents
window.
directory
is a grouping of ODS document entries.
link
is a symbolic link from one specified output object to another output object.
Note: Within the Documents window, a link is called a shortcut.
ODS document
is the name of an ODS document.
144
Chapter 6
•
The DOCUMENT Procedure
ODS Document Icon
The Results window and the Documents window use this icon to indicate an ODS
document output object:
Figure 6.5
ODS Document Icon
z/OS Specifics
The ODS Documents window on z/OS has the same functionality, but does not use
graphical icons.
Using the Documents Window Pop-up Menu
The Documents window has a pop-up menu with features that are also available through
batch processing. To view the Documents window pop-up menu, follow these steps:
1. Type odsdocuments in the command bar. The Documents window appears.
2. Right-click any entry in the Documents window. The pop-up menu appears.
The following table describes the DOCUMENT procedure menu item features. The
availability of each pop-up menu item depends on which entry you select in the
Documents window.
Table 6.6
Tasks That You Can Do with the Documents Window Pop-up Menu
Task
Menu Item
Select a new ODS destination output type
Open As
Show the entries that were previously
excluded
Show Excluded
Remove from the tree, but do not delete the
selected entry
Exclude
Replay the selected entry to all open ODS
destinations
Replay
ODS Documents in the Results Window
Understanding When to Use the Results Window
Although the Results window (like the Documents window) lists ODS documents, the
Results window also lists other types of output objects, such as PDF and HTML. The
Results window displays the following information:
•
the output object types that are created when you run a SAS program in the current
SAS session. SAS creates an output object for each ODS destination that was open
when you executed a procedure during the current SAS session only.
Results: DOCUMENT Procedure
145
•
the results after you create a new output object from the Documents window using
the Open As or Replay feature.
•
the properties of an entry.
The Results window also deletes or renames entries.
See “Comparisons between the Documents Window and the Results Window” on page
145.
Viewing Entries in the Results Window
To view the Results window, submit this command in the command bar:
odsresults
You can also view the Results window by selecting: View ð Results
The following display shows the Results window with files and output objects. The last
file is Univariate:100 Obs Sampled from a Normal Distribution. Under this file is the
same output object sent to three different destinations. Each output object is named
Normal, and the destinations are LISTING, HTML, and DOCUMENT.
Figure 6.6 Results Window Showing the Output Object “Normal” in Three Formats
For more information about using the Results window, make the Results window the
active window and select Help ð Using This Window.
Comparisons between the Documents Window and the Results
Window
Table 6.7 Tasks That You Can and Cannot Do in the Documents Window and the Results
Window
Task
Documents window
Results window
View all SAS documents
including those stored in SAS
libraries
Yes
Yes
146
Chapter 6
•
The DOCUMENT Procedure
Task
Documents window
Results window
View output object types that are
created when you run a SAS
program, such as HTML, PDF,
and SAS document
No
Yes
View the results after you create a
new output object
Yes
Yes
Customize the layout of output
objects
Yes
No
View the property information of
SAS documents
Yes
Yes
View the properties of an output
object
No
Yes
Delete or rename entries
Yes
Yes
Copy or move SAS documents
Yes
No
Create shortcuts to SAS
documents
Yes
No
Drag and drop output objects
Yes
No
Viewing the Properties of an Entry
Any entry that you select in either the Results window or the Documents window has an
associated Properties window. To view the properties of an entry, follow these steps:
1. Select an entry from either the Results Window or the Documents window.
2. Right-click the entry. A pop-up menu appears.
3. Select Properties. The Properties window for the entry appears.
Figure 6.7
Entry Properties Window
Results: DOCUMENT Procedure
147
Items vary, depending on the entry that you select in the Documents or Results windows.
The Results window for an ODS document output object can contain these items:
Created
is the date on which the entry was created.
Document
is the SAS filename where the entry is located. The filename is in the form of
libref.filename.
Document path
is the location of the entry in the tree structure. If you move the entry to another
location in the Documents window, then this path changes.
Modified
is the date on which the entry was modified.
Name
is the name of the entry.
Path
is the storage location inside the document of the entry.
Type
is the classification of the entry.
Creating Shortcuts in the Documents Window
The Documents window pop-up menu provides you with a Create Shortcut option.
Shortcut links are useful when you are creating output that uses the same entry in more
than one place. Instead of copying the entry to each location, consider using a shortcut.
Shortcuts have these advantages:
•
Because a shortcut is a link to the original entry, any changes that you make to the
original entry appear when you select the shortcut.
•
A shortcut uses fewer computer resources.
To create a shortcut, do this:
1. Right-click an entry in the Documents window. A pop-up menu appears.
2. Select Create Shortcut. A new shortcut entry appears below the selected entry.
Comparisons between the Documents Window and the DOCUMENT
Procedure
Table 6.8 Tasks That You Can and Cannot Do in the Documents Window and with the
DOCUMENT Procedure
Task
Documents Window
DOCUMENT Procedure
Create a new ODS document
Yes
Yes
Create a new folder
Yes
Yes
Import a data set or graph
segment
No
Yes
148
Chapter 6
•
The DOCUMENT Procedure
Task
Documents Window
DOCUMENT Procedure
Copy folders or output
objects
Yes
Yes
Move folders or output
objects
Yes
Yes
Create a symbolic link from
one output object to another
output object
Yes
Yes
Delete a document, folder, or
output object
Yes
Yes
Rename a folder or output
object
Yes
Yes
Assign a description to a
folder or output object
Yes
Yes
Prevent entries from being
displayed when they are
replayed
Yes
Yes
Show entries that are
excluded
Yes
Yes
Enable hidden entries to be
displayed
Yes
Yes
Replay to the specified open
ODS destinations
Yes
Yes
Determine the path
specification
Yes
Yes
Set or display the current
directory
No
Yes
Create or delete a page break
No
Yes
Create or modify title lines
No
Yes
Create or modify subtitles
No
Yes
Create of modify the lines of
text before output objects
No
Yes
Create or modify the lines of
text after output objects
No
Yes
Create or modify footnote
lines
No
Yes
Example 1: Replaying a Document Using the Document Window
Task
Documents Window
DOCUMENT Procedure
Create text strings in the
current folder
No
Yes
149
Examples: The DOCUMENT Procedure
Example 1: Replaying a Document Using the Document Window
Details
You can use the Documents window to replay a document. Replaying your document
saves you from having to rerun your procedures steps.
To replay an entire document, right-click on the document and select Open As from the
drop down menu. When the Open As window appears, select a destination, such as PDF
150
Chapter 6
•
The DOCUMENT Procedure
(highlighted), and then click OK. You can select multiple destinations by pressing the
Ctrl key and selecting the destinations that you want.
Figure 6.8 Selecting Destinations
The PDF output is shown in the following figure. When you use the Open As window,
SAS creates a default name, in this instance, saspdf.pdf. Using PROC DOCUMENT and
Example 1: Replaying a Document Using the Document Window
151
the REPLAY statement enables you to specify a name for your ODS output when you
replay the document.
Figure 6.9 Replayed PDF Output
The following PDF is the output from the original Work.Prddoc document.
Figure 6.10 Original PDF Output
152
Chapter 6
•
The DOCUMENT Procedure
Example 2: Navigating the Directory and Listing the Entries
Features:
ODS DOCUMENT statement option
NAME=
DOC statement option
NAME=
LIST statement options
entry
LEVELS=
DETAILS
DIR statement option
path
Procedure output: PROC DOCUMENT
ODS
destinations:
DOCUMENT , HTML
Details
This example shows you how to do these tasks:
•
name an ODS document
•
see what ODS documents exist
•
open a document for browsing or editing purposes
•
list one or more entries
•
change directories
Program
data distrdata;
drop n;
label Normal_x='Normal Random Variable'
Exponential_x='Exponential Random Variable';
do n=1 to 100;
Normal_x=10*rannor(53124)+50;
Exponential_x=ranexp(18746363);
output;
end;
run;
ods document name=univ;
title '100 Obs Sampled from a Normal Distribution';
proc univariate data=distrdata noprint;
var Normal_x;
histogram Normal_x / normal(noprint) cbarline=grey name='normal';
run;
title '100 Obs Sampled from an Exponential Distribution';
proc univariate data=distrdata noprint;
Example 2: Navigating the Directory and Listing the Entries
153
var Exponential_x;
histogram / exp(fill l=3) cfill=yellow midpoints=.05 to 5.55 by .25
name='exp';
run;
ods document close;
title;
proc document;
doc;
doc name=univ;
list/levels=all;
dir \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1;
list;
list fitquantiles/details;
run;
quit;
Program Description
Create the DistrData data set. The DistrData data set contains the statistical
information that PROC UNIVARIATE uses to create the histograms.
data distrdata;
drop n;
label Normal_x='Normal Random Variable'
Exponential_x='Exponential Random Variable';
do n=1 to 100;
Normal_x=10*rannor(53124)+50;
Exponential_x=ranexp(18746363);
output;
end;
run;
Create the ODS document Univ and open the DOCUMENT destination. The ODS
DOCUMENT statement opens the DOCUMENT destination. The NAME= option
assigns the name Univ to the ODS document that contains the information from this
PROC UNIVARIATE program. Note that by default Univ is created in the Work library.
Assign a libref to create Univ in a permanent library.
ods document name=univ;
Create a normal distribution histogram. The TITLE statement specifies the title of the
normal distribution histogram. The PROC UNIVARIATE step creates a normal
distribution histogram from the DistrData data set.
title '100 Obs Sampled from a Normal Distribution';
proc univariate data=distrdata noprint;
var Normal_x;
histogram Normal_x / normal(noprint) cbarline=grey name='normal';
run;
154
Chapter 6
•
The DOCUMENT Procedure
Create an exponential distribution histogram. The TITLE statement specifies the title
of the exponential histogram. The PROC UNIVARIATE step creates an exponential
distribution histogram from the DistrData data set.
title '100 Obs Sampled from an Exponential Distribution';
proc univariate data=distrdata noprint;
var Exponential_x;
histogram / exp(fill l=3) cfill=yellow midpoints=.05 to 5.55 by .25
name='exp';
run;
Close the DOCUMENT destination. If the DOCUMENT destination is not closed, no
DOCUMENT procedure output can be viewed.
ods document close;
title;
View the ODS documents, choose an ODS document, and list the entries of the
opened ODS document. The DOC statement (with no arguments specified) prints a
listing of all of the available documents that are in the SAS system. The DOC statement
with the NAME= option specifies the current document, Work.Univ. The LIST statement
with the LEVELS=ALL option lists detailed information about all levels of the
document Work.Univ.
proc document;
doc;
doc name=univ;
list/levels=all;
Set the current directory to EXPONENTIAL, list the contents of the EXPONENTIAL
directory, select a table, and list the details of the table that you selected. The DIR
statement changes the current directory to
\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1. The path
\Univariate#2\Exponential_x#1\Histogram#1\Exponential#1 was
obtained from the listing of the Work.Univ document .The LIST statement (with no
arguments) lists the contents of EXPONENTIAL. The LIST FITQUANTILES\DETAILS
statement specifies that ODS opens the FitQuantiles table and lists its details.
dir \Univariate#2\Exponential_x#1\Histogram#1\Exponential#1;
list;
list fitquantiles/details;
run;
Terminate the DOCUMENT procedure. Specify the QUIT statement to terminate the
DOCUMENT procedure. If you omit QUIT, then you cannot view DOCUMENT
procedure output.
quit;
Example 2: Navigating the Directory and Listing the Entries
Output
Output 6.1 Current ODS Document in Output
Output 6.2 List of the Entries of the ODS Document Work.Univ and the Properties of Those Entries
Output 6.3 List of the Entries of the Exponential#1 Entry and the Properties of Those Entries
155
156
Chapter 6
•
The DOCUMENT Procedure
Output 6.4 Details of the FitQuantiles#1 Table
Example 3: Managing Entries
Features:
PROC DOCUMENT statement option
NAME=
DIR statement
LIST statement option
LEVELS=
NOTE statement
OBANOTE statement option
SHOW option
OBBNOTE statement option
SHOW
OBFOOTN statement option
SHOW
OBPAGE statement
OBSTITLE statement option
SHOW
OBTITLE statement option
SHOW
REPLAY statement
Procedure output
PROC CONTENTS
ODS
destinations:
DOCUMENT, HTML
Details
This example shows you how to do these tasks:
•
generate PROC CONTENTS output to the DOCUMENT destination
•
change the title and footnote of the output
•
add object footer and object heading notes to the output
•
change the subtitle of the output
•
add a note to the document
Example 3: Managing Entries
157
•
add a page break to the output
•
specifies that a table containing the output object’s headings, titles, and footnotes, be
written to the active destinations
•
generate a listing of the entries that shows the details for each entry
Program
ods document name=class(write);
title 'Title Specified by the Global TITLE Statement';
footnote 'Footnote Specified by the Global FOOTNOTE Statement';
proc contents data=sashelp.class;
run;
ods document close;
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obtitle Attributes#1 'Title Specified by the OBTITLE Statement';
run;
quit;
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obbnote Attributes#1 'Object Heading Note Specified by the OBBNOTE Statement';
run;
quit;
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obfootn Variables#1 'Change the Global Footnote with the OBFOOTN Statement';
run;
quit;
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obanote Attributes#1 'Object Footer Note Specified by the OBANOTE Statement';
run;
quit;
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obstitle Attributes#1 'Subtitle Specified by the OBSTITLE Statement';
run;
quit;
proc document name=class;
note addnote 'Note added to the document';
run;
quit;
ods html file='your_file.html' style=Sapphire;
proc document name=class;
obpage \Contents#1\DataSet#1\Variables#1;
158
Chapter 6
•
The DOCUMENT Procedure
replay;
run;
quit;
proc document name=class;
list/ levels=all details;
dir \Contents#1\DataSet#1;
obanote Attributes#1 show;
obbnote Attributes#1
show;
obfootn Variables#1 show;
obstitle Attributes#1
show;
obtitle Attributes#1 show;
run;
quit;
ods html close;
Program Description
Open the DOCUMENT destination. The NAME= option creates an ODS document
named Class.
ods document name=class(write);
Specify a global title and footnote. The TITLE statement creates a title that is used
until you change it with another statement. The FOOTNOTE statement creates a
footnote that is used until you change it with another statement.
title 'Title Specified by the Global TITLE Statement';
footnote 'Footnote Specified by the Global FOOTNOTE Statement';
View the contents of the SAS data set. The CONTENTS procedure shows the contents
of the SAS data set Sashelp.Class.
proc contents data=sashelp.class;
run;
Close the DOCUMENT destination and create LISTING output. The entries in the
ODS document Class are used in the remainder of this example.
ods document close;
Change the global title. The OBTITLE statement assigns a new title to the Attributes#1
entry. The NAME= option specifies the current ODS document. Note that PROC
DOCUMENT is still running after the RUN statement executes. The DIR statement
changes the current path to \Contents#1\DataSet#1. The QUIT statement
terminates PROC DOCUMENT.
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obtitle Attributes#1 'Title Specified by the OBTITLE Statement';
run;
quit;
Add an object heading note to the output. The OBBNOTE statement assigns an object
heading note to the Attributes#1 entry. The NAME= option specifies the current ODS
Example 3: Managing Entries
159
document. The DIR statement changes the current directory to
\Contents#1\DataSet#1. The QUIT statement terminates PROC DOCUMENT.
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obbnote Attributes#1 'Object Heading Note Specified by the OBBNOTE Statement';
run;
quit;
Change the global footnote. The OBFOOTN statement assigns a new footnote to the
Variables#1 entry. The NAME= option specifies the current ODS document. The DIR
statement changes the current directory to \Contents#1\DataSet#1. The QUIT
statement terminates PROC DOCUMENT.
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obfootn Variables#1 'Change the Global Footnote with the OBFOOTN Statement';
run;
quit;
Add an object footer note. The OBANOTE statement assigns an object footer note to
the Attributes#1 entry. The NAME= option specifies the current ODS document. The
DIR statement changes the current directory to \Contents#1\DataSet#1. The QUIT
statement terminates PROC DOCUMENT.
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obanote Attributes#1 'Object Footer Note Specified by the OBANOTE Statement';
run;
quit;
Change the subtitle of the output. The OBSTITLE statement changes the subtitle. The
subtitle identifies the procedure that produced the output. The NAME= option specifies
the current ODS document. The DIR statement changes the current directory to
\Contents#1\DataSet#1. The QUIT statement terminates PROC DOCUMENT.
proc document name=class;
dir \Contents#1\DataSet#1;
run;
obstitle Attributes#1 'Subtitle Specified by the OBSTITLE Statement';
run;
quit;
Add a note to the document. The NOTE statement adds a note object named
ADDNOTE to the ODS document. The NAME= option specifies the current ODS
document. The LIST statement with the LEVELS=ALL option shows a list of entries in
the Class document. The QUIT statement terminates PROC DOCUMENT.
proc document name=class;
note addnote 'Note added to the document';
run;
quit;
Add a page break to the output, create HTML output, and replay Variables#1. The
ODS HTML statement opens the HTML destination and creates HTML 4.0 output. The
160
Chapter 6
•
The DOCUMENT Procedure
STYLE= option specifies that ODS use the style Sapphire. The OBPAGE statement
inserts a page break. The NAME= option specifies the current ODS document. The
REPLAY statement replays the Variables#1 object and generates output for all open
ODS destinations. The QUIT statement terminates PROC DOCUMENT.
ods html file='your_file.html' style=Sapphire;
proc document name=class;
obpage \Contents#1\DataSet#1\Variables#1;
replay;
run;
quit;
Generate a table containing contextual information for each title, footnote, and
note. The NAME= option specifies the current ODS document. The LIST statement
with the LEVELS=ALL option shows a list of entries in the Class document. The DIR
statement changes the current directory to \Contents#1\DataSet#1. The SHOW
option generates a table containing contextual information for each title, footnote, and
note. The QUIT statement terminates PROC DOCUMENT.
proc document name=class;
list/ levels=all details;
dir \Contents#1\DataSet#1;
obanote Attributes#1 show;
obbnote Attributes#1
show;
obfootn Variables#1 show;
obstitle Attributes#1
show;
obtitle Attributes#1 show;
run;
quit;
Close the HTMLdestination. The ODS HTML CLOSE statement closes the HTML
destination.
ods html close;
Example 3: Managing Entries
Output
Output 6.5 Global Title, Global Footnote, Subtitle, Object Heading Note, Object Footer Note, and Note
Output 6.6 Listing of Work.Class
161
162
Chapter 6
•
The DOCUMENT Procedure
Output 6.7 Context Tables Generated By Specifying the SHOW Option
Example 4: Listing BY-Group Entries
Features:
LIST statement options
BYGROUPS
LEVELS
LIST
PROC DOCUMENT statement option
NAME=
OBTEMPL statement
Procedure output
PROC DOCUMENT
PROC STANDARD
ODS
destinations:
DOCUMENT, HTML
Details
This example shows you how to do these tasks:
Example 4: Listing BY-Group Entries
163
•
generate PROC STANDARD output to the DOCUMENT destination
•
view the table template that describes how to display the PROC STANDARD output
•
create an ODS document
•
open an ODS document
•
list the BY-group entries in an ODS document
Program
ods document name=mydocument(write);
data score;
input Student Section Test1-Test3;
stest1=test1;
stest2=test2;
stest3=test3;
datalines;
238900545 1 94 91 87
254701167 1 95 96 97
238806445 2 91 86 94
999002527 2 80 76 78
263924860 1 92 40 85
459700886 2 75 76 80
416724915 2 66 69 72
999001230 1 82 84 80
242760674 1 75 76 70
990001252 2 51 66 91
;
run;
proc sort data=score;
by Section Student;
run;
proc standard mean=80 std=5 out=StndScore print;
by section student;
var stest1-stest3;
run;
ods document close;
proc document name=mydocument;
title "Listing of MyDocument Using the BYGROUPS Option";
run;
list/ levels=all bygroups;
run;
title "Table Template for the Output Object Standard#1";
obtempl \Standard#1\ByGroup1#1\Standard#1;
run;
quit;
Program Description
Create the ODS document MyDocument and open the DOCUMENT destination. The
ODS DOCUMENT statement with the NAME= option specified opens the ODS
164
Chapter 6
•
The DOCUMENT Procedure
document MyDocument and provides Write access as well as Read access. Note that by
default MyDocument is created in the Work library. Assign a libref to create
MyDocument in a permanent library.
ods document name=mydocument(write);
Create and sort the Score data set. This data set contains test scores for students who
took two tests and a final exam. The SORT procedure sorts the data set by the BY
variables Section and Student.
data score;
input Student Section Test1-Test3;
stest1=test1;
stest2=test2;
stest3=test3;
datalines;
238900545 1 94 91 87
254701167 1 95 96 97
238806445 2 91 86 94
999002527 2 80 76 78
263924860 1 92 40 85
459700886 2 75 76 80
416724915 2 66 69 72
999001230 1 82 84 80
242760674 1 75 76 70
990001252 2 51 66 91
;
run;
proc sort data=score;
by Section Student;
run;
Generate the standardized data and create the output data set StndScore. PROC
STANDARD uses a mean of 80 and a standard deviation of 5 to standardize the values.
OUT= identifies StndScore as the data set to contain the standardized values. The
PRINT option prints the statistics.
proc standard mean=80 std=5 out=StndScore print;
Create the standardized values for each BY group and specify the variables to
standardize. The BY statement standardizes the values separately by section number
and student ID. The VAR statement specifies the variables to standardize and their order
in the output.
by section student;
var stest1-stest3;
run;
Close the DOCUMENT destination. If the DOCUMENT destination is not closed, no
DOCUMENT procedure output can be viewed.
ods document close;
Open the ODS document MyDocument, list the entries, and view the table template
that determines how the PROC STANDARD output is displayed. The PROC
DOCUMENT statement with the NAME= option specified opens the ODS document
Work.MyDocument. The LIST statement with the LEVELS=ALL option lists detailed
Example 4: Listing BY-Group Entries
165
information about all levels of the document Work.MyDocument. The BYGROUPS
option creates columns in the list statement output for BY group information. The names
of the columns with the BY group information are the names of the BY variables,
Section and Student. The OBTEMPL statement writes the table template that is
associated with the output object Standard#1 to the HTML destination. The ODS
DOCUMENT CLOSE statement closes the DOCUMENT destination. If the
DOCUMENT destination is not closed, no DOCUMENT procedure output can be
viewed. If you omit LEVELS=ALL, then no entry list is created. This is because ODS
cannot find any BY groups at the directory level and only BY groups are listed when the
BYGROUPS option is specified.
To see what the output looks like if you omit the BYGROUPS option, see Output 6.9 on
page 166.
proc document name=mydocument;
title "Listing of MyDocument Using the BYGROUPS Option";
run;
list/ levels=all bygroups;
run;
title "Table Template for the Output Object Standard#1";
obtempl \Standard#1\ByGroup1#1\Standard#1;
run;
Terminate the DOCUMENT procedure. Specify the QUIT statement to terminate the
DOCUMENT procedure. If you omit QUIT, then you cannot view DOCUMENT
procedure output.
quit;
166
Chapter 6
•
The DOCUMENT Procedure
Output
Without the BYGROUPS option specified, there are only three columns for this output:
Obs, Path, and Type. All levels and all entries of Work.MyDocument are displayed.
Output 6.8 Listing of Work.MyDocument without the BYGROUPS Option Specified
With the BYGROUPS option specified there are now five columns. The additional
columns, named Section and Student, were created by the BYGROUPS option. The BY
variable names become the names of the columns. Only the entries containing BY group
Example 4: Listing BY-Group Entries
167
information are displayed. The entries that are directories are not displayed because they
do not contain any actual BY group information.
Output 6.9 Listing of Work.MyDocument with the BYGROUPS Option Specified
168
Chapter 6
•
The DOCUMENT Procedure
Output 6.10 Table Template Associated with PROC STANDARD Output
Example 5: Importing LISTING Output and a SAS Program
Features:
PROC DOCUMENT statement option
NAME=
IMPORT statement option
TEXTFILE=
LIST statement
REPLAY statement
Procedure output
PROC DOCUMENT
PROC GLM
ODS
destinations:
DOCUMENT, HTML, LISTING
Example 5: Importing LISTING Output and a SAS Program
169
Details
The following example uses the IMPORT TO statement to import two files into an ODS
document. The first file contains LISTING output, and the second file contains a SAS
program. The files are imported into an ODS document and then replayed to a PDF
document. In this example, the SAS program that is imported is the entire example itself,
which was saved as textfileExample.sas. Before you run this example, please save it as
textfileExample.sas.
Program
title1 'Importing a SAS Program and LISTING Output';
data one;
do month =
age = 2
age2 = 3
age3 = 4
output;
end;
run;
1
+
+
+
to 12;
0.3*rannor(345467);
0.3*rannor(345467);
0.4*rannor(345467);
ods listing file="your-file-path/odsglm.lst";
proc glm;
class month;
model age age2 age3=month / nouni; manova h=month /printe;
run;
quit;
data plants;
input type $ @;
do block=1 to 3;
input stemleng @;
output;
end;
datalines;
clarion 32.7 32.3 31.5
clinton 32.1 29.7 29.1
knox
35.7 35.9 33.1
o'neill 36.0 34.2 31.2
compost 31.8 28.0 29.2
wabash
38.2 37.8 31.9
webster 32.5 31.1 29.7
;
proc glm order=data;
class type block;
model stemleng=type block;
means type;
contrast 'compost vs others' type -1 -1 -1 -1
contrast 'river soils vs.non' type -1 -1 -1 -1
type -1 4 -1 -1
contrast 'glacial vs drift'
type -1 0 1 1
contrast 'clarion vs webster' type -1 0 0 0
contrast 'knox vs oneill'
type 0 0 1 -1
6 -1 -1;
0 5 -1,
0 0 -1;
0 0 -1;
0 0 1;
0 0 0;
170
Chapter 6
•
The DOCUMENT Procedure
quit;
ods listing close;
ods listing;
proc document name=import(write);
import textfile="your-file-path\odsglm.lst" to ^;
import textfile="your-file-path\textfileExample.sas" to ^;
list/ details;
run;
ods pdf file="out.pdf";
replay;
run;
quit;
ods pdf close;
Program Description
Add a title. The TITLE statement specifies a title.
title1 'Importing a SAS Program and LISTING Output';
Create the ONE data set.
data one;
do month =
age = 2
age2 = 3
age3 = 4
output;
end;
run;
1
+
+
+
to 12;
0.3*rannor(345467);
0.3*rannor(345467);
0.4*rannor(345467);
Create the listing file to be imported. The ODS LISTING statement creates the file
Odsglm.lst, which contains the LISTING output.
ods listing file="your-file-path/odsglm.lst";
Run the GLM procedure.
proc glm;
class month;
model age age2 age3=month / nouni; manova h=month /printe;
run;
quit;
Create the Plants data set.
data plants;
input type $ @;
do block=1 to 3;
input stemleng @;
output;
end;
Example 5: Importing LISTING Output and a SAS Program
datalines;
clarion
clinton
knox
o'neill
compost
wabash
webster
;
32.7
32.1
35.7
36.0
31.8
38.2
32.5
32.3
29.7
35.9
34.2
28.0
37.8
31.1
171
31.5
29.1
33.1
31.2
29.2
31.9
29.7
Run the GLM procedure.
proc glm order=data;
class type block;
model stemleng=type block;
means type;
contrast 'compost vs others' type -1 -1 -1 -1
contrast 'river soils vs.non' type -1 -1 -1 -1
type -1 4 -1 -1
contrast 'glacial vs drift'
type -1 0 1 1
contrast 'clarion vs webster' type -1 0 0 0
contrast 'knox vs oneill'
type 0 0 1 -1
quit;
ods listing close;
6 -1 -1;
0 5 -1,
0 0 -1;
0 0 -1;
0 0 1;
0 0 0;
Run the DOCUMENT procedure. The PROC DOCUMENT statement names the
document “Import” and opens it for Write access. The first IMPORT TO statement with
the TEXTFILE= option specified statement imports the file Odsglm.lst to the ODS
document in the current directory. The second IMPORT TO statement with the
TEXTFILE= option specified statement imports the file textfileExample.sas to the ODS
document in the current directory.
ods listing;
proc document name=import(write);
import textfile="your-file-path\odsglm.lst" to ^;
import textfile="your-file-path\textfileExample.sas" to ^;
list/ details;
run;
Replay the document to a PDF file. The REPLAY statement replays the document to
the PDF file Out.pdf.
ods pdf file="out.pdf";
replay;
run;
Terminate the DOCUMENT procedure and close the PDF destination. Specify the
QUIT statement to terminate the DOCUMENT procedure. If you omit QUIT, then you
cannot view DOCUMENT procedure output. The ODS PDF CLOSE statement closes
the PDF destination.
quit;
ods pdf close;
172
Chapter 6
•
The DOCUMENT Procedure
Output
Output 6.11
Imported LISTING Output
Example 5: Importing LISTING Output and a SAS Program
Output 6.12 Imported SAS Program
173
174
Chapter 6
•
The DOCUMENT Procedure
175
Part 4
The MSCHART Procedure
Chapter 7
(Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
176
177
Chapter 7
(Preproduction) MSCHART
Procedure
Overview: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . 177
Concepts: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . 179
A Simple MSCHART Procedure Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
About Modifying a Chart in Microsoft Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Syntax: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . .
PROC MSCHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CHARTATTRS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HCOLUMN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
KEYLEGEND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PIE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SCATTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VCOLUMN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CATEGORYAXIS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PRIMARYAXIS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SECONDARYAXIS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
182
182
186
188
189
190
192
193
195
196
199
202
Common Attribute Options for the MSCHART Procedure . . . . . . . . . . . . . . . . . . 205
Line Attribute Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Fill Attribute Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Theme Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Preset Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Examples: (Preproduction) MSCHART Procedure . . . . . . . . . . . . . . . . . . . . . . . .
Example 1: Scatter Plot with a Specified Size and Backfill . . . . . . . . . . . . . . . . . .
Example 2: Columnar Chart with a Specified Position and Border . . . . . . . . . . . .
Example 3: Combo Chart with Rotated Axis Labels . . . . . . . . . . . . . . . . . . . . . . .
Example 4: Average Miles per Gallon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
209
209
210
211
212
Overview: (Preproduction) MSCHART Procedure
The MSCHART procedure creates charts that can be opened and manipulated in
Microsoft Excel.
Note:
•
The MSCHART procedure is a new feature in the third maintenance release of
SAS 9.4. The procedure currently works only with the ODS destination for
Excel.
178
Chapter 7
•
(Preproduction) MSCHART Procedure
•
MSCHART is a preproduction procedure. A preproduction feature is a
preliminary release of software that has not completed full development, testing,
and documentation. Because it has not been fully tested, preproduction software
should be used with care. After final testing is completed, preproduction software
is likely to be offered in a future release as production-quality software.
You can use the MSCHART procedure with the ODS destination for Excel to generate a
Microsoft Excel spreadsheet that contains one or more data tables and charts. The
following figure shows an example of an Excel spreadsheet with one table and one chart.
Figure 7.1 Example Output in Microsoft Excel
For the code for this example, see “Example 2: Columnar Chart with a Specified
Position and Border” on page 210.
TIP
Procedure output is tightly integrated with Microsoft Excel output in the spreadsheet.
The graph behaves like a native Excel element and can be edited like any other Excel
chart. For more information, see “About Modifying a Chart in Microsoft Excel” on page
181.
Other procedures can also be used with the ODS destination for Excel to generate graphs
in Excel. For example, the ODS Graphics Procedures can generate graphic output in
Excel. However, those procedures create a static image of the graph inserted into the
spreadsheet. The embedded graphic does not react to any changes to the data.
Note: The MSCHART procedure is not related to ODS Graphics and is not affected by
the ODS GRAPHICS statement.
See Also
SAS ODS Graphics: Procedures Guide
Concepts: (Preproduction) MSCHART Procedure
179
Concepts: (Preproduction) MSCHART Procedure
A Simple MSCHART Procedure Program
The following sample program identifies the basic parts of a simple MSCHART
procedure program.
Figure 7.2 Simple MSCHART Procedure Program
1
specifies a title using the TITLE global SAS statement.
This option relies on the (default) GTITLE option in the ODS EXCEL statement.
You are limited to one title. Footnotes are not supported.
2
closes all open ODS destinations and opens the ODS destination for Excel. You can
also specify a filename in the ODS EXCEL statement, as shown in the example.
Note: You are not required to close all ODS destinations in order to run the
MSCHART procedure. However, the ODS destination for Excel must be open.
3
issues the PROC MSCHART statement and specifies the data set and a category
variable. You can also specify options for the graph. For example, you can specify
the height, width, or both.
4
specifies one or more chart statements. You can also specify options for the charts.
In addition to chart statements, statements are available to control legend attributes,
axis attributes, and the general appearance of the graph.
5
closes the ODS destination for Excel. You must close the destination before the
Excel file is written to your system.
Note:
6
•
You can run several consecutive procedure blocks without closing the ODS
destination for Excel until the end of the last block. In that case, the output
for all the procedure blocks appears in a single tabbed Excel file.
•
At this point in the program, no ODS destinations are open. You must open a
destination before you can run another procedure that uses ODS.
resets the title to blank.
180
Chapter 7
•
(Preproduction) MSCHART Procedure
Basic Concepts
Output File
Charts created using the MSCHART procedure are written to a Microsoft Excel
spreadsheet.
The ODS destination for Excel must be open when you run the MSCHART procedure.
In addition, you must close the ODS destination for Excel before the output chart is
written to an Excel file.
By default, the output file is named sasexcl.xlsx. Subsequent MSCHART procedure
blocks overwrite that filename.
You can specify a name and location for the Excel file in the ODS EXCEL statement by
using the FILE= option, as shown here:
ods excel file="myOutput.xlsx";
ods excel file="c:\myPath\myOutput.xlsx";
By default in the SAS windowing environment, the output file is written to the current
SAS working directory. The SAS current directory is the same directory in which you
start your SAS session. If you are running SAS in the Windows operating system, then
the current directory is displayed in the status bar at the bottom of the main SAS
window.
In SAS Studio, depending on your deployment, the output is written to your home
directory or to another working directory. If you do not have Write permission for the
default working directory, you must specify an output directory. You can then download
and open the file from the specified directory.
In SAS Studio, you can use the macro &_SASWS_ to specify your home
directory. For example, you might specify FILE="&_SASWS_/
myOutput.xlsx".For information about customizing the SAS Studio output
environment, see “SAS Studio and ODS” in SAS Output Delivery System: User's
Guide. For instructions about using SAS Studio, see the SAS Studio: User's Guide.
TIP
You can run several consecutive MSCHART procedure blocks without closing the ODS
destination for Excel until the end of the last block. In that case, the output for all the
procedure blocks appears in a single tabbed Excel file.
Multiple Charts in a Graph
The procedure can contain more than one chart statement. Combining chart types
produces what Excel calls a combo chart, as shown here.
Concepts: (Preproduction) MSCHART Procedure
181
For the code for this example, see “Example 3: Combo Chart with Rotated Axis
Labels” on page 211.
TIP
Some combinations are not supported. For example, you cannot combine a columnar
chart with a pie chart. In that case, only the pie chart is generated, and a message is
written to the SAS log.
You can also have multiple statements for the same chart type.
The following example creates a series of two horizontal columns clustered together.
Each column has a different response variable.
ods _all_ close;
ods excel;
proc mschart data=sashelp.class category=name;
hcolumn height;
hcolumn weight;
run;
ods excel close;
Note: For information about specifying an output directory, see “Output File” on page
180.
Figure 7.3 Series of Two Horizontal Columns
About Modifying a Chart in Microsoft Excel
After you run the MSCHART procedure, the output Excel file contains one or more data
tables along with one or more charts.
182
Chapter 7
•
(Preproduction) MSCHART Procedure
You can modify the chart as you would any chart created in Microsoft Excel. For
example, you can filter the chart and apply a different style. You can also change the
type of chart. For example, if the original chart was a scatter plot, you might change it to
a bar chart.
In addition, if you make changes to the data table in Excel, those changes are reflected in
the chart.
Note: When you modify a chart in Excel, your changes have no effect on the original
data set used to produce the chart.
There are numerous ways to modify charts in Excel. For more information, see the Excel
documentation.
Syntax: (Preproduction) MSCHART Procedure
Restrictions:
At least one chart statement is required.
The procedure works only with the ODS destination for Excel. If other destinations
are specified, they are ignored. See “ODS EXCEL Statement ” in SAS Output
Delivery System: User's Guide.
Note:
MSCHART is a preproduction procedure that is new in the third maintenance release
of SAS 9.4. For more information, see Overview: (Preproduction) MSCHART
Procedure on page 177.
PROC MSCHART DATA=input-data-set CATEGORY=variable <option(s)>;
CHARTATTRS <option(s)>;
HCOLUMN numeric-variable </option(s)>;
KEYLEGEND <option(s)>;
LINE numeric-variable </option(s)>;
PIE numeric-variable </option(s)>;
SCATTER numeric-variable </option(s)>;
VCOLUMN numeric-variable </option(s)>;
CATEGORYAXIS <option(s)>;
PRIMARYAXIS <option(s)>;
SECONDARYAXIS <option(s)>;
PROC MSCHART Statement
Identifies the data set that contains the chart variables and specifies the category variable.
Requirement:
An input data set and a category variable are required.
Syntax
PROC MSCHART DATA=input-data-set CATEGORY=variable <options> ;
Summary of Optional Arguments
Appearance options
PROC MSCHART Statement
183
BARGAP=size
specifies the area between clustered category bars.
HEIGHT=dimension<units>
specifies the height of the graph.
LOCK_ASPECT
locks the aspect ratio when either the HEIGHT= or the WIDTH= option is
specified.
POSITION=“position-option”
specifies the position of the upper left corner of the chart in the Microsoft
Excel spreadsheet.
STACK
stacks the contents of the graph area.
STACK100
stacks the contents of the graph area while scaling all graphics elements to
100%.
WIDTH=dimension<units>
specifies the width of the graph.
Chart options
ALT_DESCRIPTION="text-string"
specifies the alternate description for the output image.
ALT_TEXT="text-string"
specifies the alternate text for the output image.
DESCRIPTION=“text-string”
specifies a description for the output image.
Legend options
NOAUTOLEGEND
disables the generation of automatic legends.
Required Arguments
DATA=input-data-set
specifies the SAS data set that contains the variables to process.
CATEGORY=category-variable
specifies the variable whose values determine the categories of data represented by
the chart. The variable generates the midpoints to which each observation in the data
set contributes.
Restriction
When a scatter plot is specified in the procedure, the category variable
must be numeric.
Optional Arguments
ALT_DESCRIPTION="text-string"
specifies the alternate description for the output image.
ALT_TEXT="text-string"
specifies the alternate text for the output image.
BARGAP=size
specifies the area between clustered category bars. The size of the gap is specified as
a percentage of the bar width.
184
Chapter 7
•
(Preproduction) MSCHART Procedure
Default
150
Range
0 to 500
Interaction
This option applies to the HCOLUMN and VCOLUMN statements.
Note
You can include a percent (%) symbol after the size, but it is not
required.
DESCRIPTION=“text-string”
specifies a description for the output image.
Default
The default description is “The MSCHART Procedure”.
Tip
The name of the output file is specified by the FILE= option in the ODS
EXCEL statement.
HEIGHT=dimension<units>
specifies the height of the graph. When you specify the height, you can also provide
the unit of measure. The default units for dimension are inches. If you want to
specify values in other units, then you must specify the desired units with the value.
For a list of measurement units that are supported, see “dimension” on page 519.
Default
3in
Tips
You can specify the width using the WIDTH= option.
You can lock the aspect ratio using the LOCK_ASPECT option.
LOCK_ASPECT
locks the aspect ratio when either the HEIGHT= or the WIDTH= option is specified.
NOAUTOLEGEND
disables the generation of automatic legends. By default, legends are created
automatically for pie charts and for any graph that contains more than one series
variable.
POSITION=“position-option”
specifies the position of the upper left corner of the chart in the Microsoft Excel
spreadsheet. The specified position must be enclosed in quotation marks. “positionoption” specifies a position using one of the following formats:
“cell-reference”
cell-reference is an Excel cell reference in A1 format. The reference can be
relative, absolute, or mixed.
•
Relative references are relative to the upper left corner of the data cells from
which the chart is made.
For example, POSITION=“E11” positions the upper left corner of the chart 5
columns to the right and 11 rows down from the upper left corner of the data
cells. POSITION=“C5” means 3 columns to the right and 5 rows down. If the
Excel tagset’s START_AT= option (or some other option) is used to move the
data cells, the chart maintains its position relative to the data cells.
•
Absolute references have the form “$A$1”. An absolute reference ignores the
data cells and always positions the upper left corner of the chart in the upper
left corner of the specified cell. If the data cells start at A1, then there is no
difference between an absolute and a relative reference.
PROC MSCHART Statement
•
185
Mixed references omit the $ from either the row number or the column letter.
For example, $E11 means absolute column E, 11 rows down from the top of
the data cells. The reference E$11 means 5 columns to the right of the upper
left corner of the data cells, absolute row 11.
Example
position="e11"
“corner”
corner references the position of the chart with respect to the data cells. The
upper left corner of the chart is positioned adjacent to the specified corner of the
data cells. corner can be one of the following:
•
TOPLEFT overlays the chart over the data cells.
•
TOPRIGHT positions the chart immediately to the right of the data cells.
•
BOTTOMLEFT positions the chart immediately below the data cells.
•
BOTTOMRIGHT positions the chart below and to the right of the data cells.
Example
position="bottomright"
“corner (R1C1)”
positions the chart relative to the specified corner using Excel R1C1 notation.
The upper left corner of the chart is positioned by the specified number of rows
and columns relative to the corner. (See the previous position option for a
description of corner.)
This format enables negative offsets. For example, R[2]C[3] means 2 rows down
and 3 columns to the right. R[-2]C[-3] means 2 rows up and 3 columns to the
left.
In this format, row and column numbers enclosed in brackets are relative. Those
not in brackets are absolute. When you specify absolute values, the corner
specification is ignored.
Example
position="topright(r[2]c[3])"
“(R1C1)”
positions the chart relative to the upper left cell in the spreadsheet ($A$1).
Row and column numbers enclosed in brackets are relative. Those not in brackets
are absolute. This option is most useful when the cell reference is absolute.
Example
position="(r8c15)"
Default
POSITION=“BOTTOMLEFT”. By default, the chart is positioned
immediately after the data cells and aligned with the left side of the data
cells.
Notes
If you specify “(RC)” or “corner (RC)”, the ODS destination for Excel
changes the RC value to R[0]C[0]. R[0]C[0] is a relative cell reference for
zero columns to the right and zero rows down. Specifying
POSITION=“TOPRIGHT (RC)” has the same effect as specifying
POSITION=“TOPRIGHT”.
When positioning the chart below the data cells, if the number of data cells
is sufficiently large, then the chart might be hidden until the Excel user
scrolls to it.
186
Chapter 7
•
(Preproduction) MSCHART Procedure
STACK
stacks the contents of the graph area.
STACK100
stacks the contents of the graph area while scaling all graphics elements to 100%.
WIDTH=dimension<units>
specifies the width of the graph. When you specify the width, you can also provide
the unit of measure. The default units for dimension are inches. If you want to
specify values in other units, then you must specify the desired units with the value.
For a list of measurement units that are supported, see “dimension” on page 519.
Default
5in
Tips
You can specify the height using the HEIGHT= option.
You can lock the aspect ratio using the LOCK_ASPECT option.
CHARTATTRS Statement
Specifies attributes for a chart. The statement enables you to modify the border, background fill, wall, and
so on, within the procedure.
Syntax
CHARTATTRS <options> ;
Summary of Optional Arguments
Appearance options
BACKFILLATTRS =(fill-options)
specifies the fill attributes for the chart area.
BORDERATTRS=(line-options)
specifies the border attributes for the chart area.
GRIDLINEATTRS=(line-options)
specifies the line attributes for the grid lines.
NOBACKFILL
removes the fill attributes from the chart area.
NOBORDER
removes the border from the chart.
NOGRIDLINE
removes the grid lines from the data area.
NOWALL
removes the data area attributes.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the chart.
WALLATTRS =(options)
specifies the fill and border attributes for the data area.
CHARTATTRS Statement
187
Optional Arguments
BACKFILLATTRS =(fill-options)
specifies the fill attributes for the chart area. For a description of the fill-options, see
“Fill Attribute Options” on page 206.
Example
backfillattrs=(solid_color=background2 transparency=80)
BORDERATTRS=(line-options)
specifies the border attributes for the chart area. For a description of the line-options,
see “Line Attribute Options” on page 205.
Examples
borderattrs=(type=solid solid_color=red transparency=50)
borderattrs=(dash_type=round_dot cap_type=flat)
GRIDLINEATTRS=(line-options)
specifies the line attributes for the grid lines. For a description of the line-options,
see “Line Attribute Options” on page 205.
Tip
Use the NOGRIDLINE option to hide the grid lines.
NOBACKFILL
removes the fill attributes from the chart area.
NOBORDER
removes the border from the chart.
NOGRIDLINE
removes the grid lines from the data area.
NOWALL
removes the data area attributes.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the chart. options
can be one or more of the following:
BORDERATTRS=(line-options)
specifies the border attributes.
For a description of the line-options, see “Line Attribute Options” on page 205.
FILLATTRS=(fill-options)
specifies the fill attributes.
For a description of the fill-options, see “Fill Attribute Options” on page 206.
NOAUTOFIT
does not automatically fit the title.
NOBORDER
removes the border from the title area.
NOFILL
removes the fill attributes from the title area.
NOROTATE | ROTATE=degrees
specifies the rotation for the title.
NOWRAP
disables wrapping for the title.
188
Chapter 7
•
(Preproduction) MSCHART Procedure
STACK_TEXT=LEFTTORIGHT | RIGHTTOLEFT
specifies how the title text is stacked.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the title.
Examples
titleattrs=(fillattrs=(type=gradient preset_gradients=early_sunset))
titleattrs=(borderattrs=(width=4pt dash_type=long_dash))
WALLATTRS =(options)
specifies the fill and border attributes for the data area. options can be one or more of
the following:
BORDERATTRS=(line-options)
specifies the line attributes for the wall border.
For a description of the line-options, see “Line Attribute Options” on page 205.
NOBORDER
removes the border from the data area of the graph.
fill-options
are various options that are available for the wall fill.
For a description of the fill-options, see “Fill Attribute Options” on page 206.
Examples
wallattrs=(type=gradient preset_gradients=nightfall);
wallattrs=(type=solid solid_color=red transparency=50
borderattrs=(dash_type=long_dash))
HCOLUMN Statement
Creates a horizontal columnar chart.
Syntax
HCOLUMN numeric-variable </option(s)>;
Summary of Optional Arguments
Appearance options
BORDERATTRS=(line-options)
specifies the border attributes for the bars.
FILLATTRS=(fill-options)
specifies the fill attributes for the bars.
NOBORDER
removes the border from the bars.
NOFILL
removes the fill from the bars.
Axis options
KEYLEGEND Statement
189
SECONDARY
assigns the response variable to the secondary (top) horizontal axis.
Required Argument
numeric-variable
specifies the variable to use for the graphical columns. The variable generates the
midpoints to which each observation in the data set contributes.
Optional Arguments
BORDERATTRS=(line-options)
specifies the border attributes for the bars. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
borderattrs=(type=solid solid_color=red transparency=50)
borderattrs=(dash_type=round_dot cap_type=flat)
FILLATTRS=(fill-options)
specifies the fill attributes for the bars. For a description of the fill-options, see “Fill
Attribute Options” on page 206.
Examples
fillattrs=(type=solid solid_color=accent1 transparency=50)
fillattrs=(type=gradient preset_gradients=early_sunset)
NOBORDER
removes the border from the bars.
NOFILL
removes the fill from the bars.
SECONDARY
assigns the response variable to the secondary (top) horizontal axis.
KEYLEGEND Statement
Adds or modifies the chart legend.
Syntax
KEYLEGEND <option(s)>;
Summary of Optional Arguments
Appearance options
BORDERATTRS=(line-options)
specifies the border attributes for the legend.
FILLATTRS=(fill-options)
specifies the fill attributes for the legend.
NOBORDER
removes the border from the legend.
190
Chapter 7
•
(Preproduction) MSCHART Procedure
NOFILL
removes the fill from the legend.
POSITION=TOP | BOTTOM | LEFT | RIGHT | TOP_RIGHT
specifies the position of the legend.
Optional Arguments
BORDERATTRS=(line-options)
specifies the border attributes for the legend. For a description of the line-options,
see “Line Attribute Options” on page 205.
Examples
borderattrs=(type=solid solid_color=red transparency=50)
borderattrs=(dash_type=round_dot cap_type=flat)
FILLATTRS=(fill-options)
specifies the fill attributes for the legend. For a description of the fill-options, see
“Fill Attribute Options” on page 206.
Examples
fillattrs=(type=solid solid_color=accent1 transparency=50)
fillattrs=(type=gradient preset_gradients=early_sunset)
NOBORDER
removes the border from the legend.
Default
NOBORDER
NOFILL
removes the fill from the legend.
Default
NOFILL
POSITION=TOP | BOTTOM | LEFT | RIGHT | TOP_RIGHT
specifies the position of the legend.
LINE Statement
Creates a line plot.
Syntax
LINE numeric-variable </option(s)>;
Summary of Optional Arguments
Appearance options
LINEATTRS=(line-options)
specifies the attributes for the lines.
MARKER_SIZE=positive-number
specifies the size of the markers, if displayed.
MARKERBORDERATTRS=(line-options)
specifies the outline attributes for the markers, if displayed.
LINE Statement
191
MARKERFILLATTRS=(fill-options)
specifies the fill attributes for the markers, if displayed.
MARKERS=symbol
adds markers to the chart and specifies the marker symbol.
NOMARKERBORDER
removes the border from the markers.
NOMARKERFILL
removes the fill from the markers.
SMOOTH
specifies that a smoothed line passes through all vertices.
Axis options
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
Required Argument
numeric-variable
specifies the variable to use for the plot.
Optional Arguments
LINEATTRS=(line-options)
specifies the attributes for the lines. For a description of the line-options, see “Line
Attribute Options” on page 205.
Examples
lineattrs=(type=solid solid_color=red transparency=50)
lineattrs=(dash_type=round_dot cap_type=flat)
MARKER_SIZE=positive-number
specifies the size of the markers, if displayed.
Default
5
Range
2 to 72
Interaction
The MARKERS= option must be specified for this option to have any
effect.
Note
The unit of measure is points.
MARKERBORDERATTRS=(line-options)
specifies the outline attributes for the markers, if displayed. For a description of the
line-options, see “Line Attribute Options” on page 205.
Interactions
The MARKERS= option must be specified for this option to have any
effect.
This option has no effect if NOMARKERBORDER is specified.
Examples
markerborderattrs=(type=solid solid_color=red transparency=50)
markerborderattrs=(dash_type=round_dot cap_type=flat)
192
Chapter 7
•
(Preproduction) MSCHART Procedure
MARKERFILLATTRS=(fill-options)
specifies the fill attributes for the markers, if displayed. For a description of the filloptions, see “Fill Attribute Options” on page 206.
Interactions
The MARKERS= option must be specified for this option to have any
effect.
This option has no effect if NOMARKERFILL is specified.
Examples
markerfillattrs=(type=solid solid_color=accent1 transparency=50)
markerfillattrs=(type=gradient preset_gradients=early_sunset)
MARKERS=symbol
adds markers to the chart and specifies the marker symbol. symbol can be one of the
following:
Circle
Dash
Diamond
Plus
Short_Dash
Star
Triangle
X
NOMARKERBORDER
removes the border from the markers.
NOMARKERFILL
removes the fill from the markers.
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
SMOOTH
specifies that a smoothed line passes through all vertices.
PIE Statement
Creates a pie chart.
Syntax
PIE numeric-variable </ option(s)>;
Summary of Optional Arguments
Appearance options
BORDERATTRS=(line-options)
specifies the border attributes for the pie.
FILLATTRS=(fill-options)
specifies the fill attributes for the pie.
NOBORDER
removes the border from the pie.
NOFILL
removes the fill from the pie.
SCATTER Statement
193
Required Argument
numeric-variable
specifies the variable to use for the pie chart.
Optional Arguments
BORDERATTRS=(line-options)
specifies the border attributes for the pie. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
borderattrs=(type=solid solid_color=red transparency=50)
borderattrs=(dash_type=round_dot cap_type=flat)
FILLATTRS=(fill-options)
specifies the fill attributes for the pie. For a description of the fill-options, see “Fill
Attribute Options” on page 206.
Examples
fillattrs=(type=solid solid_color=accent1 transparency=50)
fillattrs=(type=gradient preset_gradients=early_sunset)
NOBORDER
removes the border from the pie.
NOFILL
removes the fill from the pie.
SCATTER Statement
Creates a scatter plot.
Syntax
SCATTER numeric-variable </option(s)>;
Summary of Optional Arguments
Appearance options
CONNECT<=SMOOTH | STRAIGHT>
connects the markers with a line.
LINEATTRS=(line-options)
specifies the line attributes for the connect lines in the scatter plot.
MARKER_SIZE=positive-number
specifies the size of the markers.
MARKERBORDERATTRS=(line-options)
specifies the outline attributes for the markers.
MARKERFILLATTRS=(fill-options)
specifies the fill attributes for the markers.
MARKERS=symbol
specifies the marker symbol.
194
Chapter 7
•
(Preproduction) MSCHART Procedure
NOMARKERBORDER
removes the border from the markers.
NOMARKERFILL
removes the fill from the markers.
Axis options
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
Required Argument
numeric-variable
specifies the variable to use for the Y axis of the scatter plot.
Note: Both this variable and the category variable that you specify in the PROC
MSCHART statement must be numeric.
Optional Arguments
CONNECT<=SMOOTH | STRAIGHT>
connects the markers with a line. When you specify this option, you can also specify
the type of line to be drawn, either a smooth line or a straight line. If you do not
specify the type of line, a straight line is drawn by default.
Default
When the option is not specified, no line is drawn.
LINEATTRS=(line-options)
specifies the line attributes for the connect lines in the scatter plot. For a description
of the line-options, see “Line Attribute Options” on page 205.
Interaction
This option has no effect unless the CONNECT option is specified.
Examples
lineattrs=(type=solid solid_color=red transparency=50)
lineattrs=(dash_type=round_dot cap_type=flat)
MARKER_SIZE=positive-number
specifies the size of the markers.
Default
5
Range
2 to 72
Note
The unit of measure is points.
MARKERBORDERATTRS=(line-options)
specifies the outline attributes for the markers. For a description of the line-options,
see “Line Attribute Options” on page 205.
Interaction
This option has no effect if NOMARKERBORDER is specified.
Examples
markerborderattrs=(type=solid solid_color=red transparency=50)
markerborderattrs=(dash_type=round_dot cap_type=flat)
MARKERFILLATTRS=(fill-options)
specifies the fill attributes for the markers. For a description of the fill-options, see
“Fill Attribute Options” on page 206.
VCOLUMN Statement
195
Interaction
This option has no effect if NOMARKERFILL is specified.
Examples
markerfillattrs=(type=solid solid_color=accent1 transparency=50)
markerfillattrs=(type=gradient preset_gradients=early_sunset)
MARKERS=symbol
specifies the marker symbol. symbol can be one of the following:
Circle
Dash
Diamond
Plus
Short_Dash
Star
Triangle
X
NOMARKERBORDER
removes the border from the markers.
NOMARKERFILL
removes the fill from the markers.
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
VCOLUMN Statement
Creates a vertical columnar chart.
Syntax
VCOLUMN numeric-variable </option(s)>;
Summary of Optional Arguments
Appearance options
BORDERATTRS=(line-options)
specifies the border attributes for the bars.
FILLATTRS=(fill-options)
specifies the fill attributes for the bars.
NOBORDER
removes the border from the bars.
NOFILL
removes the fill from the bars.
Axis options
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
Required Argument
numeric-variable
specifies the variable to use for the graphical columns.
196
Chapter 7
•
(Preproduction) MSCHART Procedure
Optional Arguments
BORDERATTRS=(line-options)
specifies the border attributes for the bars. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
borderattrs=(type=solid solid_color=red transparency=50)
borderattrs=(dash_type=round_dot cap_type=flat)
FILLATTRS=(fill-options)
specifies the fill attributes for the bars. For a description of the fill-options, see “Fill
Attribute Options” on page 206.
Examples
fillattrs=(type=solid solid_color=accent1 transparency=50)
fillattrs=(type=gradient preset_gradients=early_sunset)
NOBORDER
removes the border from the bars.
NOFILL
removes the fill from the bars.
SECONDARY
assigns the response variable to the secondary (right) vertical axis.
CATEGORYAXIS Statement
Specifies the axis options for the category axis.
Syntax
CATEGORYAXIS <option(s)>;
Summary of Optional Arguments
Appearance options
LABEL_OFFSET=numeric-value
specifies an offset for the axis label.
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
LINEATTRS=(line-options)
specifies the attributes for the axis line.
MAJOR
displays the major tick marks.
MINOR
displays the minor tick marks.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
TITLE <=variable>
CATEGORYAXIS Statement 197
displays a title for the axis.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis.
TYPE= DATE | TEXT
specifies the type of axis.
Axis options
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis.
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks
with respect to the axis.
REVERSE
reverses the axis.
TICK_INTERVAL=numeric-value
specifies the interval for the axis tick marks.
Text options
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values.
NOWRAP
disables wrapping for the axis values.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
Optional Arguments
LABEL_OFFSET=numeric-value
specifies an offset for the axis label.
Default
100
Range
0 to 1000
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
Default
ADJACENT
LINEATTRS=(line-options)
specifies the attributes for the axis line. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
lineattrs=(type=solid solid_color=red)
lineattrs=(dash_type=round_dot cap_type=flat)
MAJOR
displays the major tick marks.
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis. Specifying
MAJOR_TICKS=NONE removes the major tick marks from the axis.
198
Chapter 7
•
(Preproduction) MSCHART Procedure
MINOR
displays the minor tick marks.
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks with
respect to the axis.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values. You can specify either of the following:
NOROTATE
turns off rotation.
ROTATE=degrees
specifies the degree of rotation.
NOWRAP
disables wrapping for the axis values.
REVERSE
reverses the axis.
TICK_INTERVAL=numeric-value
specifies the interval for the axis tick marks.
Default
1
Range
1 to 31999
TITLE <=variable>
displays a title for the axis. When specifying this option, you can also specify a
variable to use for the title.
Defaults
Without this option, no title is displayed
When the option is specified with no variable, the default title is the
category variable label. If the category variable has no label, then the
variable name is used.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis. options
can be one or more of the following:
BORDERATTRS=(line-options)
specifies the border attributes.
For a description of the line-options, see “Line Attribute Options” on page 205.
FILLATTRS=(fill-options)
specifies the fill attributes.
For a description of the fill-options, see “Fill Attribute Options” on page 206.
NOAUTOFIT
does not automatically fit the title.
NOBORDER
removes the border from the title area.
PRIMARYAXIS Statement
199
NOFILL
removes the fill attributes from the title area.
NOROTATE | ROTATE=degrees
specifies the rotation for the title.
NOWRAP
disables wrapping for the title.
STACK_TEXT=LEFTTORIGHT | RIGHTTOLEFT
specifies how the title text is stacked.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the title.
Examples
titleattrs=(fillattrs=(type=gradient preset_gradients=early_sunset))
titleattrs=(borderattrs=(width=4pt dash_type=long_dash))
TYPE= DATE | TEXT
specifies the type of axis.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
PRIMARYAXIS Statement
Specifies the axis options for the primary axis.
Syntax
PRIMARYAXIS <option(s)>;
Summary of Optional Arguments
Appearance options
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
LINEATTRS=(line-options)
specifies the attributes for the axis line.
MAJOR
displays the major tick marks.
MINOR
displays the minor tick marks.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
SHOW_DISPLAY_UNITS
displays the units of measure along the axis.
TITLE <=variable>
200
Chapter 7
•
(Preproduction) MSCHART Procedure
displays a title for the axis.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis.
Axis options
DISPLAY_UNITS=units
specifies the units of measure to use for the axis.
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis.
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks
with respect to the axis.
REVERSE
reverses the axis.
Text options
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values.
NOWRAP
disables wrapping for the axis values.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
Optional Arguments
DISPLAY_UNITS=units
specifies the units of measure to use for the axis. units can be one of the following:
NONE
HUNDREDS
THOUSANDS
TEN_THOUSANDS
Tip
HUNDRED_THOUSANDS
MILLIONS
TEN_MILLIONS
HUNDRED_MILLIONS
BILLIONS
TRILLIONS
Specify SHOW_DISPLAY_UNITS to display the units on the axis.
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
Default
ADJACENT
LINEATTRS=(line-options)
specifies the attributes for the axis line. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
lineattrs=(type=solid solid_color=red)
lineattrs=(dash_type=round_dot cap_type=flat)
MAJOR
displays the major tick marks.
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis. Specifying
MAJOR_TICKS=NONE removes the major tick marks from the axis.
PRIMARYAXIS Statement
201
MINOR
displays the minor tick marks.
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks with
respect to the axis.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values. You can specify either of the following:
NOROTATE
turns off rotation.
ROTATE=degrees
specifies the degree of rotation.
NOWRAP
disables wrapping for the axis values.
REVERSE
reverses the axis.
SHOW_DISPLAY_UNITS
displays the units of measure along the axis.
Interaction
The DISPLAY_UNITS= option must be specified for this option to
have any effect.
TITLE <=variable>
displays a title for the axis. When specifying this option, you can also specify a
variable to use for the title.
Defaults
Without this option, no title is displayed
When the option is specified with no variable, the default title is the
response variable label. If the response variable has no label, then the
variable name is used.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis. options
can be one or more of the following:
BORDERATTRS=(line-options)
specifies the border attributes.
For a description of the line-options, see “Line Attribute Options” on page 205.
FILLATTRS=(fill-options)
specifies the fill attributes.
For a description of the fill-options, see “Fill Attribute Options” on page 206.
NOAUTOFIT
does not automatically fit the title.
NOBORDER
removes the border from the title area.
202
Chapter 7
•
(Preproduction) MSCHART Procedure
NOFILL
removes the fill attributes from the title area.
NOROTATE | ROTATE=degrees
specifies the rotation for the title.
NOWRAP
disables wrapping for the title.
STACK_TEXT=LEFTTORIGHT | RIGHTTOLEFT
specifies how the title text is stacked.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the title.
Examples
titleattrs=(fillattrs=(type=gradient preset_gradients=early_sunset))
titleattrs=(borderattrs=(width=4pt dash_type=long_dash))
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
SECONDARYAXIS Statement
Specifies the axis options for the secondary axis.
Syntax
SECONDARYAXIS <option(s)>;
Summary of Optional Arguments
Appearance options
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
LINEATTRS=(line-options)
specifies the attributes for the axis line.
MAJOR
displays the major tick marks.
MINOR
displays the minor tick marks.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
SHOW_DISPLAY_UNITS
displays the units of measure along the axis.
TITLE <=variable>
displays a title for the axis.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis.
SECONDARYAXIS Statement 203
Axis options
DISPLAY_UNITS=units
specifies the units of measure to use for the axis.
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis.
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks
with respect to the axis.
REVERSE
reverses the axis.
Text options
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values.
NOWRAP
disables wrapping for the axis values.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
Optional Arguments
DISPLAY_UNITS=units
specifies the units of measure to use for the axis. units can be one of the following:
NONE
HUNDREDS
THOUSANDS
TEN_THOUSANDS
Tip
HUNDRED_THOUSANDS
MILLIONS
TEN_MILLIONS
HUNDRED_MILLIONS
BILLIONS
TRILLIONS
Specify SHOW_DISPLAY_UNITS to display the units on the axis.
LABEL_POSITION=HIGH | LOW | ADJACENT
specifies the position of the axis label.
Default
ADJACENT
LINEATTRS=(line-options)
specifies the attributes for the axis line. For a description of the line-options, see
“Line Attribute Options” on page 205.
Examples
lineattrs=(type=solid solid_color=red)
lineattrs=(dash_type=round_dot cap_type=flat)
MAJOR
displays the major tick marks.
MAJOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
specifies the position of the major tick marks with respect to the axis. Specifying
MAJOR_TICKS=NONE removes the major tick marks from the axis.
MINOR
displays the minor tick marks.
204
Chapter 7
•
(Preproduction) MSCHART Procedure
MINOR_TICKS=NONE | INSIDE | OUTSIDE | CROSS
displays the minor tick marks and specifies the position of the tick marks with
respect to the axis.
NOLABEL
removes the labels from the axis.
NOLINE
removes the axis line.
NOROTATE | ROTATE=degrees
specifies the rotation for the axis values. You can specify either of the following:
NOROTATE
turns off rotation.
ROTATE=degrees
specifies the degree of rotation.
NOWRAP
disables wrapping for the axis values.
REVERSE
reverses the axis.
SHOW_DISPLAY_UNITS
displays the units of measure along the axis.
Interaction
The DISPLAY_UNITS= option must be specified for this option to
have any effect.
TITLE <=variable>
displays a title for the axis. When specifying this option, you can also specify a
variable to use for the title.
Defaults
Without this option, no title is displayed
When the option is specified with no variable, the default title is the
response variable label. If the response variable has no label, then the
variable name is used.
TITLEATTRS=(options)
specifies the attributes for the title area when a title is specified for the axis. options
can be one or more of the following:
BORDERATTRS=(line-options)
specifies the border attributes.
For a description of the line-options, see “Line Attribute Options” on page 205.
FILLATTRS=(fill-options)
specifies the fill attributes.
For a description of the fill-options, see “Fill Attribute Options” on page 206.
NOAUTOFIT
does not automatically fit the title.
NOBORDER
removes the border from the title area.
NOFILL
removes the fill attributes from the title area.
Common Attribute Options for the MSCHART Procedure
205
NOROTATE | ROTATE=degrees
specifies the rotation for the title.
NOWRAP
disables wrapping for the title.
STACK_TEXT=LEFTTORIGHT | RIGHTTOLEFT
specifies how the title text is stacked.
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the title.
Examples
titleattrs=(fillattrs=(type=gradient preset_gradients=early_sunset))
titleattrs=(borderattrs=(width=4pt dash_type=long_dash))
VERTICAL_ALIGNMENT=TOP | MIDDLE | BOTTOM | TOP_CENTER |
MIDDLE_CENTER | BOTTOM_CENTER
specifies the vertical alignment of the axis values.
Common Attribute Options for the MSCHART
Procedure
Line Attribute Options
Attribute options are available for line graphics elements, such as the graph border and
line plots.
Here are two usage examples:
lineattrs=(type=solid solid_color=red transparency=50)
lineattrs=(dash_type=round_dot cap_type=flat)
AUTO_COLOR=color | theme-color
specifies that the system determines the color. This option is used by default unless
SOLID_COLOR= is specified.
You can specify colors using a number of different color-naming schemes.
If you want to specify a theme color, see “Theme Colors” on page 207.
Default
Accent1 theme color
CAP_TYPE=FLAT | ROUND | SQUARE
specifies the cap shape.
Default
ROUND
DASH_TYPE=option
specifies the dash type for the lines.
option can be one of the following attributes:
DASH
DASH_DOT
LONG_DASH
LONG_DASH_DOT
LONG_DASH_DOT_DOT
ROUND_DOT
SOLID
SQUARE_DOT
206
Chapter 7
•
(Preproduction) MSCHART Procedure
Default
SOLID
JOIN_TYPE=BEVEL | MITER | ROUND
specifies the join type.
Default
ROUND
SOLID_COLOR=color | theme-color
specifies the color when TYPE=SOLID. You can specify colors using a number of
different color-naming schemes.
If you want to specify a theme color, see “Theme Colors” on page 207.
Interaction
TYPE=SOLID must be specified for this option to take effect.
TRANSPARENCY=integer
specifies the degree of transparency for the color.
Default
0
Range
0 (completely opaque) to 100 (completely transparent)
Interaction
TYPE=SOLID must be specified for this option to take effect.
TYPE=SOLID
specifies the type of line.
Default
SOLID
WIDTH=numeric-value
specifies the line width. The numeric value is specified in point units.
Default
2.25pt
Note
You can include the point abbreviation (pt) after the numeric value, but it is
not required.
Fill Attribute Options
Attribute options are available for a number of graphics elements, such as the graph wall
and column fills.
Here are two usage examples:
fillattrs=(type=solid solid_color=red transparency=50);
wallfillattrs=(type=gradient preset_gradients=early_sunset);
AUTO_COLOR=color | theme-color
specifies that the system determines the color. This option is used by default unless
TYPE= is specified.
You can specify colors using a number of different color-naming schemes.
If you want to specify a theme color, see “Theme Colors” on page 207.
Defaults
Background1 theme color for the chart area
Accent1 theme color for the chart graphics element
Common Attribute Options for the MSCHART Procedure
207
TYPE=SOLID | GRADIENT
specifies the type of fill.
Default
SOLID
SOLID_COLOR=color | theme-color
specifies the color when TYPE=SOLID. You can specify colors using a number of
different color-naming schemes.
If you want to specify a theme color, see “Theme Colors” on page 207.
Interaction
TYPE=SOLID must be specified for this option to take effect.
TRANSPARENCY=integer
specifies the degree of transparency for the color.
Default
0
Range
0 (completely opaque) to 100 (completely transparent)
Interaction
TYPE=SOLID must be specified for this option to take effect.
PRESET_GRADIENTS =gradient
specifies the preset gradient for the color. For a list of gradients, see “Preset
Gradients” on page 208.
Default
Accent1_Light_Gradient
Interaction
TYPE=GRADIENT must be specified for this option to take effect.
Theme Colors
For line and fill colors, you can choose from several theme colors and gradients of those
theme colors.
There are 10 colors in a theme. These include the following:
•
two text colors: Text1 and Text2
•
two background colors: Background1 and Background2
•
six accent colors: Accent1–Accent6
You can specify gradients of the theme colors. For example, suppose you specify
Background2 for a background color. For a lighter color, you can specify
Background2_Lighter_N, where N can be the number 5 or any multiple of 5 up to and
including the number 95. Background2_Lighter_50 is lighter than
Background2_Lighter_5.
Conversely, to make the color darker, you can specify Background2_Darker_N, where N
can be the number 5 or any multiple of 5 up to and including the number 95.
The following table shows the available theme colors:
Theme Color
Gradients
Text1
Text1_Lighter_5, Text1_Lighter_10, ... Text1_Lighter_95
Text1_Darker_5, Text1_Darker_10, ... Text1_Darker_95
208
Chapter 7
•
(Preproduction) MSCHART Procedure
Theme Color
Gradients
Text2
Text2_Lighter_5, Text2_Lighter_10, ... Text2_Lighter_95
Text2_Darker_5, Text2_Darker_10, ... Text2_Darker_95
Background1
Background1_Lighter_5, Background1_Lighter_10, ...
Background1_Lighter_95
Background1_Darker_5, Background1_Darker_10, ...
Background1_Darker_95
Background2
Background2_Lighter_5, Background2_Lighter_10, ...
Background2_Lighter_95
Background2_Darker_5, Background2_Darker_10, ...
Background2_Darker_95
Accent1
Accent1_Lighter_5, Accent1_Lighter_10, ... Accent1_Lighter_95
Accent1_Darker_5, Accent1_Darker_10, ... Accent1_Darker_95
Accent2
Accent2_Lighter_5, Accent2_Lighter_10, ... Accent2_Lighter_95
Accent2_Darker_5, Accent2_Darker_10, ... Accent2_Darker_95
Accent3
Accent3_Lighter_5, Accent3_Lighter_10, ... Accent3_Lighter_95
Accent3_Darker_5, Accent3_Darker_10, ... Accent3_Darker_95
Accent4
Accent4_Lighter_5, Accent4_Lighter_10, ... Accent4_Lighter_95
Accent4_Darker_5, Accent4_Darker_10, ... Accent4_Darker_95
Accent5
Accent5_Lighter_5, Accent5_Lighter_10, ... Accent5_Lighter_95
Accent5_Darker_5, Accent5_Darker_10, ... Accent5_Darker_95
Accent6
Accent6_Lighter_5, Accent6_Lighter_10, ... Accent6_Lighter_95
Accent6_Darker_5, Accent6_Darker_10, ... Accent6_Darker_95
Preset Gradients
EARLY_SUNSET
LATE_SUNSET
NIGHTFALL
DAYBREAK
HORIZON
DESERT
OCEAN
ACCENT1_LIGHT_GRADIENT (Default)
ACCENT1_TOP_SPOTLIGHT
ACCENT1_MEDIUM_GRADIENT
ACCENT1_RADIAL_GRADIENT
ACCENT2_LIGHT_GRADIENT
ACCENT2_TOP_SPOTLIGHT
ACCENT2_MEDIUM_GRADIENT
Example 1: Scatter Plot with a Specified Size and Backfill
CALM_WATER
FIRE
FOG
MOSS
PEACOCK
WHEAT
PARCHMENT
MAHOGANY
RAINBOW
RAINBOW2
GOLD
GOLD2
BRASS
CHROME
CHROME2
SILVER
SAPPHIRE
209
ACCENT2_RADIAL_GRADIENT
ACCENT3_LIGHT_GRADIENT
ACCENT3_TOP_SPOTLIGHT
ACCENT3_MEDIUM_GRADIENT
ACCENT3_RADIAL_GRADIENT
ACCENT4_LIGHT_GRADIENT
ACCENT4_TOP_SPOTLIGHT
ACCENT4_MEDIUM_GRADIENT
ACCENT4_RADIAL_GRADIENT
ACCENT5_LIGHT_GRADIENT
ACCENT5_TOP_SPOTLIGHT
ACCENT5_MEDIUM_GRADIENT
ACCENT5_RADIAL_GRADIENT
ACCENT6_LIGHT_GRADIENT
ACCENT6_TOP_SPOTLIGHT
ACCENT6_MEDIUM_GRADIENT
ACCENT6_RADIAL_GRADIENT
Examples: (Preproduction) MSCHART Procedure
Example 1: Scatter Plot with a Specified Size and Backfill
This example scatter plot controls the size of the chart by specifying the WIDTH=
option. By default, the aspect ratio of the chart is maintained, so you do not need to
specify the HEIGHT= or the LOCK_ASPECT option. However, both options are
available.
The example also specifies the fill attributes for the chart area. The example changes the
marker color to white, so the markers are clearly visible against the gradient.
Note: For information about specifying an output directory, see “Output File” on page
180.
210
Chapter 7
•
(Preproduction) MSCHART Procedure
ods _all_ close;
ods excel file="exbackfill.xlsx";
title "Student Height in Inches";
proc mschart data=sashelp.class category=age width=4in;
chartattrs backfillattrs=(type=gradient preset_gradients=calm_water);
scatter height / markerfillattrs=(type=solid solid_color=white);
run;
title;
ods excel close;
ods html; /* Not required in SAS Studio */
Example 2: Columnar Chart with a Specified Position and Border
This example creates a columnar chart with a blue border. The example specifies the
position of the upper left corner of the chart in the Microsoft Excel spreadsheet. To see
how the chart appears in Excel, see Figure 7.1 on page 178.
Note: Not all student names appear in the chart because the procedure has thinned the
names to fit in the space provided. You can avoid this thinning by rotating the text.
To rotate the text, specify ROTATE in the CATEGORYAXIS statement. (See
“Example 3: Combo Chart with Rotated Axis Labels” on page 211.)
Note: For information about specifying an output directory, see “Output File” on page
180.
Example 3: Combo Chart with Rotated Axis Labels
211
ods _all_ close;
ods excel;
title "Student Height in Inches";
proc mschart data=sashelp.class category=name
width=4in position="$D$2";
chartattrs borderattrs=(type=solid solid_color=blue
transparency=50);
hcolumn height;
run;
title;
ods excel close;
ods html; /* Not required in SAS Studio */
Example 3: Combo Chart with Rotated Axis Labels
This example combines a columnar chart with a line plot to produce what Excel calls a
combo chart. The example also reduces the size of the chart by specifying the WIDTH=
option. Finally, the example rotates the axis labels to fit within the new size.
Note: For information about specifying an output directory, see “Output File” on page
180.
212
Chapter 7
•
(Preproduction) MSCHART Procedure
ods _all_ close;
ods excel file="excombo.xlsx";
title "Student Age and Height";
proc mschart data=sashelp.class category=name
width=4in;
line age;
vcolumn height;
categoryaxis rotate=60;
run;
title;
ods excel close;
ods html; /* Not required in SAS Studio */
Example 4: Average Miles per Gallon
This example first calculates the average miles per gallon for a set of vehicles. The
example then creates a columnar chart with those averages.
Note: For information about specifying an output directory, see “Output File” on page
180.
proc means data=sashelp.cars noprint;
Example 4: Average Miles per Gallon
class type;
var mpg_City mpg_highway;
output out=cars(where=(_type_ > 0))
mean(mpg_city mpg_highway) = CityMPG HwyMPG ;
run;
ods _all_ close;
ods excel file="MSChart_VColumn.xlsx";
title "Average City Miles per Gallon";
proc mschart data=cars category=type width=4in;
chartattrs wallattrs=(borderattrs=(solid_color=blue));
hcolumn CityMPG;
primaryaxis title;
run;
title;
ods excel close;
ods html; /* Not required in SAS Studio */
213
214
Chapter 7
•
(Preproduction) MSCHART Procedure
215
Part 5
The ODSLIST Procedure
Chapter 8
The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
216
217
Chapter 8
The ODSLIST Procedure
Overview: ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Syntax: The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
PROC ODSLIST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
CELLSTYLE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
DYNAMIC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
ITEM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
LIST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
MVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
NMVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
P Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
TRANSLATE INTO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Using the ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Changing the Bullet Type for Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Examples: The ODSLIST Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Example 1: Using Item Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Example 2: Creating Nested Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Example 3: Customizing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Example 4: Comparing Lists Created with PROC ODSLIST
and PROC ODSTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Overview: ODSLIST Procedure
The ODSLIST procedure is used to create bulleted lists. With PROC ODSLIST, you can
create text templates for lists that can be customized and nested an infinite number of
times. You can use style attributes and formats to customize your content and WHERE
expressions to specify list item content. With PROC ODSLIST, you can use the DATA=
option to bind your data to a template without using a DATA step.
PROC ODSLIST can be used with any output destination. However, PROC ODSLIST is
essential for creating content for the ODS destination for PowerPoint and e-books. See
“ODS EPUB Statement” in SAS Output Delivery System: User's Guide and “ODS
POWERPOINT Statement” in SAS Output Delivery System: User's Guide for more
information about creating output for the ODS destination for PowerPoint and e-book
output.
218
Chapter 8
•
The ODSLIST Procedure
Syntax: The ODSLIST Procedure
PROC ODSLIST <CONTENTS=text-string><DATA=SAS-data-set> <NAME=template-name>
<PAGEBREAK=NO | YES> <PRINT> <STORE=template-store>;
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
MVAR variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
NMVAR variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
ITEM <expression> / <FORMAT=format-name> <STYLE=style-override> <VALUE=integer-value>;
P expression / <FORMAT=format-name> <STYLE=style-override>;
LIST / <START=integer-value><STYLE=style-override> ;
ITEM <expression> /
<FORMAT=format-name> <STYLE=style-override>
<VALUE=integer-value>;
END;
END;
TRANSLATE expression-1 INTO expression-2 < , expression-n INTO expression-m;>
PROC ODSLIST Statement
Creates an item list.
Syntax
PROC ODSLIST <CONTENTS=text-string><DATA=SAS-data-set> <NAME=template-name>
<PAGEBREAK=NO | YES><PRINT> <STORE=template-store>;
Optional Arguments
CONTENTS="text-string"
specifies the title for the table of contents. The CONTENTS= option overrides the
generated table of contents text.
Tip
text-string is the text that can be seen in the PDF table of contents and in the
Results Window folder descriptions.
DATA=SAS-data-set
specifies a SAS data set.
Tip
No output is produced if you specify the NAME= option without either the
DATA= option or the PRINT option. Without the DATA= or PRINT options,
ODS creates the template but does not render the output.
END Statement
219
NAME=template-name
specifies that the content of the procedure should be saved as a template with the
specified name.
No output is produced if you specify the NAME= option without either the
DATA= option or the PRINT option. Without the DATA= or PRINT options,
ODS creates the template but does not render the output.
Tip
PAGEBREAK=NO | YES
specifies whether the procedure should generate a page break.
NO
specifies that no page break is generated.
OFF
Alias
YES
specifies that a page break is generated.
ON
Alias
Default
NO
PRINT
specifies that the template is printed as well as stored.
Restriction
The PRINT option is needed only if the NAME= option is specified
without the DATA= option.
Tip
No output is produced if you specify the NAME= option without either
the DATA= option or the PRINT option. Without the DATA= or PRINT
options, ODS creates the template but does not render the output.
STORE=template-store
specifies the template store where the compiled template is placed. If you do not
specify a name or template store, ODS stores the template in the first writable
template store in the ODS path. By default, this template store is Sasuser.Templat.
If you do specify a name and template store, but do not have a libref specified, then
the template is stored in the Work directory. For example, the statement proc
odslist name=mylist store=mystore; results in a template store named
Work.mystore.
Restriction
END Statement
Ends item and list blocks.
Syntax
END;
The STORE= option can only be specified if the NAME= option is
specified.
220
Chapter 8
•
The ODSLIST Procedure
CELLSTYLE AS Statement
For tables, sets the style element of the cells in the table or column according to the values of the
variables. For text, sets the style attributes of the list items or paragraphs. Use this statement to set the
presentation characteristics (such as foreground color and font face) of individual cells or text.
Restriction:
The CELLSTYLE AS statement can be used only within a column template, an ODS
list, an ODS textblock, or a table template.
Example:
“Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 245
Syntax
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)]>
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
Required Arguments
expression
is an expression that is evaluated for each list item, paragraph, or table cell.
If expression resolves to TRUE (a nonzero value), the style element that is specified
is used for the current cell. If expression is FALSE (zero), the next expression in the
statement is evaluated. Thus, you can string multiple expressions together to format
cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a string, a comparison, logical
operation, or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 8.1
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
CELLSTYLE AS Statement
Symbol
Mnemonic Equivalent
Definition
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
221
Tip
Using an expression of 1 as the last expression in the CELLSTYLE AS
statement sets the style element for any cells that did not meet an earlier
condition. For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general
form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a table template, see
“Style Attributes Overview” on page 473.
Optional Argument
style-element-name
is the name of a style element that is part of a style that is registered with the Output
Delivery System. SAS provides some styles. You can create customized styles and
style elements with PROC TEMPLATE by using the “DEFINE STYLE Statement”
on page 462. For a table of style element names, see Chapter 21, “Style Elements,”
on page 831.
The following style elements are most likely to be used with the CELLSTYLE AS
statement:
•
Data
•
DataFixed
•
DataEmpty
•
DataEmphasis
•
DataEmphasisFixed
222
Chapter 8
•
The ODSLIST Procedure
•
DataStrong
•
DataStrongFixed
•
ListItem
•
ListItem2
•
Paragraph
The style element provides the basis for displaying the cell. Additional style
attributes modify the display.
Default
Data
See
Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page
442
For a table of style element names, see Chapter 21, “Style Elements,” on
page 831.
DYNAMIC Statement
Defines a symbol that references a value that the data component supplies from the procedure or DATA
step.
Restriction:
The DYNAMIC statement can be used only in the template of an ODS textblock,
ODS list, table, column, header, or footer. A dynamic variable that is defined in a
template is available to that template and to all the templates that it contains.
Syntax
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
Required Argument
variable-name
names a variable that the data component supplies. ODS resolves the value of the
variable when it binds the template and the data component.
Tip
Dynamic variables are most useful to the authors of SAS procedures and to
DATA step programmers.
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the dynamic variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
ITEM Statement 223
ITEM Statement
Specifies an item to be added to the item list. An ITEM statement that does not specify an expression
begins an item block.
Restriction:
Example:
ITEM statements that do not specify an expression must end with an END
statement.
“Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 245
Syntax
ITEM <expression> / <FORMAT=format-name> <STYLE=style-override> <VALUE=integer-value>;
Optional Arguments
expression
is an expression that specifies the content of an item. expression has this form:
expression-1 < expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a logical operation, a string, or an arithmetic calculation. An
operand is one of the following:
constant
is a fixed value, such as the name of a column, a text string, or symbols that
are declared in a DYNAMIC, MVAR, or NMVAR statement in the current
template.
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Restriction
ITEM statements that do not specify an expression must end with an
END statement.
FORMAT=format-name
specifies a default format for the value in each table cell or list item. You can use any
SAS or user-defined format.
Example
proc odslist data=sashelp.class;
item age / format=2.;
run;
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the specified item. For example, the following
statement specifies that the text color for the item is red:
item 'first item' / style=[color=red];
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
224
Chapter 8
•
The ODSLIST Procedure
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
VALUE=integer-value
starts a numbered list from the specified integer-value. If another VALUE= option is
specified in subsequent statements, numbering begins again at that point.
Restriction
When VALUE= is specified, you must also specify a numbering list
type with the LISTSTYLETPYE= style attribute. For example,
LISTSTYLETYPE= “decimal_leading_zero” or
LISTSTYLETYPE=“decimal”.
Tip
You can change the bullet type of a list item by specifying the
“LISTSTYLETYPE=bullet-type” style attribute with the STYLE=
option.
Examples
The following example creates a list with three items that are numbered
7, 10, and 4.
proc odslist;
item;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Seven" / value=7;
item "Ten" / value=10;
item "Four" / value=4;
end;
end;
run;
The following example creates a list that begins numbering items with
the number 7.
proc odslist;
item;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Seven" / value=7;
LIST Statement
225
item "Eight";
end;
end;
run;
Example
“Example 2: Creating Nested Lists” on page 237
LIST Statement
Creates a list.
Restrictions:
The LIST statement must be used within an item block.
LIST statements begin a LIST statement block, and must end with an END
statement.
Example:
“Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 245
Syntax
LIST / <START=integer-value><STYLE=style-override> ;
Optional Arguments
START=integer-value
starts a numbered list from the specified integer-value. If another START= option is
specified in subsequent statements, the numbering begins again at that point.
Restrictions
When START= is specified, you must also specify a numbering list type
with the LISTSTYLETPYE= style attribute. For example,
LISTSTYLETYPE= “decimal_leading_zero” or
LISTSTYLETYPE=“decimal” are numbering list types.
The START= option is valid for the PDF and RTF destinations.
Tip
You can change the bullet type of a list item by specifying the
“LISTSTYLETYPE=bullet-type” style attribute with the STYLE= option.
Examples
The following example creates a list that begins numbering items with the
number seven.
proc odslist;
item;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"} start=7;
item "Seven";
item "Eight";
end;
end;
run;
The following example creates a list that assigns a specific number to each
item.
proc odslist;
item;
226
Chapter 8
•
The ODSLIST Procedure
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Two" / value=2;
item "Four" / value=4;
item "Six" / value=6
end;
end;
run;
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the specified item in the list. For example, the
following statement specifies that the text color for the item is red:
item 'first item' / style=[color=red];
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
MVAR Statement
Defines a symbol that references a macro variable. ODS uses the value of the variable as a string.
References to the macro variable are resolved when ODS binds the template and the data component to
produce an output object.
Restriction:
Tip:
When replaying an ODS document with PROC DOCUMENT, values created by the
MVAR statement must be re-created in the same session that is replaying the
document.
You can use the MVAR statement in the template of an ODS list, ODS textblock,
table, column, header, or footer. A macro variable that is defined in a template is
available to that template and to all the templates that it contains.
NMVAR Statement 227
See:
“Example 3: Creating a New Table Template ” on page 624 and “Example 1:
Creating a Stand-Alone Style” on page 521
Syntax
MVAR variable-name-1 <='value-1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS uses the value of the
macro variable as a string. ODS does not resolve the value of the macro variable
until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use the
automatic macro variable SYSDATE9 in a template, declare it in an MVAR
statement and reference it as SYSDATE9, without an ampersand, in the PROC
TEMPLATE or PROC ODSTABLE step. If you use the ampersand, the macro
variable resolves when the template is compiled instead of when ODS binds the
template to the data component.
Optional Arguments
value
sets the default variable value.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NMVAR Statement
Defines a symbol that references a macro variable. ODS converts the variable's value to a number (stored
as a double) before using it. References to the macro variable are resolved when ODS binds the template
and the data component to produce an output object.
Restriction:
See:
The NMVAR statement can be used only in the template of an ODS list, ODS
textblock, table, column, header, or footer. A macro variable that is defined in a
template is available to that template and to all the templates that it contains.
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
Syntax
NMVAR variable-name-1 <='value–1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
228
Chapter 8
•
The ODSLIST Procedure
Required Argument
variable-name
names a macro variable to reference in the template. ODS converts the variable's
value to a number (stored as a double) before using it. ODS does not resolve the
macro variable until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use a macro
variable as a number, declare it in an NMVAR statement and reference it
without an ampersand. If you use the ampersand, the macro variable resolves
when the template is compiled instead of when ODS binds the template to the
data component.
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
P Statement
Specifies a paragraph. Multiple P statements are allowed within an item block.
Restriction:
Example:
In the ODSLIST Procedure, the P statement can be specified only within an ITEM
block. In the ODSTEXT procedure, the P statement can be used at the top level of
PROC ODSTEXT as well as within list items.
“Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 245
Syntax
P expression / <FORMAT=format-name> <STYLE=style-override> ;
Required Argument
expression
is an expression that specifies the content of an item or paragraph. expression has
this form:
expression-1 < expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a logical operation or an arithmetic calculation. An operand
is one of the following:
constant
is a fixed value, such as the name of a column, text string, or symbols that are
declared in a DYNAMIC, MVAR, or NMVAR statement in the current
template.
P Statement
229
For example, the following code creates a paragraph and an item list with
PROC ODSTEXT:
proc odstext data=sashelp.class;
p "My name is " || name;
list;
item;
p "My age is " || put(age, 2.);
p "My weight is " || put(weight, 3.);
end;
end;
run;
The following code creates an item list with PROC ODSLIST:
proc odslist data=sashelp.class;
item;
p "My name is " || name;
list;
item;
p "My age is " || put(age, 2.);
p "My weight is " || put(weight, 3.);
end;
end;
end;
run;
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Restriction
ITEM statements that do not specify an expression must end with an
END statement.
Optional Arguments
FORMAT=format-name
specifies a default format for the value in each paragraph. You can use any SAS or
user-defined format.
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the items in the list or paragraph.
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
230
Chapter 8
•
The ODSLIST Procedure
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
Examples
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
For example, the following statement specifies that the text color of the
paragraph is red:
p 'text block' / style=[color=red];
For example, the following statement specifies that the text color for the
item is red:
item 'first item' / style=[color=red];
TRANSLATE INTO Statement
Translates the specified numeric values to other values.
Restrictions:
The TRANSLATE INTO statement can be used only in a column template, an ODS
list, an ODS textblock, or a table template.
The TRANSLATE INTO statement in a table template applies only to numeric
variables. To translate the values of a character variable, use TRANSLATE INTO in
the template of that column.
Example:
“Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 245
Syntax
TRANSLATE expression-1 INTO expression-2 <, expression-n INTO expression-m>;
Required Arguments
expression-1
is an expression that is evaluated for each list item, paragraph, table, or column cell
that contains a numeric variable.
If expression-1 resolves to TRUE (a nonzero value), the translation that is specified
is used for the current cell. If expression-1 is FALSE (zero), the next expression in
the statement is evaluated. Thus, you can string multiple expressions together to
format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
TRANSLATE INTO Statement 231
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 8.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Restriction
You cannot reference the values of other columns in expression-1.
Tip
Using an expression of 1 as the last expression in the TRANSLATE–
INTO statement specifies a translation for any cells that did not meet an
earlier condition.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
expression-2
is an expression that specifies the value to use in the list, paragraph, or cell in place
of the variable's actual value.
expression has this form:
expression-1 <comparison-operator expression-n>
232
Chapter 8
•
The ODSLIST Procedure
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 8.3
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
expression-2 must resolve to a character value, not a numeric value.
Tip
When you translate a numeric value to a character value, the table
template or column template does not try to apply the numeric format
that is associated with the column. Instead, it simply writes the
character value into the formatted field, starting at the left. To rightjustify the value, use the JUSTIFY=ON attribute.
See
“JUSTIFY<=ON | OFF | variable>;” on page 663 column attribute
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
Changing the Bullet Type for Lists
233
Using the ODSLIST Procedure
PROC ODSLIST uses many of the same statements as PROC TEMPLATE to create and
customize your list templates. The CELLSTYLE AS, DYNAMIC, MVAR, NMVAR,
and TRANSLATE INTO statements are all valid statements within PROC ODSLIST
that can be used to customize your list templates.
Changing the Bullet Type for Lists
By default, lists created by the ODSLIST procedure are displayed as an unordered list
with a disc as the bullet type. In markup family output, you can change the bullet type
for lists by using the following two steps:
1. Specify the LISTSTYLETYPE= style attribute with the desired bullet type in a style
override. The following shows the general syntax for specifying the
LISTSTYLETYPE= attribute:
STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
2. Specify the style override in an ITEM or LIST statement. The following shows the
general syntax for specifying a style override in the LIST or ITEM statements:
LIST / STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
ITEM / STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
When you specify LISTSTYLETYPE= in the LIST statement, the bullets for all of the
following items are changed. If you specify LISTSTYLETYPE= in an ITEM statement,
only the bullet for that ITEM statement is changed.
The following example creates a numbered list. Because the style override is specified in
the LIST statement, all of the following items have the same numbering scheme.
title;
proc odslist;
item / style={liststyletype="none" fontsize=12pt};
p 'Follow these steps to change the bullet type for lists:'
/ style={fontsize=12pt};
list / style={liststyletype="decimal" fontsize=12pt};
item "Decide what bullet type to display.";
item "Add a '/' after the LIST statement (if not already present).";
item "Specify the LISTSTYLETYPE= attribute with the STYLE= option.";
end;
end;
run;
234
Chapter 8
•
The ODSLIST Procedure
Output 8.1 Changing the Bullet Type for All Items
You can also change the bullet type for each individual item by specifying a style
override in each ITEM statement.
title 'You Can Change the Bullet Type for Each Individual Item' ;
proc odslist;
item "List items can be a square" / style={liststyletype="square" fontsize=12pt};
item "Or a circle" / style={liststyletype="circle" fontsize=12pt};
item "Or a disc" / style={liststyletype="disc" fontsize=12pt};
item "Or items can have no bullet" / style={liststyletype="none" fontsize=12pt};
end;
run;
Output 8.2 Changing the Bullet Type for Individual Items
The following are browser-supported bullet types. However, many browsers support
other common types and the support is browser dependent. If an unsupported bullet type
is specified, the bullet’s display is browser dependent.
Table 8.4
Valid Bullet Types
Bullet Type
Description
Ordered Lists
decimal
The list items are ordered with numbers
(default).
upper_latin
The list items are ordered with uppercase
letters.
lower_latin
The list items are ordered with lowercase
letters.
upper_roman
The list items are ordered with uppercase
roman numerals.
Example 1: Using Item Statements
Bullet Type
235
Description
lower_roman
The list items are ordered with lowercase
roman numerals.
Unordered Lists
disc
The list items are marked with filled circles.
circle
The list items are marked with circles.
square
The list items are marked with squares.
none
The list items are not marked.
Examples: The ODSLIST Procedure
Example 1: Using Item Statements
Features:
CELLSTYLE AS statement
PROC ODSLIST statement
NAME= option
PRINT option
STORE= option
ITEM statement
STYLE= option
Other features:
ODS HTML CLOSE statement
ODS POWERPOINT statement
OPTIONS statement
TITLE statement
Details
The following program creates a list for a Microsoft PowerPoint slide. The
CELLSTYLE AS statement formats the contents of each item.
Program
ods html close;
options nodate;
title 'Using PROC ODSLIST ITEM Statements';
ods powerpoint file="DefaultStyle.ppt";
ods powerpoint(2) file="PowerpointdarkStyle.ppt" style=powerpointdark;
236
Chapter 8
•
The ODSLIST Procedure
proc odslist name=Slides store=sasuser.Myexampleslides print;
cellstyle 1 as {fontsize=1cm color=purple fontweight=bold};
item 'Fraud';
item 'Customer Intelligence';
item 'Social Media';
item 'Data Mining';
item 'High-Performance Computing';
item 'Risk';
item 'Data Management';
run;
ods _all_ close;
Program Description
Close the HTML destination and specify the SAS system options. The HTML
destination is open by default in SAS Windowing environment. If you are not creating
HTML output, then close the destination to save system resources.
ods html close;
options nodate;
title 'Using PROC ODSLIST ITEM Statements';
Open two instances of the ODS destination for PowerPoint. The ODS
POWERPOINT statement creates output formatted for the ODS destination for
PowerPoint.
ods powerpoint file="DefaultStyle.ppt";
ods powerpoint(2) file="PowerpointdarkStyle.ppt" style=powerpointdark;
Begin the ODSLIST procedure and create a template store and name for the
template. The NAME= option gives the template a name and the STORE= option
specifies the template store where the template is stored. If the specified template store
does not exist, then ODS creates it. Because there is no DATA= option specified, you
must use the PRINT option to render the output. Otherwise, the template is created but
no output is rendered.
proc odslist name=Slides store=sasuser.Myexampleslides print;
Create content for the ODS destination for PowerPoint. The ITEM statements create
each item in the list. The CELLSTYLE AS statement applies the style attributes to each
item.
cellstyle 1 as {fontsize=1cm color=purple fontweight=bold};
item 'Fraud';
item 'Customer Intelligence';
item 'Social Media';
item 'Data Mining';
item 'High-Performance Computing';
item 'Risk';
item 'Data Management';
run;
Example 2: Creating Nested Lists
Close the open destinations.
ods _all_ close;
Output 8.3
Slide with Default Style
Output 8.4
Slide with PowerPointDark Style
Example 2: Creating Nested Lists
Features:
ITEM statement
STYLE= option
VALUE option
LIST statement
237
238
Chapter 8
•
The ODSLIST Procedure
P statement
PROC ODSLIST statement
NAME= option
PRINT option
STORE= option
Other features:
ODS HTML CLOSE statement
ODS POWERPOINT statement
OPTIONS statement
TITLE statement
Details
PROC ODSLIST enables you to easily nest lists and add text. The following example
creates a nested list inside the first item of the list. You can use the P statement to add
text that is not in a list.
Program
ods html close;
options nodate;
title 'Creating Nested Lists';
ods powerpoint file="NestedList.ppt" style=powerpointdark;
proc odslist name=nested store=sasuser.Myexampleslides print;
item;
p ' Fraud' ;
list;
item 'Consumer Fraud';
item 'Business Fraud';
end;
end;
item
item
item
item
item
item
run;
'
'
'
'
'
'
Customer Intelligence';
Social Media' ;
Data Mining';
High-Performance Computing';
Risk';
Data Management';
ods _all_ close;
Program Description
Close the HTML destination and set the SAS system options. The HTML destination
is open by default in SAS Windowing environment. If you are not creating HTML
output, then close the destination to save system resources.
ods html close;
options nodate;
title 'Creating Nested Lists';
Example 2: Creating Nested Lists
239
Open the ODS destination for PowerPoint. The ODS POWERPOINT statement
creates output formatted for the ODS destination for PowerPoint.
ods powerpoint file="NestedList.ppt" style=powerpointdark;
Begin the ODSLIST procedure and create a template store and name for the
template. The NAME= option gives the template a name and the STORE= option
specifies the template store to put the template in. If the specified template store does not
exist, then ODS creates it. Because there is no DATA= option specified, you must use
the PRINT option to render the output. Otherwise, the template is created, but no output
is rendered.
proc odslist name=nested store=sasuser.Myexampleslides print;
Create a nested list. The first ITEM statement creates the list item that contains the
nested list. The P statement specifies the paragraph that contains the nested list. The
LIST statement begins the list, and the ITEM statements create the list items.
item;
p ' Fraud' ;
list;
item 'Consumer Fraud';
item 'Business Fraud';
end;
end;
Create the remaining list items. The ITEM statements that are not nested create the
remaining list items.
item
item
item
item
item
item
run;
'
'
'
'
'
'
Customer Intelligence';
Social Media' ;
Data Mining';
High-Performance Computing';
Risk';
Data Management';
Close the open destinations.
ods _all_ close;
240
Chapter 8
•
The ODSLIST Procedure
Output 8.5
Nesting Lists
Example 3: Customizing Lists
Features:
LIST statement
P statement
PROC ODSLIST statement
NAME= option
PRINT option
STORE= option
ITEM statement
STYLE= option
Other features:
ODS ESCAPECHAR statement
FOOTNOTE statement
ODS HTML CLOSE statement
ODS POWERPOINT statement
OPTIONS statement
TITLE statement
Details
You can customize any list created with PROC ODSLIST. You can use the STYLE=
option on the ITEM, P, or LIST statement. You can specify customizations for the entire
list with the STYLE= option in the LIST statement. You can also make specific changes
to each item or text with the STYLE= option on the ITEM or P statement.
Example 3: Customizing Lists
241
Program
ods html close;
options nodate;
ods escapechar = "^";
title 'Customizing Lists';
footnote "Marketing Data ^{nbspace 50}
www.sas.com ";
ods powerpoint file="a.ppt" style=powerpointdark;
proc odslist name=nested store=sasuser.Myexampleslides print;
item;
p ' Topics For This Week';
list / style={liststyletype=decimal fontweight=bold fontsize=1cm color=blue};
item / style=[fontweight=bold fontsize=1cm color=red] value=1;
p ' Fraud' ;
list / style={liststyletype=decimal color=purple};
item 'Consumer Fraud ^{super January-June}' / value=1;
item 'Business Fraud';
end;
end;
item
item
item
item
item
'
'
'
'
'
Customer Intelligence' ;
Social Media';
Data Mining';
High-Performance Computing';
Risk ^{style [font_style=italic color=purple]
^{sub (* Allen and sons)}}';
item ' Data Management';
end;
end;
run;
title;
proc odslist;
item;
p ' Topics For Today';
list / style={liststyletype=decimal };
item ' Customer Intelligence' / style=[fontweight=bold fontsize=1cm
color=purple] value=1;
item ' Social Media' / style=[fontweight=bold fontsize=1cm ];
item ' Data Mining' / style=[fontweight=bold fontsize=1cm ];
end;
end;
run;
ods _all_ close;
242
Chapter 8
•
The ODSLIST Procedure
Program Description
Close the HTML destination and specify the SAS system options. The HTML
destination is open by default in SAS Windowing environment. If you are not creating
HTML output, then close the destination to save system resources.
ods html close;
options nodate;
Specify titles and footnotes and define a representative character to be used in
output strings.
ods escapechar = "^";
title 'Customizing Lists';
footnote "Marketing Data ^{nbspace 50}
www.sas.com ";
Open the ODS destination for PowerPoint. The ODS POWERPOINT statement
creates output formatted for the ODS destination for PowerPoint.
ods powerpoint file="a.ppt" style=powerpointdark;
Begin the ODSLIST procedure and create a template store and name for the
template. The NAME= option gives the template a name and the STORE= option
specifies the template store to put the template in. If the specified template store does not
exist, then ODS creates it. Because there is no DATA= option specified, you must use
the PRINT option to render the output. Otherwise, the template is created but no output
is rendered.
proc odslist name=nested store=sasuser.Myexampleslides print;
Begin creating content for your output. The ITEM statement without an expression
specified begins an ITEM block. The P statement specifies explanatory text for the list.
The LIST statement begins the list. LIST statements must be specified within an ITEM
block. The STYLE= option that is specified in the LIST statement applies to all of the
list items within the list.
item;
p ' Topics For This Week';
list / style={liststyletype=decimal fontweight=bold fontsize=1cm color=blue};
Create a nested list. The LIST statement within the P statement creates a nested list for
the first item on the list. The STYLE= option in the LIST statement specifies style
attributes to format the text for all of the items in the list. The END statements end the
LIST and ITEM blocks. A STYLE= option specified in an ITEM statement overrides the
STYLE= option specified in the LIST statement. The color “blue” is applied to all of the
items in overall list except the first item, which has a STYLE= option specified. The
color “red” is applied to the first item only.
item / style=[fontweight=bold fontsize=1cm color=red] value=1;
p ' Fraud' ;
list / style={liststyletype=decimal color=purple};
item 'Consumer Fraud ^{super January-June}' / value=1;
item 'Business Fraud';
end;
end;
Example 3: Customizing Lists
243
Create the remaining list items. The ITEM statements that are not nested create the
remaining list items. The customization for each item comes from the STYLE= option
specified on the first LIST statement. The STYLE= option on the “Risk” item specifies
style attributes to format the text for that item only.
item
item
item
item
item
'
'
'
'
'
Customer Intelligence' ;
Social Media';
Data Mining';
High-Performance Computing';
Risk ^{style [font_style=italic color=purple]
^{sub (* Allen and sons)}}';
item ' Data Management';
end;
end;
run;
Create a second slide. The second ODSLIST procedure block creates a list on a second
slide. The STYLE= option specifies style attributes to format the text.
title;
proc odslist;
item;
p ' Topics For Today';
list / style={liststyletype=decimal };
item ' Customer Intelligence' / style=[fontweight=bold fontsize=1cm
color=purple] value=1;
item ' Social Media' / style=[fontweight=bold fontsize=1cm ];
item ' Data Mining' / style=[fontweight=bold fontsize=1cm ];
end;
end;
run;
Close the open destinations.
ods _all_ close;
244
Chapter 8
•
The ODSLIST Procedure
Slide 1
Output 8.6 Slide 1
Output 8.7
Slide 2
Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
245
Example 4: Comparing Lists Created with PROC ODSLIST and PROC
ODSTEXT
Features:
ODSLIST Procedure
CELLSTYLE AS statement
END statement
ITEM statement
LIST statement
P statement:
PROC ODSLIST statement
TRANSLATE INTO statement
ODSTEXT Procedure
CELLSTYLE AS statement
END statement
ITEM statement
LIST statement
P statement
PROC ODSTEXT statement
TRANSLATE INTO statement
Other features:
OPTIONS statement
TITLE statement
Details
The following examples create similar output using PROC ODSLIST and PROC
ODSTEXT. Both procedures can be used to create lists and paragraphs. However, there
are differences in how the syntax of the two procedures can be specified. The following
table shows how the P, ITEM, and LIST statements are specified in each procedure.
PROC ODSTEXT
PROC ODSLIST
The P statement can be specified only within
an ITEM block.
The P statement can be used at the top level of
PROC ODSTEXT as well as within list items.
The ITEM statement must be used within a
LIST block.
The ITEM statement does not have to be
specified within a LIST block.
The LIST statement does not have to be
specified within an item block.
The LIST statement must be used within an
item block.
There are also slight differences in the appearance of the output created by the two
procedures. Examine the output created by the two programs in this example. Notice that
the spacing and bullet points are slightly different.
Program: Using PROC ODSLIST
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
246
Chapter 8
•
The ODSLIST Procedure
proc odslist data=sashelp.class;
item;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
end;
end;
run;
Program Description
Specify the SAS system options and title.
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
Begin the ODSLIST procedure, begin an ITEM block, and specify explanatory text.
The PROC ODSLIST statement specifies the input data set and begins the procedure.
The ITEM statement with no options specified begins an ITEM block. The P statements
specify the explanatory text. In the ODSLIST Procedure, the P statement must be
specified within an ITEM block.
proc odslist data=sashelp.class;
item;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
Begin the list and conditionally set the style attributes. The LIST statement with no
options specified begins a list block. The LIST statement must be used within an item
block. The CELLSTYLE AS statement sets the style attributes of the list items based on
the value of the variable Age. If the value of the variable Age is less than or equal to 13,
the background color is green. If the value of the variable Age is greater than or equal to
14, the background color is light purple.
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
Specify the items. The ITEM statements specify the content of each item.
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
247
Conditionally transform the value for the AGE variable. The TRANSLATE INTO
statement translates the value of Age based on the conditions specified. For values of the
variable AGE that are equal to or less than thirteen, "N/A" is written to the output.
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
End the LIST and ITEM blocks. The LIST block began with the LIST statement. An
END statement ends the LIST block. Both ITEM blocks began with an ITEM statement
with no expression specified. An END statement ends each ITEM block.
end;
end;
run;
Output 8.8 Output Created with the PROC ODSLIST
Program: PROC ODSTEXT
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
proc odstext data=sashelp.class;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
item;
248
Chapter 8
•
The ODSLIST Procedure
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
end;
run;
Program Description
Specify the SAS system options and title.
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
Begin the ODSTEXT procedure and specify explanatory text for the list. The PROC
ODSLIST statement specifies the input data set and begins the procedure. The P
statements specify the text that precedes the list. In the ODSTEXT procedure, the P
statement does not have to be specified within an ITEM block.
proc odstext data=sashelp.class;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
Begin the list and conditionally set the style attributes. The LIST statement with no
options specified begins a list block. In the ODSTEXT procedure, the LIST statement
does not have to be specified within an item block. The CELLSTYLE AS statement sets
the style attributes of the list items based on the value of the variable Age. If the value of
the variable Age is less than or equal to 13, the background color is green. If the value of
the variable Age is greater than or equal to 14, the background color is light purple.
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
Specify the items. The ITEM statements specify the content of each item.
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
Conditionally transform the value for the AGE variable. The TRANSLATE INTO
statement translates the value of Age based on the conditions specified. For values of the
variable AGE that are equal to or less than thirteen, "N/A" is written to the output. The
TRANSLATE INTO statement must be specified within the block of the variable you
want to be translated. Otherwise, the variable is translated and the results apply to all
variables.
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
End the LIST block. The LIST block began with the LIST statement. An END statement
ends the LIST block.
end;
run;
Example 4: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
Output 8.9 Output Created with the PROC ODSTEXT
249
250
Chapter 8
•
The ODSLIST Procedure
251
Part 6
The ODSTABLE Procedure
Chapter 9
The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
252
253
Chapter 9
The ODSTABLE Procedure
Overview: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Concepts: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Differences between PROC TEMPLATE and PROC ODSTABLE . . . . . . . . . . . . 255
Viewing the Contents of a Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Syntax: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PROC ODSTABLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CELLSTYLE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COLUMN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COMPUTE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEFINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DYNAMIC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOOTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HEADER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NMVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOTES Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TRANSLATE INTO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
256
256
270
273
274
276
277
278
278
279
280
281
281
282
Using the ODSTABLE Procedure to Create Tabular Output . . . . . . . . . . . . . . . .
Values in Table Columns and How They Are Justified . . . . . . . . . . . . . . . . . . . . .
Formatting Values in Table Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stacking Values for Two or More Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
286
286
287
288
Examples: The ODSTABLE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 1: Customizing Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 2: Defining Variables with the COLUMN Statement . . . . . . . . . . . . . . .
Example 3: Creating and Storing a Customized Table Template . . . . . . . . . . . . . .
Example 4: Using PROC TEMPLATE and PROC ODSTABLE . . . . . . . . . . . . . .
289
289
291
293
295
Overview: The ODSTABLE Procedure
By default, ODS output is formatted according to the various definitions or templates
that the procedure or DATA step specify. Table templates describe how tables should be
constructed. This includes the content and placement of headers and footers, the content
and placement of columns, and style overrides. All SAS procedures, except PROC
PRINT, PROC REPORT, and PROC TABULATE, use table templates to describe how
their tables should look. This means that you can change the structure of tables that are
generated by SAS procedures by using table templates.
254
Chapter 9
•
The ODSTABLE Procedure
You can create your own new tabular output templates by using the ODSTABLE
procedure. The Output Delivery System then uses these templates to produce customized
tabular output. With the ODSTABLE procedure, you can create table templates and bind
them with the input data set in one statement. You can also name your templates and
store them in a template store.
The ODSTABLE procedure is a simpler way of producing the same output that you
would expect to get from using the DEFINE TABLE statement in PROC TEMPLATE.
You can use the same statements in an ODSTABLE block as you would use in a
DEFINE TABLE block in PROC TEMPLATE. For example, the table templates created
in both of the following programs are equivalent. The statements between the DEFINE
TABLE statement and the END statement in the PROC TEMPLATE step are identical to
the statements in the PROC ODSTABLE step.
Example Code 9.1 Table Template Created with PROC TEMPLATE
proc template;
define table Base.Summary;
notes "Summary table for MEANS and SUMMARY";
dynamic clmpct one_var_name one_var_label one_var;
column class nobs id type ways (varname) (label) (min)
(max) (range)
(n
) (nmiss) (sumwgt) (sum) (mean) (uss)
(css) (var) (stddev) (cv)
(
stderr) (t) (probt) (lclm) (uclm) (skew)
(kurt) (median) (mode) (q1)
(q3) (qrange) (p1) (p5) (p10) (p25) (p50) (p75)
(p90) (p95) (p99);
define nobs;
style={color=orange backgroundcolor=white};
end;
end;
run;
Example Code 9.2
Table Template Created with PROC ODSTABLE
proc odstable name=Base.Summary;
notes "Summary table for MEANS and SUMMARY";
dynamic clmpct one_var_name one_var_label one_var;
column class nobs id type ways (varname) (label) (min)
(max) (range)
(n
) (nmiss) (sumwgt) (sum) (mean) (uss)
(css) (var) (stddev) (cv)
(
stderr) (t) (probt) (lclm) (uclm) (skew)
(kurt) (median) (mode) (q1)
(q3) (qrange) (p1) (p5) (p10) (p25) (p50) (p75)
(p90) (p95) (p99);
define nobs;
style={color=orange backgroundcolor=white};
end;
run;
Concepts: The ODSTABLE Procedure
255
Concepts: The ODSTABLE Procedure
Differences between PROC TEMPLATE and PROC ODSTABLE
PROC TEMPLATE with DEFINE TABLE
Statement
PROC ODSTABLE
Creates and modifies table templates.
Creates and modifies table templates.
Creates and modifies column, header, and
footer templates in a single procedure step.
Improves the readability of programs by
creating one template type in one procedure
step.
Must use a DATA _NULL_ step to bind the
data to the table template.
Creates data-dependent table templates
without using the DATA _NULL_ step.
Does not require an input data set.
No output is produced if you specify the
NAME= option without the DATA= option.
Without the DATA= option, ODS creates the
template but does not render the output.
Viewing the Contents of a Table Template
To view the contents of a table template, use the SAS windowing environment, the
command line, or the TEMPLATE procedure.
•
Using the SAS Windowing Environment
1. From the menu, select View ð Results.
2. In the Results window, select the Results folder. Right-click and select
Templates to open the Templates window.
3. Double-click Sashelp.Tmplmst to view the contents of that item store or
directory.
4. Double-click a directory to view the list of subdirectories and table templates that
you want to view. For example, the Base SAS table template Summary is the
default template store for the summary tables created in the MEANS and
SUMMARY procedures. Double-click the Base directory, and then double-click
the Summary table.
•
Using the Command Line
1. To view the Templates window, submit this command: odstemplates
The Templates window contains the item stores Sashelp.Tmplmst and any
product-dependent item stores.
2. When you double-click an item store, such as Sashelp.Tmplmst, that item store
expands to list the directories where ODS templates are stored.
256
Chapter 9
•
The ODSTABLE Procedure
3. To view the table templates that SAS provides, double-click the item store that
contains a table template, such as Base.
4. From the list view, right-click the table template, such as Summary, and select
Open. The table template is displayed in the Template Browser window.
•
Using the TEMPLATE Procedure.
The SOURCE statement writes the source code for the specified template to the SAS
log.
For example, to view the source code for all the objects in Base SAS, submit this
code.
proc template;
source base;
run;
Syntax: The ODSTABLE Procedure
PROC ODSTABLE DATA=data-set-name | NAME=template-name
<PAGEBREAK= NO | YES ><STORE=template-store>;
<table-attribute-1 < table-attribute-2>…>;
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
COLUMN column(s);
DEFINE template-type template-name </ option(s)>;
statements-and-attributes
END;
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
FOOTER footer-name(s);
HEADER header-name(s);
MVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TRANSLATE expression-1 INTO expression-2 < , expression-n INTO expression-m;>
PROC ODSTABLE Statement
Begins a table template.
Requirement:
You must specify the DATA= option or the NAME= option.
Syntax
PROC ODSTABLE DATA=data-set-name | NAME=template-name <CONTENTS= "text-string">
PROC ODSTABLE Statement 257
<PAGEBREAK= NO | YES ><STORE=template-store>;
<table-attribute-1 < table-attribute-2>…>;
Required Arguments
DATA=data-set-name
specifies the input data.
Examples
“Example 1: Customizing Columns” on page 289
“Example 3: Creating and Storing a Customized Table Template” on
page 293
NAME= template-name
specifies the name of the template. Specifying a template name with the NAME=
option is the same as specifying a template name with the DEFINE TABLE
statement in PROC TEMPLATE. For example, the following two code blocks are
equivalent:
proc odstable name=mytable;
run;
proc template;
define table mytable;
end;
run;
Examples
“Example 3: Creating and Storing a Customized Table Template” on
page 293
“Example 4: Using PROC TEMPLATE and PROC ODSTABLE ” on
page 295
Optional Arguments
CONTENTS="text-string"
specifies the title for the table of contents. The CONTENTS= option overrides the
generated table of contents text.
text-string is the text that can be seen in the PDF table of contents and in the
Results Window folder descriptions.
Tip
PAGEBREAK= NO | YES
specifies whether the procedure should generate a page break.
NO
specifies that no page break is generated.
Alias
OFF
YES
specifies that a page break is generated.
Alias
Default
ON
YES
258
Chapter 9
•
The ODSTABLE Procedure
STORE=template-store
specifies the template store where the compiled template is placed. If you do not
specify a name or template store, ODS stores the template in the first writable
template store in the ODS path. By default, this template store is Sasuser.Templat.
If you do specify a name and template store, but do not have a libref specified, then
the template is stored in the Work directory. For example, the statement proc
odstable name=mylist store=mystore; results in a template store named
Work.mystore.
Using the STORE= option is the same as using the STORE= option in the DEFINE
statement in PROC TEMPLATE. For example, the following two code blocks are
equivalent:
proc odstable name=mytable store=sasuser.mystore(update);
run;
proc template;
define table mytable / store=sasuser.mystore(update);
end;
run;
Restriction
The STORE= option can only be used if the NAME= option is
specified.
Examples
“Example 3: Creating and Storing a Customized Table Template” on
page 293
“Example 4: Using PROC TEMPLATE and PROC ODSTABLE ” on
page 295
Table Attributes
This section lists all the attributes that you can use in a table template. Table attributes
are used to customize the attributes of a table. You can specify multiple table attributes
together or separately. For example, you can specify the following table attributes
together:
order_data=yes use_format_defaults=yes print_headers=off;
or separately:
order_data=yes;
use_format_defaults=yes;
print_headers=off;
For all attributes that support a value of ON, these forms are equivalent:
ATTRIBUTE-NAME;
ATTRIBUTE-NAME=ON;
For all of the attributes that support a value of variable, variable is any variable that you
declare in the table template with the DYNAMIC, MVAR, or NMVAR statement. If the
attribute is a Boolean, then the value of variable should resolve to either true or false as
shown in this table:
PROC ODSTABLE Statement 259
Table 9.1
Boolean Values
True
False
ON
OFF
_ON_
_OFF_
1
0
TRUE
FALSE
YES
NO
_YES_
_NO_
Table 9.2
Table Attributes
Task
Attribute
Destinations
Influence the layout of the table
Specify whether to try to place the same
number of columns in each data panel if
the entire table does not fit in one data
panel
BALANCE on page 685
LISTING, printer
family, and RTF
Specify whether to center each data
panel independently if the entire table
does not fit in one data panel
CENTER on page 685
LISTING, printer
family, RTF
Specify whether to force a new page
before printing the table
NEWPAGE on page 688
All except
OUTPUT
Specify the number of sets of columns
to place on a page
PANELS= on page 689
LISTING and
printer family
Specify the number of blank characters
to place between sets of columns when
PANELS= is in effect
PANEL_SPACE= on page
689
LISTING
Specify the number of lines that must be
available on the page in order to print
the body of the table
REQUIRED_SPACE= on
page 690
LISTING and
printer family
Specify the number of lines to place
between the previous output object and
the current one
TOP_SPACE= on page 691
LISTING and
printer family
Specify whether to split a table that is
too wide to fit in the space that is
provided or to wrap each row of the
table
WRAP on page 693
LISTING and
printer family
260
Chapter 9
•
The ODSTABLE Procedure
Task
Attribute
Destinations
Specify whether to add a double space
after the last line of a single row when
the row is wrapped
WRAP_SPACE on page 693
LISTING and
printer family
Influence the layout of rows and columns
Specify the maximum number of blank
characters to place between columns
COL_SPACE_MAX= on
page 685
LISTING
Specify the minimum number of blank
characters to place between columns
COL_SPACE_MIN= on
page 686
LISTING
Specify the name of the column whose
value provides formatting information
about the space before each row of the
template
CONTROL= on page 686
All except
OUTPUT
Specify whether to double space
between the rows of the table
DOUBLE_SPACE on page
687
LISTING
Specify whether extra space is evenly
divided among all columns of the table
EVEN on page 687
LISTING
Specify whether to split a long stacked
column across page boundaries
SPLIT_STACK on page 690
LISTING
Influence the display of the values in header cells and data cells
Specify whether to suppress blanking
the value in a column that is marked
with the BLANK_DUPS column
attribute if the value changes in a
previous column that is also marked
with the BLANK_DUPS attribute
CLASSLEVELS= on page
685
LISTING and
printer family
Specify which format to use if both a
column template and a data component
specify a format
DATA_FORMAT_OVERRI
DE on page 687
All
Specify whether to justify the format
fields within the columns or to justify
the values within the columns without
regard to the format fields
JUSTIFY on page 688
LISTING
Specify whether to order the columns by
their order in the data component
ORDER_DATA on page
689
All except
OUTPUT
Specify the source of the values for the
format width and the decimal width if
they are not specified
USE_FORMAT_DEFAULT
S on page 692
All
PROC ODSTABLE Statement 261
Task
Attribute
Destinations
Use the column name as the column
header if neither the column template
nor the data component specifies a
header
USE_NAME on page 692
All
Influence the layout of headers and footers
Specify the number of blank lines to
place between the last row of data and
the first row of output
FOOTER_SPACE= on page
687
LISTING
Specify the number of blank lines to
place between the last row of headers
and the first row of data
HEADER_SPACE= on page
688
LISTING
Specify whether to draw a continuous
line above the first table footer or, if
there is no table footer, below the last
row of data on a page
OVERLINE on page 689
LISTING
Specify whether to print table footers
and any overlining of the table footers
PRINT_FOOTERS on page
690
All except
OUTPUT
Specify whether to print table headers
and any underlining of the table headers
PRINT_HEADERS on page
690
All except
OUTPUT
Specify whether to draw a continuous
line under the last table header or, if
there is no table header, then above the
last row of data on a page
UNDERLINE on page 692
LISTING
Influence the non-LISTING output
Specify whether to place the output
object in a table of contents, if you
create a table of contents
CONTENTS on page 686
HTML
Specify the label to use for the output
object in the contents file, the Results
window, and the trace record
CONTENTS_LABEL= on
page 686
HTML, PDF,
PRINTER, PS
PDFMARK
Other table attributes
Control whether BY lines are printed
above each BY group
BYLINE= on page 685
All except
OUTPUT
Define the characters to use as the linedrawing characters in the table
FORMCHAR= on page 687
LISTING
Specify a label for the table
LABEL= on page 688
All
262
Chapter 9
•
The ODSTABLE Procedure
Task
Attribute
Destinations
Specify the table that the current
template inherits from
PARENT= on page 690
All
Specify the style element to use for the
table and any changes to the attributes
STYLE= on page 690
Markup family,
printer family, and
RTF
Specify the special data set type of a
SAS data set
TYPE= on page 691
OUTPUT
BALANCE <=ON | OFF | variable>;
specifies whether to try to place the same number of columns in each data panel if
the entire table does not fit in one data panel.
Default
OFF
Tip
The BALANCE attribute is valid only in the LISTING, printer family, and
RTF.
BYLINE <=ON | OFF | variable>;
controls whether BY lines are printed above each BY group in a configuration file, at
SAS invocation, in the OPTIONS statement, or in the Systems Options window.
Category
PROC OPTIONS GROUP= LISTCONTROL
Default
OFF
Restriction
This attribute applies only if the table is not the first one on the page. If
BY-group processing is in effect, a BY line automatically precedes the
first table on the page.
Tip
The BYLINE attribute is valid in all destinations except the OUTPUT
destination.
CENTER <=ON | OFF | variable>;
specifies whether to center each data panel independently if the entire table does not
fit in the space that is provided.
Default
ON
Tip
The CENTER attribute is valid only in the LISTING, printer family, and
RTF destinations.
CLASSLEVELS <=ON | OFF | variable>;
specifies whether to suppress blanking the value in a column that is marked with the
BLANK_DUPS column attribute if the value changes in a previous column that is
also marked with the BLANK_DUPS attribute.
Default
OFF
Tip
The CLASSLEVELS attribute is valid for all destinations except the
OUTPUT destination.
Example
“Example 1: Creating a Stand-Alone Style” on page 521
PROC ODSTABLE Statement 263
COL_SPACE_MAX= positive-integer | variable;
specifies the maximum number of blank characters to place between the columns.
Default
4
Tip
The COL_SPACE_MAX= table attribute is valid only in the LISTING
destination.
COL_SPACE_MIN= positive-integer | variable;
specifies the minimum number of blank characters to place between the columns.
Default
2
Tip
The COL_SPACE_MIN= attribute is valid only in the LISTING
destination.
CONTENTS <=ON | OFF | variable>;
specifies whether to place the output object in a table of contents, if you create a
table of contents.
Default
ON
Tip
The CONTENTS attribute is valid in markup family and printer family
destinations.
CONTENTS_LABEL= "string" | variable;
specifies the label to use for the output object in the contents file, the Results
window, and the trace record.
Default
If the SAS system option LABEL is in effect, the default label is the
object's label. If LABEL is not in effect, the default label is the object's
name.
Restriction
The CONTENTS_LABEL= attribute is valid only in markup family
and printer family destinations.
CONTROL=column-name | variable;
specifies the name of the column whose values provide formatting information about
the space before each row of the template. The value of CONTROL= should be the
name of a column of type character with a length equal to 1.
Table 9.3
Values in the Control Column
Column Control Value
Result
A digit from 1-9
The specified number of blank lines
precedes the current row.
A hyphen (-)
A row of underlining precedes the current
row.
"b" or "B"
ODS tries to insert a panel break if the
entire table does not fit in the space that is
provided.
264
Chapter 9
•
The ODSTABLE Procedure
Default
None
Restriction
The "b" and "B" column control values are not supported for the
PRINTER destination.
Tip
The CONTROL= attribute is valid in all destinations except the
OUTPUT destination.
DATA_FORMAT_OVERRIDE<=ON | OFF | variable>;
specifies which format to use if both a column template and a data component
specify a format.
ON
uses the format that the data component specifies.
OFF
use the format that the column template specifies.
Default
OFF
Tip
The DATA_FORMAT_OVERRIDE attribute is valid in all destinations.
DOUBLE_SPACE<=ON | OFF | variable>;
specifies whether to double space between the rows of the table.
Default
OFF
Tip
The DOUBLE_SPACE attribute is valid only in the LISTING
destination.
Examples
“Example 1: Editing a Table Template That a SAS Procedure Uses” on
page 613
“Example 3: Creating a New Table Template ” on page 624
EVEN<=ON | OFF | variable>;
specifies whether extra space is evenly divided among all columns of the table.
Default
OFF
Tip
The EVEN attribute is valid only in the LISTING destination.
FOOTER_SPACE=0 | 1 | 2 | variable;
specifies the number of blank lines to place between the last row of data and the first
row of the table footer.
Default
1
Tip
The FOOTER_SPACE= attribute is valid only in the LISTING destination.
FORMCHAR= "string" | variable;
defines the characters to use as the line-drawing characters in the table. Currently,
ODS uses only the second of the 20 possible formatting characters. This formatting
character is used for underlining and overlining. To change the second formatting
character, specify both the first and second formatting characters. For example, this
option assigns the asterisk (*) to the first formatting character, the plus sign (+) to the
second character, and does not alter the remaining characters: formchar="*+"
PROC ODSTABLE Statement 265
Default
The SAS system option FORMCHAR= specifies the default formatting
characters.
Tips
Use any character in formatting characters, including hexadecimal
characters. If you use hexadecimal characters, then put an x after the
closing quotation mark. For example, this option assigns the hexadecimal
character 2-D to the first formatting character, the hexadecimal character
7C to the second character, and does not alter the remaining characters:
formchar="2D7C"x
The FORMCHAR= attribute is valid only in the LISTING destination.
HEADER_SPACE=0 | 1 | 2 | variable;
specifies the number of blank lines to place between the last row of headers and the
first row of data. A row of underscores is a header.
Default
1
Tip
The HEADER_SPACE= attribute is valid only in the LISTING destination.
JUSTIFY<=ON | OFF | variable>;
specifies whether to justify the format fields within the columns or to justify the
values within the columns without regard to the format fields.
Default
OFF
Interactions
JUSTIFY=ON can interfere with decimal alignment.
If the column is numeric, then values are aligned to the right if you
specify JUSTIFY=OFF and JUST=C.
All of the destinations except for the LISTING destination justify the
values in columns as if JUSTIFY=ON for JUST=R and JUST=L.
If you translate numeric data to character data, you might need to use
JUSTIFY= to align the data.
Tips
The JUSTIFY attribute is valid only in the LISTING destination.
“Values in Table Columns and How They Are Justified” on page 610
See
LABEL= "text" | variable;
specifies a label for the table.
Default
ODS uses the first of the following that it finds: a label that the table
template provides, a label that the data component provides, or the first
spanning header in the table.
Tip
The LABEL= attribute is valid in all destinations.
NEWPAGE<=ON | OFF | variable>;
specifies whether to force a new page before printing the table.
Default
OFF
Restriction
If the table is the first item on the page, ODS ignores this attribute.
266
Chapter 9
•
The ODSTABLE Procedure
The NEWPAGE attribute is valid in all destinations except the
OUTPUT destination.
Tip
ORDER_DATA<=ON | OFF | variable>;
specifies whether to order the columns by their order in the data component.
OFF
Defaults
When ORDER_DATA=OFF, the default order for columns is the order
that they are specified in the COLUMN statement. If you omit a
COLUMN statement, the default order for columns is the order in
which you define them in the template.
Interaction
ORDER_DATA is most useful for ordering generic columns.
Tip
The ORDER_DATA attribute is valid in all destinations except the
OUTPUT destination. The OUTPUT destination always uses the order
of the columns in the data component when it creates an output data set.
OVERLINE<=ON | OFF | variable>;
specifies whether to draw a continuous line above the first table footer or, if there is
no table footer, below the last row of data on a page. The second formatting character
is used to draw the line.
Default
OFF
Tip
The OVERLINE attribute is valid only in the LISTING destination.
See
For information about formatting characters, see the discussion of
“FORMCHAR= "string" | variable;” on page 687.
UNDERLINE= table attribute on page 692, UNDERLINE= column
attribute on page 669, and the OVERLINE= column attribute on page
665.
“Example 1: Editing a Table Template That a SAS Procedure Uses” on
page 613
Example
PANELS=positive-integer | variable;
specifies the number of sets of columns to place on a page. If the width of all the
columns is less than half of the line size, display the data in multiple sets of columns
so that rows that would otherwise appear on multiple pages appear on the same page.
Tips
If the number of panels that is specified is larger than the number of panels
that can fit on the page, the template creates as many panels as it can. Let the
table template put data in the maximum number of panels that can fit on the
page by specifying a large number of panels (for example, 99).
The PANELS= attribute is valid only in LISTING and printer family
destinations.
PANEL_SPACE=positive-integer | variable;
specifies the number of blank characters to place between sets of columns when
PANELS= is in effect.
Default
2
PROC ODSTABLE Statement 267
The PANEL_SPACE= attribute is valid only in the LISTING destination.
Tip
PARENT=table-path;
specifies the table that the current template inherits from. A table-path consists of
one or more names, separated by periods. Each name represents a directory in a
template store. (A template store is a type of SAS file.) The current template inherits
from the specified table in the first template store in the current path that you can
read from.
When you specify a parent, all of the attributes and statements that are specified in
the parent's template are used in the current template unless the current template
overrides them.
Tip
The PARENT= attribute is valid in all destinations.
PRINT_FOOTERS<=ON | OFF | variable>;
specifies whether to print table footers and any overlining of the table footers.
Default
ON
Tip
The PRINT_FOOTERS attribute is valid in all destinations except the
OUTPUT destination.
See
OVERLINE= table attribute on page 689
PRINT_HEADERS<=ON | OFF | variable>;
specifies whether to print the table headers and any underlining of the table headers.
Default
ON
Interaction
When used in a table template, PRINT_HEADERS affects only headers
for the table, not the headers for individual columns. For individual
columns, use the following column attribute:
“PRINT_HEADERS<=ON | OFF | variable>;” on page 667.
Tip
The PRINT_HEADERS attribute is valid in all destinations except the
OUTPUT destination.
See
“UNDERLINE<=ON | OFF | variable>;” on page 692
REQUIRED_SPACE=positive-integer | variable;
specifies the number of lines that must be available on the page in order to print the
body of the table. The body of the table is the part of the table that contains the data.
It does not include headers and footers.
Default
3
Tip
The REQUIRED_SPACE= attribute is valid in LISTING and printer
family destinations.
SPLIT_STACK<=ON | OFF | variable>;
specifies whether to split a long stacked column across page boundaries.
Default
OFF
Tip
The SPLIT_STACK attribute is valid only in the LISTING destinations.
268
Chapter 9
•
The ODSTABLE Procedure
STYLE=<style-element-name><[style-attribute-specification(s)]>;
specifies the style element and any changes to its attributes to use for the table.
style-element-name
is the name of the style element to use to display the table. The style element
must be part of a style that is registered with the Output Delivery System. SAS
provides some styles. You can create customized styles with PROC TEMPLATE
(see “DEFINE STYLE Statement” on page 462). By default, ODS produces
different parts of ODS output with different elements. For example, by default, a
table is produced with the style element Table. SAS does not provide another
style element that you would be likely to want to use instead of Table. However,
you might have a user-defined style element at your site that would be
appropriate to specify.
The style element provides the basis for displaying the table. Additional style
attributes that you provide can modify the display.
style-element-name is either the name of a style element or a variable whose
value is a style element.
See
“Viewing the Contents of a Style” on page 444
“Finding and Viewing the Default Style for ODS Destinations” on page
445
For a table of style element names, see Chapter 21, “Style Elements,” on
page 831.
style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this
general form:
style-attribute-name=style-attribute-value
See
“Style Attributes Overview” on page 473
Default
Table
Requirement
Specify either a style-attribute-specification or a style-element-name
with the STYLE= option.
Tips
You can use braces ({ and }) instead of square brackets ([ and ]).
If you use the STYLE= attribute inside a quoted string, then add a
space before or after the carriage return to prevent errors. SAS does
not interpret a carriage return as a space. You must explicitly specify
spaces in quoted strings.
The STYLE= attribute is valid only in the markup family, printer
family, and RTF destinations.
TOP_SPACE=positive-integer | variable ;
specifies the number of lines to place between the previous output object and the
current one.
Default
1
Tip
The TOP_SPACE= attribute is valid only in LISTING and printer family
destinations.
PROC ODSTABLE Statement 269
TYPE=string | variable;
specifies a special type of SAS data set.
Restriction
PROC TEMPLATE and PROC ODSTABLE do not verify that a SAS
data set type that you specify is a valid data set type or the structure of
the data set that you create is appropriate for the type that you have
assigned.
Tips
Most SAS data sets have no special type. However, certain SAS
procedures, like the CORR procedure, can create a number of special
SAS data sets. In addition, SAS/STAT software and SAS/EIS software
support special data set types.
The TYPE= attribute is valid only in the OUTPUT destination.
UNDERLINE<=ON | OFF | variable>;
specifies whether to draw a continuous line under the last table header (or, if there is
no table header, then above the first row of data on a page). The second formatting
character is used to draw the line.
Default
OFF
Tip
The UNDERLINE attribute is valid only in the LISTING destination.
See
For information about formatting characters, see “FORMCHAR=
"string" | variable;” on page 687.
UNDERLINE= column attribute on page 669 and OVERLINE=
column attribute on page 665.
Also see OVERLINE table attribute on page 689.
Examples
“Example 1: Editing a Table Template That a SAS Procedure Uses” on
page 613
“Example 3: Creating a New Table Template ” on page 624
USE_FORMAT_DEFAULTS<=ON | OFF | variable>;
specifies the source of the values for the format width and the decimal width if they
are not specified.
ON
uses the default values, if any, that are associated with the format name.
OFF
uses the PROC TEMPLATE or PROC ODSTABLE defaults.
Default
OFF
Tip
The USE_FORMAT_DEFAULTS attribute is valid in all destinations
except the OUTPUT destination.
USE_NAME<=ON | OFF | variable>;
uses the column name as the column heading if neither the column template nor the
data component specifies a header.
Default
OFF
270
Chapter 9
•
The ODSTABLE Procedure
Tips
Use this attribute when column names are derived from a data set and the
columns are generic.
The USE_NAME attribute is valid in all destinations except the OUTPUT
destination.
WRAP<=ON | OFF | variable>;
specifies whether to split a wide table into multiple data panels, or to wrap each row
of the table so that an entire row is printed before the next row starts.
Default
OFF
Interaction
When ODS wraps the rows of a table, it does not place multiple values
in any column that contains an ID column.
Tip
The WRAP attribute is valid only in LISTING and printer family
destinations.
See
WRAP_SPACE table attribute on page 693 and ID= column attribute
on page 662
WRAP_SPACE<=ON | OFF | variable>
specifies whether to double space after the last line of a single row of the table when
the row is wrapped onto more than one line.
Default
OFF
Tip
The WRAP_SPACE attribute is valid only in the LISTING, printer family,
and RTF destinations.
See
WRAP= table attribute on page 693
CELLSTYLE AS Statement
For tables, sets the style element of the cells in the table or column according to the values of the
variables. For text, sets the style attributes of the list items or paragraphs. Use this statement to set the
presentation characteristics (such as foreground color and font face) of individual cells or text.
Restriction:
The CELLSTYLE AS statement can be used only within a column template, an ODS
list, an ODS textblock, or a table template.
Examples:
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
“Example 1: Using Item Statements” on page 235
Syntax
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)]>
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
Required Arguments
expression
is an expression that is evaluated for each list item, paragraph, or table cell.
CELLSTYLE AS Statement
271
If expression resolves to TRUE (a nonzero value), the style element that is specified
is used for the current cell. If expression is FALSE (zero), the next expression in the
statement is evaluated. Thus, you can string multiple expressions together to format
cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a string, a comparison, logical
operation, or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in table or column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
Example
The following CELLSTYLE AS statement specifies that
numeric column variables have a red font color and character
column variables have a blue font color:
cellstyle
_datatype_ = "num" as {color=red},
_datatype_ = "char" as {color=blue};
_LABEL_
is a column label.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
272
Chapter 9
•
The ODSTABLE Procedure
_STYLE_
is a style element name.
See
For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 9.4
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Tip
Using an expression of 1 as the last expression in the CELLSTYLE AS
statement sets the style element for any cells that did not meet an earlier
condition. For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general
form:
COLUMN Statement
273
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a table template, see
“Style Attributes Overview” on page 473.
Optional Argument
style-element-name
is the name of a style element that is part of a style that is registered with the Output
Delivery System. SAS provides some styles. You can create customized styles and
style elements with PROC TEMPLATE by using the “DEFINE STYLE Statement”
on page 462. For a table of style element names, see Chapter 21, “Style Elements,”
on page 831.
The following style elements are most likely to be used with the CELLSTYLE AS
statement:
•
Data
•
DataFixed
•
DataEmpty
•
DataEmphasis
•
DataEmphasisFixed
•
DataStrong
•
DataStrongFixed
•
ListItem
•
ListItem2
•
Paragraph
The style element provides the basis for displaying the cell. Additional style
attributes modify the display.
Default
Data
See
Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page
442
For a table of style element names, see Chapter 21, “Style Elements,” on
page 831.
COLUMN Statement
Declares a symbol as a column in the table and specifies the order of the columns.
Restriction:
Examples:
The COLUMN statement can be used only within a table template.
“Example 3: Creating a New Table Template ” on page 624
“Example 2: Defining Variables with the COLUMN Statement” on page 291
Syntax
COLUMN column(s);
274
Chapter 9
•
The ODSTABLE Procedure
Required Argument
column
is one or more columns. If the column is defined outside the current table template,
reference it by its path in the template store. Columns in the template are laid out
from left to right in the same order that they are specified in the COLUMN
statement.
Defaults
If you omit a COLUMN statement, ODS makes a column for each
column template (DEFINE COLUMN statement), and places the
columns in the same order that the column templates have in the table
template.
If you use a COLUMN statement but omit a DEFINE COLUMN
statement for any of the columns, ODS uses a default column template
that is based on the type of data in the column.
Interaction
If you specify the column attribute PRINT=OFF, then the value of a
column is turned off if the column is part of a stacked column. If all
columns in a stacked column have PRINT=OFF set, then the entire
column is removed from the table.
Tip
Use a list of variable names, such as DAY1–DAY10, to specify
multiple variables.
See
“Stacking Values for Two or More Variables ” on page 612
COMPUTE AS Statement
Computes values for a column that is not in the data component, or modifies the values of a column that is
in the data component.
Restriction:
Example:
The COMPUTE AS statement can be used only within a column template.
“Example 2: Defining Variables with the COLUMN Statement” on page 291
Syntax
COMPUTE AS expression;
Required Argument
expression
is an expression that assigns a value to each table cell in the column.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a comparison, a logical operation, or an arithmetic
calculation. An operand is one of the following:
constant
is a fixed value, such as the name of a column, or symbols that are declared
in a DYNAMIC, MVAR, or NMVAR statement in the current template.
COMPUTE AS Statement 275
To reference another column in a COMPUTE AS statement, use the name of
the column. In addition, if the column has values in the data component, you
can reference the column itself in the expression.
For example, this DEFINE COLUMN block defines a column that contains
the square root of the value in the column called Source:
define column sqroot;
compute as sqrt(source);
header="Square Root";
format=6.4;
end;
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data-column name.
_LABEL_
is a column label.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style-element name.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or another variable.
276
Chapter 9
•
The ODSTABLE Procedure
Table 9.5
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Tip
The COMPUTE AS statement can alter values in an output object. None
of the templates that SAS provides modifies any values. To determine
whether a template was provided by SAS, use the “ODS VERIFY
Statement” in SAS Output Delivery System: User's Guide. If the template
is not from SAS, the ODS VERIFY statement returns a warning when it
runs the SAS program that uses the template. If you receive such a
warning, use the SOURCE statement to look at the template and
determine whether the COMPUTE AS statement alters values. (See
“SOURCE Statement” on page 361.)
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
DEFINE Statement
Creates a template inside a table template.
Restriction:
See:
The DEFINE statement can be used only inside a table template.
“DEFINE COLUMN Statement” on page 592
“DEFINE FOOTER Statement” on page 593
“DEFINE HEADER Statement” on page 594
Example:
“Example 2: Defining Variables with the COLUMN Statement” on page 291
DYNAMIC Statement
277
Syntax
DEFINE <template-type> template-name </ option(s)>;
statements-and-attributes;
END;
Required Argument
template-name
specifies the name of the new object.
Restriction
template-name must be a single-level name.
Tip
To reference the template that you are creating from another template,
create it outside the table template.
Optional Arguments
template-type
specifies the type of template to create, where template-type is one of the following:
•
COLUMN
•
FOOTER
•
HEADER
The template-type determines what other statements and what attributes can go in the
template. For details, see the documentation for the corresponding DEFINE
statement.
template-type is optional if you specify the COLUMN name before the definition.
The same is true for headers and footers.
NOLIST
preserves the template-type when inheriting it from another table template.
Tip
If you specify an existing template-name without using the NOLIST option,
then the template is overwritten.
DYNAMIC Statement
Defines a symbol that references a value that the data component supplies from the procedure or DATA
step.
Restriction:
The DYNAMIC statement can be used only in the template of an ODS textblock,
ODS list, table, column, header, or footer. A dynamic variable that is defined in a
template is available to that template and to all the templates that it contains.
Syntax
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
278
Chapter 9
•
The ODSTABLE Procedure
Required Argument
variable-name
names a variable that the data component supplies. ODS resolves the value of the
variable when it binds the template and the data component.
Tip
Dynamic variables are most useful to the authors of SAS procedures and to
DATA step programmers.
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the dynamic variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
END Statement
Ends the table template, header template, column template, or footer template.
Syntax
END;
FOOTER Statement
Declares a symbol as a footer in the table and specifies the order of the footers.
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
FOOTER footer-specification(s);
Required Argument
footer-specification
is one or more footers. If the footer is defined outside the current table template,
reference it by its path in the template store. Footers in the template are laid out from
top to bottom in the same order that they are specified in the FOOTER statement.
Each footer-specification is one of the following:
"string"
specifies the text to use for the footer. If you specify a string, you do not need to
specify a DEFINE FOOTER statement. However, you cannot specify any footer
attributes except for a split character. If the SPLIT= attribute is not in effect and
if the first character of the footer that you specify is neither a blank character nor
HEADER Statement
279
an alphanumeric character, PROC TEMPLATE and PROC ODSTABLE treat it
as the split character.
See
“SPLIT= "character" | variable;” on page 678
footer-path
is the path of the footer template to use. A footer-path consists of one or more
names, separated by periods. Each name represents a directory in a template
store, which is a type of SAS file.
_LABEL_
uses the label of the output object as the footer. Each SAS procedure specifies a
label for each output object that it creates. The DATA step uses the value of the
OBJECTLABEL= option as the label of the output object. If OBJECTLABEL=
is not specified, it uses the text of the first TITLE statement as the label.
Default
If you omit a FOOTER statement, ODS makes a footer for each footer
template (DEFINE FOOTER statement), and places the footers in the same
order that the footer templates have in the table template.
HEADER Statement
Declares a symbol as a header in the table and specifies the order of the headers.
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
HEADER header-specification(s);
Required Argument
header-specification
is one or more headers. If the header is defined outside the current table template,
reference it by its path in the template store. Headers in the template are laid out
from top to bottom in the same order that they are specified in the HEADER
statement. Each header-specification is one of the following:
"string"
specifies the text to use for the header. If you specify a string, you do not need to
use a DEFINE HEADER statement. However, you cannot specify any header
attributes except for a split character. If the SPLIT= header attribute is not in
effect and if the first character of the header that you specify is neither a blank
character nor an alphanumeric character, PROC TEMPLATE and PROC
ODSTABLE treat it as the split character.
See
“SPLIT= "character" | variable;” on page 678
header-path
is the path of the header template to use. A header-path consists of one or more
names, separated by periods. Each name represents a directory in a template
store. (A template store is a type of SAS file.)
280
Chapter 9
•
The ODSTABLE Procedure
_LABEL_
uses the label of the output object as the header. Each SAS procedure specifies a
label for each output object that it creates. The DATA step uses the value of the
OBJECTLABEL= option as the label of the output object. If OBJECTLABEL=
is not specified, it uses the text of the first TITLE statement as the label.
Default
If you omit a HEADER statement, then ODS makes a header for each
header template (DEFINE HEADER statement), and places the headers
in the same order that the header templates have in the table template.
Example
“Example 3: Creating a New Table Template ” on page 624
MVAR Statement
Defines a symbol that references a macro variable. ODS uses the value of the variable as a string.
References to the macro variable are resolved when ODS binds the template and the data component to
produce an output object.
Restriction:
When replaying an ODS document with PROC DOCUMENT, values created by the
MVAR statement must be re-created in the same session that is replaying the
document.
Tip:
You can use the MVAR statement in the template of an ODS list, ODS textblock,
table, column, header, or footer. A macro variable that is defined in a template is
available to that template and to all the templates that it contains.
See:
“Example 3: Creating a New Table Template ” on page 624 and “Example 1:
Creating a Stand-Alone Style” on page 521
Syntax
MVAR variable-name-1 <='value-1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS uses the value of the
macro variable as a string. ODS does not resolve the value of the macro variable
until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use the
automatic macro variable SYSDATE9 in a template, declare it in an MVAR
statement and reference it as SYSDATE9, without an ampersand, in the PROC
TEMPLATE or PROC ODSTABLE step. If you use the ampersand, the macro
variable resolves when the template is compiled instead of when ODS binds the
template to the data component.
Optional Arguments
value
sets the default variable value.
NOTES Statement 281
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NMVAR Statement
Defines a symbol that references a macro variable. ODS converts the variable's value to a number (stored
as a double) before using it. References to the macro variable are resolved when ODS binds the template
and the data component to produce an output object.
Restriction:
See:
The NMVAR statement can be used only in the template of an ODS list, ODS
textblock, table, column, header, or footer. A macro variable that is defined in a
template is available to that template and to all the templates that it contains.
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
Syntax
NMVAR variable-name-1 <='value–1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS converts the variable's
value to a number (stored as a double) before using it. ODS does not resolve the
macro variable until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use a macro
variable as a number, declare it in an NMVAR statement and reference it
without an ampersand. If you use the ampersand, the macro variable resolves
when the template is compiled instead of when ODS binds the template to the
data component.
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NOTES Statement
Provides information about the table, header, column, or footer.
Restriction:
The NOTES statement can be used only in the template of a table, column, header,
or footer.
282
Chapter 9
•
The ODSTABLE Procedure
Tip:
The NOTES statement becomes part of the compiled template, which you can view
with the SOURCE statement, whereas SAS comments do not.
See:
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
NOTES 'text';
Required Argument
text
provides information about the table.
TRANSLATE INTO Statement
Translates the specified numeric values to other values.
Restrictions:
The TRANSLATE INTO statement can be used only in a column template, an ODS
list, an ODS textblock, or a table template.
The TRANSLATE INTO statement in a table template applies only to numeric
variables. To translate the values of a character variable, use TRANSLATE INTO in
the template of that column.
Example:
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
Syntax
TRANSLATE expression-1 INTO expression-2 <, expression-n INTO expression-m>;
Required Arguments
expression-1
is an expression that is evaluated for each list item, paragraph, table, or column cell
that contains a numeric variable.
If expression-1 resolves to TRUE (a nonzero value), the translation that is specified
is used for the current cell. If expression-1 is FALSE (zero), the next expression in
the statement is evaluated. Thus, you can string multiple expressions together to
format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
TRANSLATE INTO Statement 283
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in table or column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
_LABEL_
is a column label.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style element name.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 9.6
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
284
Chapter 9
•
The ODSTABLE Procedure
Symbol
Mnemonic Equivalent
Definition
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Restriction
You cannot reference the values of other columns in expression-1.
Tip
Using an expression of 1 as the last expression in the TRANSLATE–
INTO statement specifies a translation for any cells that did not meet an
earlier condition.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
expression-2
is an expression that specifies the value to use in the list, paragraph, or cell in place
of the variable's actual value.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Built-in variable
a special type of WHERE expression operand that helps you find common
values in table templates. Built-in variables are one or more of the following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
TRANSLATE INTO Statement 285
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
_LABEL_
is a column label
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style element name.
See
For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 9.7
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
286
Chapter 9
•
The ODSTABLE Procedure
Symbol
Mnemonic Equivalent
Definition
IN
Equal to one from a list of values
Restriction
expression-2 must resolve to a character value, not a numeric value.
Tip
When you translate a numeric value to a character value, the table
template or column template does not try to apply the numeric format
that is associated with the column. Instead, it simply writes the
character value into the formatted field, starting at the left. To rightjustify the value, use the JUSTIFY=ON attribute.
See
“JUSTIFY<=ON | OFF | variable>;” on page 663 column attribute
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
Using the ODSTABLE Procedure to Create
Tabular Output
Values in Table Columns and How They Are Justified
The process of justifying the values in columns in LISTING output is determined by the
format of the variable and the values of two attributes: JUST= and JUSTIFY=. It is a
three-step process:
1. ODS puts the value into the format for the column. Character variables are leftjustified within their format fields; numeric variables are right-justified.
2. ODS justifies the entire format field within the column width according to the value
of the JUST= attribute for the column, or, if that attribute is not set, JUST= for the
table. For example, if you right-justify the column, the format field is placed as far to
the right as possible. However, the placement of the individual numbers and
characters within the field does not change. Thus, decimal points remain aligned. If
the column and the format field have the same width, then JUST= has no apparent
effect because the format field occupies the entire column.
3. If you specify JUSTIFY=ON for the column or the table, ODS justifies the values
within the column without regard to the format field. By default, JUSTIFY=OFF.
For example, consider this set of values:
123.45
234.5
.
Using the ODSTABLE Procedure to Create Tabular Output
287
987.654
If the values are formatted with a 6.2 format and displayed in a column with a width of
6, they appear this way, regardless of the value of JUST= (asterisks indicate the width of
the column):
******
123.45
234.50
.
987.65
If the width of the column increases to 8, then the value of JUST= does affect the
placement of the values, because the format field has room to move within the column.
Notice that the decimal points remain aligned but that the numbers shift in relation to the
column width.
just=left
just=center
just=right
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
Now, if you add JUSTIFY=ON, then the values are formatted within the column without
regard to the format width. The results are as follows:
justify=on
just=left
justify=on
just=center
justify=on
just=right
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
All destinations except LISTING justify the values in columns as if JUSTIFY=ON.
Formatting Values in Table Columns
The process of formatting the values in columns in LISTING output is determined by the
format of the variable and the values of three options: FORMAT=, FORMAT_WIDTH=,
and FORMAT_NDEC=. It is a four-step process:
1. If you omit a FORMAT= option, then the format that the data component provides is
used. If the data component does not provide a format, then ODS uses one of the
following:
•
best8. for integers
•
D12.3 for doubles
•
the length of the variable for character variables
2. If a format width is specified in the FORMAT= option, then takes precedence over
the FORMAT_WIDTH= and FORMAT_NDEC= options.
3. If you specify a decimal width with the FORMAT= and FORMAT_NDEC= options,
then the format that is specified with the FORMAT= option is used.
288
Chapter 9
•
The ODSTABLE Procedure
4. If you specify a format width with the FORMAT= and FORMAT_WIDTH= options,
then the format that is specified with FORMAT= option is used.
The formatting attributes of a column are determined by the data component or the
column template. This table summarizes the behavior of the column formatting attributes
based on which attributes the column template provides.
Table 9.8
Summary of Column Formatting Attributes
Specifications Provided by the
Column Template
Result
Nothing
Format name, width, and number of decimal places are
determined by the data component.
Format name
Format name and width are determined by the column
template; number of decimal places is determined by the
data component.
Format name and width
Format name and width are determined by the column
template.
Format name, width, and number of
decimal places
All three are determined by the column template.
Width
No name is specified; width is determined by the column
template; number of decimal places is determined by the
data component.
Number of decimal places
No name is specified; width is determined by the data
component; number of decimal places is determined by
the column template.
Stacking Values for Two or More Variables
To stack values for two or more variables in the same column, put parentheses around
the stacked variables. In such a case, the column header for the first column inside the
parentheses becomes the header for the column that contains all the variables inside
parentheses. For example, this COLUMN statement produces a template with the
following characteristics:
•
The value of NAME is in the first column by itself.
•
The values of CITY and STATE appear in the second column with CITY above
STATE. The header for this column is the header that is associated with CITY.
•
The values HOMEPHONE and WORKPHONE appear in the third column with
HOMEPHONE above WORKPHONE. The header for this column is the header that
is associated with HOMEPHONE.
column name (city state) (homephone workphone);
Use the asterisk (*) in the COLUMN statement to change the layout of stacking
variables. An asterisk between groups of variables in parentheses stacks the first item in
the first set of parentheses above the first item in the next set of parentheses, and so on,
until the last group of parentheses is reached. Then, the second item in the first group is
Example 1: Customizing Columns
289
stacked above the second item in the second group, and so on. For example, this
COLUMN statement produces a report with the following characteristics:
•
The value of NAME is in the first column by itself.
•
The values of CITY and HOMEPHONE appear in the second column with CITY
above HOMEPHONE. The header for this column is the header that is associated
with CITY.
•
The values STATE and WORKPHONE appear in the third column with STATE
above WORKPHONE. The header for this column is the header that is associated
with STATE.
column name (city state) * (homephone workphone);
Examples: The ODSTABLE Procedure
Example 1: Customizing Columns
Features:
COLUMN statement
DATA= option
DEFINE statement
PROC ODSTABLE statement
Table attributes
STYLE
HEADER
FORMAT
Other features:
OPTIONS statement
TITLE statement
Program
options nodate obs=15;
title "Customizing Columns";
proc odstable data=sashelp.class;
column age sex height weight;
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
290
Chapter 9
•
The ODSTABLE Procedure
run;
Program Description
Specify the SAS system options and titles.
options nodate obs=15;
title "Customizing Columns";
Begin the ODSTABLE procedure and specify the columns. The PROC ODSTABLE
statement begins the procedure. The DATA= option specifies the input data set. The
COLUMN statement specifies the columns.
proc odstable data=sashelp.class;
column age sex height weight;
Customize the columns. The DEFINE statements modify the specified column. The
HEADER table attribute specifies the text for the column heading. The STYLE table
argument specifies font size, font color, justification, and line style.
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
run;
Example 2: Defining Variables with the COLUMN Statement
291
The following output uses the default HTMLBlue style, with customized columns.
Output 9.1 Customizing Columns
Example 2: Defining Variables with the COLUMN Statement
Features:
COLUMN statement
DEFINE statement
COMPUTE AS statement
Details
The COLUMN statement indicates which data columns are available for use anywhere
in the template. A variable must be specified in the COLUMN statement for its value to
be available. If you do not want a specific variable and column to appear in the output,
you can suppress the variable by using the PRINT=OFF column attribute.
This example calculates a three percent holdback based on the invoice price and
manufacturers suggested retail price.
292
Chapter 9
•
The ODSTABLE Procedure
Program
title "Dealer Profit Assuming Three Percent Holdback";
proc odstable data=sashelp.cars(obs=15);
column Make Model Msrp Holdback;
define holdback;
compute as (msrp * .03) ;
label="3% Dealer Holdback";
format=dollar10.2;
end;
define msrp;
print=off;
end;
run;
Program Description
Specify the title and begin the ODSTABLE procedure.
title "Dealer Profit Assuming Three Percent Holdback";
proc odstable data=sashelp.cars(obs=15);
Specify the data columns to include in the table. The column statement specifies the
columns that are available to be used in the template. Make, Model, and Msrp are in the
data set. The Holdback column values will be calculated.
column Make Model Msrp Holdback;
Create the Holdback data values. The define statement creates a column named
Holdback. The COMPUTE AS statement specifies the calculation to be used. The
LABEL and FORMAT column attributes specify the label and format that the values
use.
define holdback;
compute as (msrp * .03) ;
label="3% Dealer Holdback";
format=dollar10.2;
end;
Suppress the printing of the Msrp column. You must include the Msrp variable in the
COLUMN statement so that the values are available for calculating the Holdback values.
To suppress the printing of the Msrp column, use the DEFINE statement and the
PRINT=OFF column attribute.
define msrp;
print=off;
end;
run;
Example 3: Creating and Storing a Customized Table Template
Output 9.2
Output Showing Selected Column Variables
Example 3: Creating and Storing a Customized Table Template
Features:
PROC ODSTABLE statement
DATA= option
NAME= option
STORE= option
COLUMN statement
DEFINE statement
Table attributes
STYLE
HEADER
FORMAT
Other features:
OPTIONS statement
TITLE statement
293
294
Chapter 9
•
The ODSTABLE Procedure
Details
This example creates a table with customized columns. With the ODSTABLE procedure,
you can give the table template a name and store it in the template store of your choice.
Program
options nodate obs=15;
title;
proc odstable data=sashelp.class name=odstableExample store=Sasuser.MyExampleTemplates;
column age sex height weight;
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
run;
Program Description
Specify the SAS system options and titles.
options nodate obs=15;
title;
Specify the name of the new table template and the template store. The DATA=
option specifies the input data set. The NAME= option specifies the name of the table
template. The STORE= option specifies the template store to put the template in. If the
template store specified by the STORE= option does not exist, the STORE= option
creates it.
proc odstable data=sashelp.class name=odstableExample store=Sasuser.MyExampleTemplates;
Specify the columns. The COLUMN statement specifies the columns.
column age sex height weight;
Customize the columns. The DEFINE statements modify the specified column. The
HEADER table attribute specifies the text for the column heading. The STYLE table
argument specifies font size, font color, justification, and line style.
define age;
style={fontsize=10pt just=l borderrightstyle=dashed background=yellow};
header='Age of Student';
format=3.;
end;
define sex;
style={fontsize=10pt just=l borderrightstyle=dashed};
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
295
header='Gender';
end;
define height;
style={fontsize=10pt just=l foreground=blue borderrightstyle=dashed};
header='Height';
end;
run;
Output 9.3
Using the NAME= and STORE= Options
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
Features:
PROC ODSTABLE statement:
STORE= option
NAME= option
CELLSTYLE-AS statement
Other features:
PROC TEMPLATE
DEFINE TABLE statement
ODS PDF statement
OPTIONS statement
PROC SQL
TITLE statement
Details
The following programs create the same output using two different methods. Using the
PROC ODSTABLE statement is the same as using the combination of PROC
TEMPLATE and DEFINE TABLE statements.
This example also creates a master table template. Master templates are applied globally
to all of your tabular output. For more information about master table templates, see
“Base.Template.Table” on page 597.
Program: Creating a Table with PROC ODSTABLE
ods path reset;
ods path show;
ods html close;
296
Chapter 9
•
The ODSTABLE Procedure
options nodate;
ods pdf file="ProcOdstableTable.pdf";
title "Using PROC ODSTABLE";
proc odstable name=Base.Template.Table;
define header myheader1;
text "Use the CELLSTYLE-AS Statement to Customize Output";
style={color=red};
end;
define header myheader2;
text "Use PROC ODSTABLE to Create a Table Template";
style={color=red};
end;
define footer myfooter;
text "This output is formated with a master template.";
style={color=blue};
end;
cellstyle _row_ in (13) as {BackgroundColor=Palegreen },
_row_ in (12) as {BorderBottomStyle=Solid },
_row_ in (11) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
proc sql;
select * from sashelp.class;
run;
quit;
proc odstable name=Base.Template.Table store=mystore;
cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
ods path (prepend) Mystore;
ods path show;
proc sql;
select * from sashelp.class;
run;
quit;
ods pdf close;
ods html;
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
297
proc template;
delete base.template.table;
delete base.template.table / store=mystore;
run;
ods path reset;
Program Description
Set ODS path to default settings and display the current ODS path.
ods path reset;
ods path show;
ods html close;
Set the SAS system options, specify the PDF destination, and specify a title.
options nodate;
ods pdf file="ProcOdstableTable.pdf";
title "Using PROC ODSTABLE";
Create the table template Base.Template.Table. The PROC ODSTABLE statement
creates the master template Base.Template.Table. This template is applied to every table
created by SAS, unless it is overridden by another template created by PROC
TEMPLATE or PROC ODSTABLE, removed with the DELETE statement, or manually
removed from the item store. Because there is no STORE= option specified in the PROC
ODSTABLE statement, the template is stored in the Sasuser.Templat template store.
proc odstable name=Base.Template.Table;
Create two headers and a footer. The DEFINE statement with “header” template type
specified, creates a header. The DEFINE statement with “footer” template type
specified, creates a footer. DEFINE statement blocks must end with an END statement.
define header myheader1;
text "Use the CELLSTYLE-AS Statement to Customize Output";
style={color=red};
end;
define header myheader2;
text "Use PROC ODSTABLE to Create a Table Template";
style={color=red};
end;
define footer myfooter;
text "This output is formated with a master template.";
style={color=blue};
end;
Format cells. The CELLSTYLE-AS statement specifies the style element and style
attributes to use for cells in each of the rows in a table, which creates the alternating row
colors in the output.
cellstyle _row_ in (13) as {BackgroundColor=Palegreen },
_row_ in (12) as {BorderBottomStyle=Solid },
_row_ in (11) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
298
Chapter 9
•
The ODSTABLE Procedure
_col_
_col_
_col_
_col_
=
=
=
=
2
3
4
5
as
as
as
as
{Width=2in},
{Width=.6in},
{Width=.5in},
{Width=.9in};
run;
Select columns. The SQL procedure selects all columns from the Sashelp.Class data
set.
proc sql;
select * from sashelp.class;
run;
quit;
Create a second table template named Base.Template.Table. The PROC
ODSTABLE statement creates the master template Base.Template.Table. This template
is applied to every table created by SAS, unless it is overridden by another template
created by PROC TEMPLATE or PROC ODSTABLE, removed with the DELETE
statement, or manually removed from the item store. Because the STORE= option is
specified in the PROC ODSTABLE statement, the template is placed in the template
store Work.Mystore.
proc odstable name=Base.Template.Table store=mystore;
Format cells. The CELLSTYLE-AS statement specifies the style element and style
attributes to use for cells in each of the rows in a table, which creates the alternating row
colors in the output.
cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
Add Work.Mystore to the beginning of the ODS search order path. The ODS PATH
statement with PREPEND specified adds Work.Mystore to the beginning of the ODS
search order path. This enables the template Base.Template.Table from the
Work.Mystore item store to be used. The ODS PATH statement displays the modified
ODS path.
ods path (prepend) Mystore;
ods path show;
Select columns, close the PDF destination, and open the HTML destination. The
SQL procedure selects all columns from the Sashelp.Class data set. The PDF statement
closes the PDF destination. The ODS HTML statement opens the HTML statement.
proc sql;
select * from sashelp.class;
run;
quit;
ods pdf close;
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
299
ods html;
Delete the master templates. The DELETE statement deletes the master templates. If
you do not delete them, they are applied to all of your tabular output until you do delete
them.
proc template;
delete base.template.table;
delete base.template.table / store=mystore;
run;
Set the ODS path to default settings.
ods path reset;
The following output was created with PROC ODSTABLE. The headers and footers are
created by the DEFINE statements.
Output 9.4
Output Created with PROC ODSTABLE, with Headers and Footers
300
Chapter 9
•
The ODSTABLE Procedure
The following output was created with PROC ODSTABLE. There are no headers and
footers for this output, because the DEFINE statement was not used in the second PROC
ODSTABLE block..
Output 9.5 Output Created with PROC ODSTABLE, No Headers or Footers
Program: Creating a Table with PROC TEMPLATE and the DEFINE TABLE
Statement
ods path reset;
ods path show;
ods html close;
options nodate;
ods pdf file="ProctemplTable.pdf";
title "Using PROC TEMPLATE and the DEFINE TABLE Statement";
proc template;
define table Base.Template.Table;
define header myheader1;
text "Use the CELLSTYLE-AS Statement to Customize Output";
style={color=red};
end;
define header myheader2;
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
text "Use PROC TEMPLATE to Create a Table Template";
style={color=red};
end;
define footer myfooter;
text "This output is formated with a master template.";
style={color=blue};
end;
cellstyle _row_ in (13) as {BackgroundColor=Palegreen },
_row_ in (12) as {BorderBottomStyle=Solid },
_row_ in (11) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
end;
run;
proc sql;
select * from sashelp.class;
run;
quit;
proc template;
define table Base.Template.Table / store=Mystore;
cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
end;
run;
ods path (prepend) Mystore;
ods path show;
proc sql;
select * from sashelp.class;
run;
quit;
ods pdf close;
ods html;
proc template;
delete base.template.table;
delete base.template.table / store=mystore;
run;
Program Description
Set ODS path to default settings and display the current ODS path.
301
302
Chapter 9
•
The ODSTABLE Procedure
ods path reset;
ods path show;
ods html close;
Set the SAS system options, specify the PDF destination, and specify a title.
options nodate;
ods pdf file="ProctemplTable.pdf";
title "Using PROC TEMPLATE and the DEFINE TABLE Statement";
Create the table template Base.Template.Table. The DEFINE TABLE statement in
PROC TEMPLATE creates the master template Base.Template.Table. This template is
applied to every table created by SAS, unless it is overridden by another template
created by PROC TEMPLATE or PROC ODSTABLE, removed with the DELETE
statement, or manually removed from the item store. Because there is no STORE=
option specified in the DEFINE TABLE statement, the template is stored in the
Sasuser.Templat template store.
proc template;
define table Base.Template.Table;
Create two headers and a footer. The DEFINE statement with “header” template type
specified, creates a header. The DEFINE statement with “footer” template type
specified, creates a footer. DEFINE statement blocks must end with an END statement.
define header myheader1;
text "Use the CELLSTYLE-AS Statement to Customize Output";
style={color=red};
end;
define header myheader2;
text "Use PROC TEMPLATE to Create a Table Template";
style={color=red};
end;
define footer myfooter;
text "This output is formated with a master template.";
style={color=blue};
end;
Format cells. The CELLSTYLE-AS statement specifies the style element and style
attributes to use for cells in each of the rows in a table, which creates the alternating row
colors in the output.
cellstyle _row_ in (13) as {BackgroundColor=Palegreen },
_row_ in (12) as {BorderBottomStyle=Solid },
_row_ in (11) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
end;
run;
Select columns. The SQL procedure selects all columns from the Sashelp.Class data
set.
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
303
proc sql;
select * from sashelp.class;
run;
quit;
Create a second table template named Base.Template.Table. The DEFINE TABLE
statement in PROC TEMPLATE creates the master template Base.Template.Table. This
template is applied to every table created by SAS, unless it is overridden by another
template created by PROC TEMPLATE or PROC ODSTABLE, removed with the
DELETE statement, or manually removed from the item store. Because the STORE=
option is specified in the DEFINE TABLE statement, the template is placed in the
template store Work.Mystore.
proc template;
define table Base.Template.Table / store=Mystore;
Format cells. The CELLSTYLE-AS statement specifies the style element and style
attributes to use for cells in each of the rows in a table, which creates the alternating row
colors in the output.
cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
end;
run;
Add Work.Mystore to the beginning of the ODS search order path. The ODS PATH
statement with PREPEND specified adds Work.Mystore to the beginning of the ODS
search order path. This enables the template Base.Template.Table from the
Work.Mystore item store to be used. The ODS PATH statement displays the modified
ODS path.
ods path (prepend) Mystore;
ods path show;
Select columns, close the PDF destination, and open the HTML destination. The
SQL procedure selects all columns from the Sashelp.Class data set. The ODS PDF
statement closes the PDF destination, and the ODS HTML statement opens the HTML
destination.
proc sql;
select * from sashelp.class;
run;
quit;
ods pdf close;
ods html;
Delete the templates. The DELETE statements delete the template
Base.Template.Table from the Sasuser.Templat template store and the
Base.Template.Table from the Work.Mystore template store
proc template;
304
Chapter 9
•
The ODSTABLE Procedure
delete base.template.table;
delete base.template.table / store=mystore;
run;
The following output was created with PROC TEMPLATE and the DEFINE TABLE
statement. The headers and footers are created by the DEFINE statements.
Output 9.6 Output Created with PROC TEMPLATE, with Headers and Footers
Example 4: Using PROC TEMPLATE and PROC ODSTABLE
305
The following output was created with PROC TEMPLATE and the DEFINE TABLE
statement. There are no headers and footers for this output, because the DEFINE
statement was not used in the second PROC ODSTABLE block..
Output 9.7
Output Created with PROC TEMPLATE, No Headers or Footers
After both templates are created, either with PROC TEMPLATE or PROC ODSTABLE,
you can view them in the Templates window. The template store Work.Mystore is
created by the option STORE=Mystore. The template store Sasuser.Templat is the
template store that is created when you do not explicitly create or name your own
306
Chapter 9
•
The ODSTABLE Procedure
template store. Sasuser.Templat is created when you specify the PROC ODSTABLE or
DEFINE TABLE statement with no STORE= option
Output 9.8 Templates Window Showing the Table Templates
307
Part 7
The ODSTEXT Procedure
Chapter 10
The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
308
309
Chapter 10
The ODSTEXT Procedure
Overview: ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Syntax: The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PROC ODSTEXT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CELLSTYLE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DYNAMIC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ITEM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LIST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NMVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
P Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TRANSLATE INTO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
310
310
311
314
314
314
317
318
319
320
322
Using the ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Changing the Bullet Type for Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Examples: The ODSTEXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Example 1: Creating Content for the ODS Destination for PowerPoint . . . . . . . . 327
Example 2: Comparing Lists Created with PROC ODSLIST
and PROC ODSTEXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Overview: ODSTEXT Procedure
The ODSTEXT procedure is used to create text block templates. These text block
templates create lists and paragraphs for your output. You can use style attributes and
formats to customize your content, and WHERE expressions to select your content. With
PROC ODSTEXT, you can use the DATA= option to bind your data to the template
without using a DATA step.
PROC ODSTEXT can be used with any output destination. However, the procedure is
essential for creating content for the ODS destination for PowerPoint and e-books. See
“ODS EPUB Statement” in SAS Output Delivery System: User's Guide and “ODS
POWERPOINT Statement” in SAS Output Delivery System: User's Guide for more
information about creating output for the ODS destination for PowerPoint and e-book
output.
310
Chapter 10
•
The ODSTEXT Procedure
Syntax: The ODSTEXT Procedure
PROC ODSTEXT <CONTENTS=text-string><DATA=SAS-data-set> <NAME=template-name>
<PAGEBREAK=NO | YES> <PRINT><STORE=template-store>;
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
MVAR variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
NMVAR variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
LIST / <START=integer-value><STYLE=style-override> ;
ITEM <expression> / <FORMAT=format-name>
<STYLE=style-override>
<VALUE=integer-value>;
END;
P expression/ <FORMAT=format-name> <STYLE=style-override> ;
TRANSLATE expression-1 INTO expression-2 < , expression-n INTO expression-m;>
PROC ODSTEXT Statement
Creates a text block.
Syntax
PROC ODSTEXT <CONTENTS=text-string><DATA=SAS-data-set> <NAME=template-name>
<PAGEBREAK=NO | YES> <PRINT><STORE=template-store>;
Optional Arguments
CONTENTS="text-string"
specifies the title for the table of contents. The CONTENTS= option overrides the
generated table of contents text.
Tip
text-string is the text that can be seen in the PDF table of contents and in the
Results Window folder descriptions.
DATA=SAS-data-set
specifies a SAS data set.
Tip
No output is produced if you specify the NAME= option without either the
DATA= option or the PRINT option. Without the DATA= or PRINT options,
ODS creates the template but does not render the output.
CELLSTYLE AS Statement
311
NAME=<template-name>
specifies that the content of the procedure should be saved as a template with the
specified name.
No output is produced if you specify the NAME= option without either the
DATA= option or the PRINT option. Without the DATA= or PRINT options,
ODS creates the template but does not render the output.
Tip
PAGEBREAK= NO | YES
specifies whether the procedure should generate a page break.
NO
specifies that no page break is generated.
OFF
Alias
YES
specifies that a page break is generated.
ON
Alias
Default
NO
PRINT
specifies that the template is printed as well as stored.
Restriction
The PRINT option is needed only if the NAME= option is specified
without the DATA= option.
Tip
No output is produced if you specify the NAME= option without either
the DATA= option or the PRINT option. Without the DATA= or PRINT
options, ODS creates the template but does not render the output.
STORE=template-store
specifies the template store where the compiled template is placed. If you do not
specify a name or template store, ODS stores the template in the first writable
template store in the ODS path. By default, this template store is Sasuser.Templat.
If you do specify a name and template store, but no libref is specified, then the
template is stored in the Work directory. For example, the statement proc
odstext name=mylist store=mystore; results in a template store named
Work.Mystore.
Restriction
The STORE= option can only be specified if the NAME= option is
specified.
CELLSTYLE AS Statement
For tables, sets the style element of the cells in the table or column according to the values of the
variables. For text, sets the style attributes of the list items or paragraphs. Use this statement to set the
presentation characteristics (such as foreground color and font face) of individual cells or text.
Restriction:
The CELLSTYLE AS statement can be used only within a column template, an ODS
list, an ODS textblock, or a table template.
312
Chapter 10
Example:
•
The ODSTEXT Procedure
“Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 329
Syntax
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)]>
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
Required Arguments
expression
is an expression that is evaluated for each list item, paragraph, or table cell.
If expression resolves to TRUE (a nonzero value), the style element that is specified
is used for the current cell. If expression is FALSE (zero), the next expression in the
statement is evaluated. Thus, you can string multiple expressions together to format
cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a string, a comparison, logical
operation, or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 10.1
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
CELLSTYLE AS Statement
313
Tip
Using an expression of 1 as the last expression in the CELLSTYLE AS
statement sets the style element for any cells that did not meet an earlier
condition. For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general
form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a table template, see
“Style Attributes Overview” on page 473.
Optional Argument
style-element-name
is the name of a style element that is part of a style that is registered with the Output
Delivery System. SAS provides some styles. You can create customized styles and
style elements with PROC TEMPLATE by using the “DEFINE STYLE Statement”
on page 462. For a table of style element names, see Chapter 21, “Style Elements,”
on page 831.
The following style elements are most likely to be used with the CELLSTYLE AS
statement:
•
Data
•
DataFixed
•
DataEmpty
•
DataEmphasis
•
DataEmphasisFixed
•
DataStrong
•
DataStrongFixed
•
ListItem
•
ListItem2
•
Paragraph
The style element provides the basis for displaying the cell. Additional style
attributes modify the display.
Default
Data
See
Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page
442
314
Chapter 10
•
The ODSTEXT Procedure
For a table of style element names, see Chapter 21, “Style Elements,” on
page 831.
DYNAMIC Statement
Defines a symbol that references a value that the data component supplies from the procedure or DATA
step.
Restriction:
The DYNAMIC statement can be used only in the template of an ODS textblock,
ODS list, table, column, header, or footer. A dynamic variable that is defined in a
template is available to that template and to all the templates that it contains.
Syntax
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
Required Argument
variable-name
names a variable that the data component supplies. ODS resolves the value of the
variable when it binds the template and the data component.
Tip
Dynamic variables are most useful to the authors of SAS procedures and to
DATA step programmers.
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the dynamic variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
END Statement
Ends item and list blocks.
Syntax
END;
ITEM Statement
Specifies an item to be added to the item list. An ITEM statement that does not specify an expression
begins an item block.
ITEM Statement 315
Restrictions:
The ITEM statement must be used within a LIST block.
ITEM statements that do not specify an expression must end with an END
statement.
Example:
“Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 329
Syntax
ITEM <expression> / <FORMAT=format-name> <STYLE=style-override> <VALUE=integer-value>;
Optional Arguments
expression
is an expression that specifies the content of an item. expression has this form:
expression-1 < expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a logical operation, a string, or an arithmetic calculation. An
operand is one of the following:
constant
is a fixed value, such as the name of a column, a text string, or symbols that
are declared in a DYNAMIC, MVAR, or NMVAR statement in the current
template.
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Restriction
ITEM statements that do not specify an expression must end with an
END statement.
FORMAT=format-name
specifies a default format for the value in each table cell or list item. You can use any
SAS or user-defined format.
Example
proc odstext data=sashelp.class;
list;
item age / format=2.;
end;
run;
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the specified item. For example, the following
statement specifies that the text color for the item is red:
item 'first item' / style=[color=red];
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
316
Chapter 10
•
The ODSTEXT Procedure
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
VALUE=integer-value
starts a numbered list from the specified integer-value. If another VALUE= option is
specified in subsequent statements, numbering begins again at that point.
Restriction
When VALUE= is specified, you must also specify a numbering list
type with the LISTSTYLETPYE= style attribute. For example,
LISTSTYLETYPE= “decimal_leading_zero” or
LISTSTYLETYPE=“decimal”.
Tip
You can change the bullet type of a list item by specifying the
“LISTSTYLETYPE=bullet-type” style attribute with the STYLE=
option.
Examples
The following example creates a list with three items that are numbered
7, 10, and 4.
proc odstext;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Seven" / value=7;
item "Ten" / value=10;
item "Four" / value=4;
end;
run;
The following example creates a list that begins numbering items with
the number 7.
proc odstext;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Seven" / value=7;
item "Eight";
end;
run;
Example
“Example 2: Creating Nested Lists” on page 237
LIST Statement
317
LIST Statement
Creates a list.
Restriction:
Example:
LIST statements begin a LIST statement block, and must end with an END
statement.
“Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 329
Syntax
LIST / <START=integer-value><STYLE=style-override> ;
Optional Arguments
START=integer-value
starts a numbered list from the specified integer-value. If another START= option is
specified in subsequent statements, the numbering begins again at that point.
Restrictions
When START= is specified, you must also specify a numbering list type
with the LISTSTYLETPYE= style attribute. For example,
LISTSTYLETYPE= "decimal_leading_zero" or
LISTSTYLETYPE="decimal" are numbering list types.
The START= option is valid for the PDF, POWERPOINT, HTML, and
RTF destinations.
Tip
You can change the bullet type of a list item by specifying the
“LISTSTYLETYPE=bullet-type” style attribute with the STYLE=
option.
Examples
The following example creates a list that begins numbering items with
the number 7.
proc odstext;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"} start=7;
item "Seven";
item "Eight";
end;
run;
The following example creates a list that assigns a specific number to
each item.
proc odstext;
p 'This is a numbered list';
list / style={liststyletype="decimal_leading_zero"};
item "Two" / value=2;
item "Four" / value=4;
item "Six" / value=6
end;
run;
318
Chapter 10
•
The ODSTEXT Procedure
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the items in the list. For example, the following
statement specifies that the text color for item is red:
item 'first item' / style=[color=red];
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
MVAR Statement
Defines a symbol that references a macro variable. ODS uses the value of the variable as a string.
References to the macro variable are resolved when ODS binds the template and the data component to
produce an output object.
Restriction:
When replaying an ODS document with PROC DOCUMENT, values created by the
MVAR statement must be re-created in the same session that is replaying the
document.
Tip:
You can use the MVAR statement in the template of an ODS list, ODS textblock,
table, column, header, or footer. A macro variable that is defined in a template is
available to that template and to all the templates that it contains.
See:
“Example 3: Creating a New Table Template ” on page 624 and “Example 1:
Creating a Stand-Alone Style” on page 521
Syntax
MVAR variable-name-1 <='value-1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
NMVAR Statement 319
Required Argument
variable-name
names a macro variable to reference in the template. ODS uses the value of the
macro variable as a string. ODS does not resolve the value of the macro variable
until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use the
automatic macro variable SYSDATE9 in a template, declare it in an MVAR
statement and reference it as SYSDATE9, without an ampersand, in the PROC
TEMPLATE or PROC ODSTABLE step. If you use the ampersand, the macro
variable resolves when the template is compiled instead of when ODS binds the
template to the data component.
Optional Arguments
value
sets the default variable value.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NMVAR Statement
Defines a symbol that references a macro variable. ODS converts the variable's value to a number (stored
as a double) before using it. References to the macro variable are resolved when ODS binds the template
and the data component to produce an output object.
Restriction:
See:
The NMVAR statement can be used only in the template of an ODS list, ODS
textblock, table, column, header, or footer. A macro variable that is defined in a
template is available to that template and to all the templates that it contains.
“Example 4: Setting the Style Element for Cells Based on Their Values” on page 632
Syntax
NMVAR variable-name-1 <='value–1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS converts the variable's
value to a number (stored as a double) before using it. ODS does not resolve the
macro variable until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use a macro
variable as a number, declare it in an NMVAR statement and reference it
without an ampersand. If you use the ampersand, the macro variable resolves
when the template is compiled instead of when ODS binds the template to the
data component.
320
Chapter 10
•
The ODSTEXT Procedure
Optional Arguments
value
sets the value of the variable.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
P Statement
Specifies a paragraph. Multiple P statements are allowed within an item block.
Restriction:
Example:
In the ODSLIST Procedure, the P statement can be specified only within an ITEM
block. In the ODSTEXT procedure, the P statement can be used at the top level of
PROC ODSTEXT as well as within list items.
“Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 329
Syntax
P expression / <FORMAT=format-name> <STYLE=style-override> ;
Required Argument
expression
is an expression that specifies the content of an item or paragraph. expression has
this form:
expression-1 < expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a logical operation or an arithmetic calculation. An operand
is one of the following:
constant
is a fixed value, such as the name of a column, text string, or symbols that are
declared in a DYNAMIC, MVAR, or NMVAR statement in the current
template.
For example, the following code creates a paragraph and an item list with
PROC ODSTEXT:
proc odstext data=sashelp.class;
p "My name is " || name;
list;
item;
p "My age is " || put(age, 2.);
p "My weight is " || put(weight, 3.);
end;
end;
run;
The following code creates an item list with PROC ODSLIST:
P Statement
321
proc odslist data=sashelp.class;
item;
p "My name is " || name;
list;
item;
p "My age is " || put(age, 2.);
p "My weight is " || put(weight, 3.);
end;
end;
end;
run;
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Restriction
ITEM statements that do not specify an expression must end with an
END statement.
Optional Arguments
FORMAT=format-name
specifies a default format for the value in each paragraph. You can use any SAS or
user-defined format.
STYLE=<style-element-name >[style-attribute-name=style-attribute-value<… styleattribute-name=style-attribute-value>]
specifies the style element to use for the items in the list or paragraph.
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style template that is registered
with the Output Delivery System. SAS provides some style templates. You can
create your own style templates with PROC TEMPLATE.
See
“Concepts: Styles and the TEMPLATE Procedure ” on page 444 for
information about PROC TEMPLATE and the default style templates.
For a list of style elements, see “Style Elements” in SAS Output Delivery
System: User's Guide.
style-attribute-name
specifies the attribute to change.
See
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid
values.
See
Examples
For information about style attributes and their values, see “Style
Attributes” in SAS Output Delivery System: User's Guide.
For example, the following statement specifies that the text color of the
paragraph is red:
p 'text block' / style=[color=red];
322
Chapter 10
•
The ODSTEXT Procedure
For example, the following statement specifies that the text color for the
item is red:
item 'first item' / style=[color=red];
TRANSLATE INTO Statement
Translates the specified numeric values to other values.
Restrictions:
The TRANSLATE INTO statement can be used only in a column template, an ODS
list, an ODS textblock, or a table template.
The TRANSLATE INTO statement in a table template applies only to numeric
variables. To translate the values of a character variable, use TRANSLATE INTO in
the template of that column.
Example:
“Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT”
on page 329
Syntax
TRANSLATE expression-1 INTO expression-2 <, expression-n INTO expression-m>;
Required Arguments
expression-1
is an expression that is evaluated for each list item, paragraph, table, or column cell
that contains a numeric variable.
If expression-1 resolves to TRUE (a nonzero value), the translation that is specified
is used for the current cell. If expression-1 is FALSE (zero), the next expression in
the statement is evaluated. Thus, you can string multiple expressions together to
format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
TRANSLATE INTO Statement 323
Table 10.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Restriction
You cannot reference the values of other columns in expression-1.
Tip
Using an expression of 1 as the last expression in the TRANSLATE–
INTO statement specifies a translation for any cells that did not meet an
earlier condition.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
expression-2
is an expression that specifies the value to use in the list, paragraph, or cell in place
of the variable's actual value.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
324
Chapter 10
•
The ODSTEXT Procedure
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 10.3
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
expression-2 must resolve to a character value, not a numeric value.
Tip
When you translate a numeric value to a character value, the table
template or column template does not try to apply the numeric format
that is associated with the column. Instead, it simply writes the
character value into the formatted field, starting at the left. To rightjustify the value, use the JUSTIFY=ON attribute.
See
“JUSTIFY<=ON | OFF | variable>;” on page 663 column attribute
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
Using the ODSTEXT Procedure
PROC ODSTEXT uses many of the same statements as PROC TEMPLATE to create
and customize your text. The CELLSTYLE AS, DYNAMIC, MVAR, NMVAR, and
TRANSLATE INTO statements are all valid statements within PROC ODSTEXT that
can be used to customize your text.
Changing the Bullet Type for Lists
325
Changing the Bullet Type for Lists
By default, lists created by the ODS TEXT procedure are displayed as an unordered list
with a disc as the bullet type. In markup family output, you can change the bullet type
for lists by using the following two steps:
1. Specify the LISTSTYLETYPE= style attribute with the desired bullet type in a style
override. The following shows the general syntax for specifying the
LISTSTYLETYPE= attribute::
STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
2. Specify the style override in an ITEM or LIST statement. The following shows the
general syntax for specifying a style override in the LIST or ITEM statements:
LIST / STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
ITEM / STYLE={ LISTSTYLETYPE="bullet-type" <more-style-attributes>}
When you specify LISTSTYLETYPE= in the LIST statement, the bullets for all of the
following items are changed. If you specify LISTSTYLETYPE= in an ITEM statement,
only the bullet for that ITEM statement is changed.
The following example creates a numbered list. Because the style override is specified in
the LIST statement, all of the items will have the same numbering scheme.
ods html5 file='entireList_html5.htm';
title;
proc odstext;
p 'Follow these steps to change the bullet type for lists:'
/ style={fontsize=12pt};
list / style={liststyletype="decimal" fontsize=12pt};
item "Decide what bullet type to display.";
item "Add a '/' after the LIST statement (if not already present).";
item "Specify the LISTSTYLETYPE= attribute with the STYLE= option.";
end;
run;
ods _all_ close;
Output 10.1 Changing the Bullet Type for All List Items
You can also change the bullet type for each individual item by specifying a style
override in each ITEM statement.
ods html5 file='individualItems_html5.htm';
326
Chapter 10
•
The ODSTEXT Procedure
title;
proc odstext;
p 'You can change the bullet type for each individual item.'
/ style={fontsize=12pt};
list / style={fontsize=12pt};
item "List items can be a square" / style={liststyletype="square"};
item "Or a circle" / style={liststyletype="circle"};
item "Or a disc" / style={liststyletype="disc"};
item "Or items can have no bullet" / style={liststyletype="none"};
end;
run;
ods _all_ close;
Output 10.2 Changing the Bullet Type for Individual Items
The following are browser-supported bullet types. However, many browsers support
other common types and the support is browser dependent. If an unsupported bullet type
is specified, the bullet’s display is browser dependent.
Table 10.4
Valid Bullet Types
Bullet Type
Description
Ordered Lists
decimal
The list items are ordered with numbers
(default).
upper_latin
The list items are ordered with uppercase
letters.
lower_latin
The list items are ordered with lowercase
letters.
upper_roman
The list items are ordered with uppercase
roman numerals.
lower_roman
The list items are ordered with lowercase
roman numerals.
Example 1: Creating Content for the ODS Destination for PowerPoint
Bullet Type
327
Description
Unordered Lists
disc
The list items are marked with filled circles.
circle
The list items are marked with circles.
square
The list items are marked with squares.
none
The list items are not marked.
Examples: The ODSTEXT Procedure
Example 1: Creating Content for the ODS Destination for PowerPoint
Features:
P statement
STYLE= option
PROC ODSTEXT statement
P statement
Other features:
FOOTNOTE statement
ODS HTML CLOSE statement
ODS POWERPOINT statement
OPTIONS statement
TITLE statement
Details
The following example creates text output to add to a Microsoft PowerPoint slide. You
can use the STYLE= option in the P statement to customize your text.
Program
ods html close;
options nodate;
title 'Using PROC ODSTEXT';
footnote 'The ODS Destination for PowerPoint';
ods powerpoint file="layoutTwocontent.ppt" layout=twocontent;
proc odstext;
p 'You can use the ODSTEXT procedure to add paragraphs
and lists to your output.';
p 'You can also format your text.' / style=[color=red fontsize=25pt];
p 'This slide shows output created by PROC GMAP.'
328
Chapter 10
•
The ODSTEXT Procedure
/ style=[color=purple fontsize=30pt];
run;
proc gmap map=maps.us data=maps.us all;
id state;
choro state/statistic=frequency discrete;
run;
quit;
ods _all_ close;
Program Description
Close the HTML destination, specify titles, and specify footnotes. The ODS HTML
destination is open by default in the SAS Windowing environment. If you are not
creating HTML output, close the HTML destination to conserve system resources.
ods html close;
options nodate;
title 'Using PROC ODSTEXT';
footnote 'The ODS Destination for PowerPoint';
Create a file for the ODS destination for PowerPoint. The ODS POWERPOINT
statement creates output formatted for the ODS destination for PowerPoint.
ods powerpoint file="layoutTwocontent.ppt" layout=twocontent;
Create content for the ODS destination for PowerPoint.
proc odstext;
p 'You can use the ODSTEXT procedure to add paragraphs
and lists to your output.';
p 'You can also format your text.' / style=[color=red fontsize=25pt];
p 'This slide shows output created by PROC GMAP.'
/ style=[color=purple fontsize=30pt];
run;
Create PROC GMAP output and close open destinations.
proc gmap map=maps.us data=maps.us all;
id state;
choro state/statistic=frequency discrete;
run;
quit;
ods _all_ close;
Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
329
Adding Text to Your Output
Output 10.3 Adding Text to Your Output
Example 2: Comparing Lists Created with PROC ODSLIST and PROC
ODSTEXT
Features:
ODSLIST Procedure
CELLSTYLE AS statement
END statement
ITEM statement
LIST statement
P statement:
PROC ODSLIST statement
TRANSLATE INTO statement
ODSTEXT Procedure
CELLSTYLE AS statement
END statement
ITEM statement
LIST statement
P statement
PROC ODSTEXT statement
TRANSLATE INTO statement
Other features:
OPTIONS statement
TITLE statement
Details
The following examples create similar output using PROC ODSLIST and PROC
ODSTEXT. Both procedures can be used to create lists and paragraphs. However, there
are differences in how the syntax of the two procedures can be specified. The following
table shows how the P, ITEM, and LIST statements are specified in each procedure.
330
Chapter 10
•
The ODSTEXT Procedure
PROC ODSTEXT
PROC ODSLIST
The P statement can be specified only within
an ITEM block.
The P statement can be used at the top level of
PROC ODSTEXT as well as within list items.
The ITEM statement must be used within a
LIST block.
The ITEM statement does not have to be
specified within a LIST block.
The LIST statement does not have to be
specified within an item block.
The LIST statement must be used within an
item block.
There are also slight differences in the appearance of the output created by the two
procedures. Examine the output created by the two programs in this example. Notice that
the spacing and bullet points are slightly different.
Program: Using PROC ODSLIST
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
proc odslist data=sashelp.class;
item;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
end;
end;
run;
Program Description
Specify the SAS system options and title.
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
Begin the ODSLIST procedure, begin an ITEM block, and specify explanatory text.
The PROC ODSLIST statement specifies the input data set and begins the procedure.
The ITEM statement with no options specified begins an ITEM block. The P statements
specify the explanatory text. In the ODSLIST Procedure, the P statement must be
specified within an ITEM block.
Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
331
proc odslist data=sashelp.class;
item;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
Begin the list and conditionally set the style attributes. The LIST statement with no
options specified begins a list block. The LIST statement must be used within an item
block. The CELLSTYLE AS statement sets the style attributes of the list items based on
the value of the variable Age. If the value of the variable Age is less than or equal to 13,
the background color is green. If the value of the variable Age is greater than or equal to
14, the background color is light purple.
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
Specify the items. The ITEM statements specify the content of each item.
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
Conditionally transform the value for the AGE variable. The TRANSLATE INTO
statement translates the value of Age based on the conditions specified. For values of the
variable AGE that are equal to or less than thirteen, "N/A" is written to the output.
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
End the LIST and ITEM blocks. The LIST block began with the LIST statement. An
END statement ends the LIST block. Both ITEM blocks began with an ITEM statement
with no expression specified. An END statement ends each ITEM block.
end;
end;
run;
332
Chapter 10
•
The ODSTEXT Procedure
Output 10.4 Output Created with the PROC ODSLIST
Program: PROC ODSTEXT
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
proc odstext data=sashelp.class;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
end;
run;
Program Description
Specify the SAS system options and title.
options nodate nonumber obs=7;
title "Students' Names, Ages, and Weights";
Begin the ODSTEXT procedure and specify explanatory text for the list. The PROC
ODSLIST statement specifies the input data set and begins the procedure. The P
Example 2: Comparing Lists Created with PROC ODSLIST and PROC ODSTEXT
333
statements specify the text that precedes the list. In the ODSTEXT procedure, the P
statement does not have to be specified within an ITEM block.
proc odstext data=sashelp.class;
p 'List of Students'' Names, Ages, and Weights' / style=systemtitle;
p 'Weights of children younger than fourteen are hidden for legal reasons'
/ style={fontstyle=italic};
Begin the list and conditionally set the style attributes. The LIST statement with no
options specified begins a list block. In the ODSTEXT procedure, the LIST statement
does not have to be specified within an item block. The CELLSTYLE AS statement sets
the style attributes of the list items based on the value of the variable Age. If the value of
the variable Age is less than or equal to 13, the background color is green. If the value of
the variable Age is greater than or equal to 14, the background color is light purple.
list;
cellstyle age<=13 as datastrong{background=green},
age>=14 as {background=lightpurple};
Specify the items. The ITEM statements specify the content of each item.
item 'Student name is ' || name;
item 'Age: ' || put(age, 2.);
Conditionally transform the value for the AGE variable. The TRANSLATE INTO
statement translates the value of Age based on the conditions specified. For values of the
variable AGE that are equal to or less than thirteen, "N/A" is written to the output. The
TRANSLATE INTO statement must be specified within the block of the variable you
want to be translated. Otherwise, the variable is translated and the results apply to all
variables.
item;
translate age<=13 into 'Weight: N/A';
p 'Weight: ' || put(weight, 3.);
end;
End the LIST block. The LIST block began with the LIST statement. An END statement
ends the LIST block.
end;
run;
334
Chapter 10
•
The ODSTEXT Procedure
Output 10.5 Output Created with the PROC ODSTEXT
335
Part 8
The TEMPLATE Procedure
Chapter 11
TEMPLATE Procedure: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Chapter 12
TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . . 349
Chapter 13
TEMPLATE Procedure: Creating Crosstabulation
Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Chapter 14
TEMPLATE Procedure: Creating ODS Graphics . . . . . . . . . . . . . . . . . . 435
Chapter 15
TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . . 441
Chapter 16
TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . . . 577
Chapter 17
Tabular Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Chapter 18
TEMPLATE Procedure: Creating Markup Language Tagsets . . . . . 695
336
337
Chapter 11
TEMPLATE Procedure: Overview
Introduction to the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introduction to the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terminology: TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Backward Compatibility of ODS Templates . . . . . . . . . . . . . . . . . . . . . . . . . .
337
337
338
339
Syntax: TEMPLATE Procedure: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Using the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
What Can You Do with the TEMPLATE Procedure? . . . . . . . . . . . . . . . . . . . . . . 342
PROC TEMPLATE Statements by Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Where to Go from Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Introduction to the TEMPLATE Procedure
Introduction to the TEMPLATE Procedure
The TEMPLATE procedure enables you to customize the appearance of your SAS
output. For example, you can create, extend, or modify existing templates for various
types of output:
•
styles
•
tables
•
crosstabulation tables
•
columns
•
headers
•
footers
•
tagsets
•
ODS Graphics
ODS then uses these templates to produce formatted output.
You can also use the TEMPLATE procedure to navigate and manage the templates
stored in template stores. Here are some tasks that you can do with PROC TEMPLATE:
•
edit an existing template
338
Chapter 11
•
TEMPLATE Procedure: Overview
•
create links to an existing template
•
change the location where you write new templates
•
search for existing templates
•
view the source code of a template
Terminology: TEMPLATE Procedure
These terms frequently appear in discussions of PROC TEMPLATE:
aggregate storage location
is a location on an operating system that can contain a group of distinct files.
Different host operating systems call an aggregate grouping of files different names,
such as a directory, a maclib, or a partitioned data set. The standard form for
referencing an aggregate storage location from within SAS is fileref(name), where
fileref is the entire aggregate and (name) is a specific file or member of that
aggregate.
event
specifies the text that the markup destination produces when the specified event
occurs. For example, the template of an event called ROW might specify to place the
appropriate tags for starting a row at the beginning of an event and the appropriate
tags for ending a row at the end of the event. SAS procedures that generate ODS
output use a standard set of events, which you can customize with the TEMPLATE
procedure.
graph template
describes the contents and structure of a single-cell or multi-cell graph.
item store
is a member of a SAS library. An item store is a hierarchical file system that is
implemented as a single physical file. An item store can contain directories and files
(called items) similar to the file systems in the UNIX and Windows operating
environments. An item store is referenced by a two-level name: a libref and the name
of the item store in the SAS library that the libref references. For example, the SAS
registry is stored in two items stores, Sasuser.Registry and Sashelp.Registry.
style (template)
describes how to display the presentation aspects (color, font face, font size, and so
on) of your SAS output. A style determines the overall appearance of the documents
that use it. Each style consists of style elements.
style element
is a collection of style attributes that apply to a particular part of the output. For
example, a style element can contain instructions for the presentation of column
headings or for the presentation of the data inside cells. Style elements can also
specify default colors and fonts for output that uses the style. Each style attribute
specifies a value for one aspect of the presentation. For example, the
BACKGROUND= attribute specifies the color for the background of an HTML
table, and the FONTSTYLE= attribute specifies whether to use a Roman, a slant, or
an italic font.
table template
describes how to display the output for a tabular output object. (Most ODS output is
tabular.) A table template determines the order of table headers and footers, the order
of columns, and the overall appearance of the output object that uses it. Each table
template contains or references table elements.
Introduction to the TEMPLATE Procedure
339
table element
is a collection of attributes that apply to a particular column, header, or footer.
Typically, these attributes specify something about the data rather than about its
presentation. For example, FORMAT= specifies the SAS format to use in a column.
However, some attributes describe presentation aspects of the data.
Note: You can also define table elements such as columns, headers, and footers
outside of a table template. Any table template can then reference these table
elements. For more information about defining columns, headers, and footers
outside of the table template, see Chapter 16, “TEMPLATE Procedure: Creating
Tabular Templates,” on page 578.
tagset
specifies instructions for creating a markup language for your SAS output. The
resulting output contains embedded instructions in order to define layout and some
content. Each tagset contains event templates and event attributes that control the
generation of the output. SAS provides tagsets for a variety of markup languages.
With the TEMPLATE procedure, you can modify any of these SAS tagsets, or you
can create your own tagsets.
template store
is an item store that stores templates that were created by the TEMPLATE procedure.
Templates that SAS provides are in the item store Sashelp.Tmplmst. You can store
templates that you create in any template store where you have Write access.
Note: A template store can contain multiple levels known as directories. When you
specify a template store in the ODS PATH statement, however, you specify a
two-level name that includes a libref and the name of a template store in the SAS
library that the libref references.
The Backward Compatibility of ODS Templates
ODS templates are not binary compatible between SAS versions. However, with some
templates, you can use a template created with an earlier version of SAS with a later
version of SAS. The following table lists the ODS templates and whether they are
forward or backward compatible between SAS versions.
Table 11.1
Compatibility of ODS Templates between SAS Versions
ODS Template
Backward Compatible
Forward Compatible
Table
No
Yes
Crosstabs
No
Yes
Style
No
Yes *
Tagset
No
No
ODS Graphics
No
No
* Styles that use inheritance might not be compatible forwards or backward. See
“Inheritance Compatibility across Versions” on page 459 for more information.
340
Chapter 11
•
TEMPLATE Procedure: Overview
If you would like to use a template created with a later version of SAS with an earlier
version of SAS, you might be able to extract the template source and use it to compile
the template in the earlier release.
Syntax: TEMPLATE Procedure: Overview
341
Syntax: TEMPLATE Procedure: Overview
PROC TEMPLATE;
DEFINE COLUMN column-path </ STORE=libref.template-store>;
<column-attribute-1; <...column-attribute-n;>>
statements
END;
DEFINE FOOTER footer-path </ STORE=libref.template-store>;
<footer-attribute-1; <...footer-attribute-n;>>
statements
END;
DEFINE HEADER template-name </ STORE=libref.template-store>;
<header-attribute-1; <...header-attribute-n;>>
statements
END;
DEFINE STYLE style-path </ STORE=libref.template-store>;
<PARENT= style-path;>
statements
END;
DEFINE TABLE table-path </ STORE=libref.template-store>;
<table-attribute-1; <...table-attribute-n;>>
statements
END;
DEFINE TAGSET tagset-path </ STORE=libref.template-store>;
DEFINE EVENT event-name;
<event-attribute-1; <...event-attribute-n;>>
statements
END;
DEFINE CROSSTABS table-path </ STORE=libref.template-store>;
statements
END;
DEFINE STATGRAPH graph-path </ STORE=libref.template-store>;
statements
END;
DELETE template-path </ STORE=libref.template-store >;
EDIT template-path-1 <AS template-path-2> </ STORE=libref.template-store > ;
statements-and-attributes
END;
LINK template-path-1 TO template-path-2 </ option(s)>;
LIST <starting-path></ option(s)>;
PATH location(s);
SOURCE template-path </ option(s)>;
TEST DATA=data-set </ STORE=libref.template-store>;
342
Chapter 11
•
TEMPLATE Procedure: Overview
Using the TEMPLATE Procedure
What Can You Do with the TEMPLATE Procedure?
Modify a Table Template That a SAS Procedure Uses
This output shows the use of a customized table template for the Moments output object
from PROC UNIVARIATE. The program used to create the modified table template
does the following:
•
creates and edits a copy of the default table template
•
edits a header within the table template
•
sets column attributes to enhance the appearance of the HTML output
For the code that creates the following default and customized output, see “Example 1:
Editing a Table Template That a SAS Procedure Uses” on page 613.
Output 11.1 Default Moments Table
Output 11.2 Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with
Microsoft Internet Explorer)
Using the TEMPLATE Procedure
343
Modify a Style
When you are working with styles, you are more likely to modify a style that SAS
supplies than to write a completely new style. The following output uses the
Styles.HTMLBlue template that SAS provides, but includes changes made to the style in
order to customize the output's appearance. For the code that creates this output, see
“Example 3: Modifying the Default Style with the CLASS Statement” on page 537.
In the contents file, the modified style makes changes to the following:
•
the text of the header and the text that identifies the procedure that produced the
output
•
the colors for some parts of the text
•
the font size for some parts of the text
•
the spacing in the list of entries in the table of contents
In the body file, the modified style makes changes to the following:
Figure 11.1
•
two of the colors in the color list. One of these colors is used as the foreground color
for the table of contents, the byline, and column headings. The other is used for the
foreground of many parts of the body file, including SAS titles and footnotes.
•
the font size for titles and footnotes.
•
the font style for headers.
•
the presentation of the data in the table by changing attributes like cellspacing, rules,
and borderwidth.
HTML Output (Viewed with Microsoft Internet Explorer)
344
Chapter 11
•
TEMPLATE Procedure: Overview
Create Your Own Tagset
Tagsets are used to create custom markup. You can create your own tagsets, extend
existing tagsets, or modify a tagset that SAS supplies. This display shows the results
from a new tagset TAGSET.MYTAGS.
To see the customized CHTML tagset, view the source from your web browser by
selecting View ð Source from your browser's toolbar.
Figure 11.2
MYTAGS.CHTML Output (Viewed with Microsoft Internet Explorer)
Create a Template-Based Graph
STATGRAPH templates are used to create output called ODS Graphics. For complete
information, see SAS Graph Template Language: User's Guide.
The following code creates the STATGRAPH template MyGraphs.Regplot, which
creates the following graph.
proc template;
define statgraph mygraphs.regplot;
begingraph;
Using the TEMPLATE Procedure
345
entrytitle "Regression Plot";
layout overlay;
modelband "mean";
scatterplot x=height y=weight;
regressionplot x=height y=weight / clm="mean";
endlayout;
endgraph;
end;
run;
ods listing style=analysis;
ods graphics / reset imagename="reg" width=500px;
proc sgrender data=sashelp.class template=mygraphs.regplot;
run;
The following display shows a scatter plot with an overlaid regression line and
confidence limits of the mean for the HEIGHT and WEIGHT variables of a data set.
Figure 11.3
Graph Created with a STATGRAPH Template
Modify a Crosstabulation Table
The TEMPLATE procedure enables you to customize the appearance of crosstabulation
(contingency) tables that are created with the FREQ procedure. By default,
crosstabulation tables are formatted according to the CrossTabFreqs template that SAS
provides. However, you can create a customized CrossTabFreqs table template by using
the TEMPLATE procedure with the DEFINE CROSSTABS statement. For the SAS code
346
Chapter 11
•
TEMPLATE Procedure: Overview
that creates this output, see “Example 2: Creating a Crosstabulation Table Template with
a Customized Legend” on page 416.
This output shows the use of a customized crosstabulation table template for the
CrossTabFreqs table. The program used to create the modified crosstabulation table
template does the following:
Figure 11.4
•
modifies table regions
•
customizes legend text
•
modifies headers and footers
•
modifies variable labels used in headers
•
customizes styles for cellvalues
Customized Crosstabulation Table Template for the CrossTabFreqs Table
PROC TEMPLATE Statements by Category
This table lists and describes the categories and statements used in the TEMPLATE
procedure.
PROC TEMPLATE Statements by Category 347
Table 11.2
Categories and PROC TEMPLATE Statements
Task
Statements Category
Statements
Description
Navigate template
stores and manage
ODS templates
Template store
DELETE
Deletes the specified
template
LINK
Creates a link to an
existing template
LIST
Lists items in one or more
template stores
PATH
Specifies the locations to
write to or read from when
creating or using PROC
TEMPLATE templates,
and the order in which to
search for them
SOURCE
Writes the source code for
the specified template
TEST
Tests the most recently
created template by
binding it to the specified
data set
Create or modify
ODS style
Style
DEFINE
STYLE
Creates a style for any
destination that supports
the STYLE= option
Create and
modify ODS
table, column,
header, and footer
templates
Tabular
EDIT
Edits an existing template
DEFINE
COLUMN
Creates a template for a
column
DEFINE
FOOTER
Creates a template for a
table footer
DEFINE
HEADER
Creates a template for a
header
DEFINE
TABLE
Creates a template for a
table
DEFINE
TAGSET
Creates a template for a
tagset
Create or modify
markup language
tagsets
Markup language tagsets
348
Chapter 11
•
TEMPLATE Procedure: Overview
Task
Statements Category
Statements
Description
Create or modify
a crosstabulation
table template
Tabular
DEFINE
CROSSTABS
Creates a template for a
PROC FREQ
crosstabulation table
Create or modify
a graph template
Graphical
DEFINE
STATGRAPH
Creates a template for a
graph
Where to Go from Here
Creating statistical graphics with ODS:
For reference information about the Graph Template Language, see SAS Graph
Template Language: Reference.
Creating statistical graphics with ODS:
For usage information about PROC TEMPLATE and the Graph Template Language,
see SAS Graph Template Language: User's Guide.
Managing the various templates stored in template stores:
For reference information about the PROC TEMPLATE statements that help you
manage and navigate around the many ODS templates, see Chapter 12,
“TEMPLATE Procedure: Managing Template Stores,” on page 349.
Modifying an existing style or creating your own style:
For reference information about the style template statements in PROC TEMPLATE,
see Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page 442.
Creating and modifying ODS tabular output:
For reference information about the tabular template statements in PROC
TEMPLATE, see Chapter 16, “TEMPLATE Procedure: Creating Tabular
Templates,” on page 577.
Modifying markup language tagsets that SAS provides or creating your own tagsets:
For reference information about the markup language tagset statements in PROC
TEMPLATE, see Chapter 18, “TEMPLATE Procedure: Creating Markup Language
Tagsets,” on page 696.
349
Chapter 12
TEMPLATE Procedure: Managing
Template Stores
Overview: Template Stores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
What Is a Template Store? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Why Use the TEMPLATE Procedure to Manage Template Stores? . . . . . . . . . . . 350
Concepts: Template Stores and the TEMPLATE Procedure . . . . . . . . . . . . . . . . . 350
The Contents of Templates That SAS Supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Syntax: TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . . . .
PROC TEMPLATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DELETE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LINK Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LIST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PATH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SOURCE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TEST Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
352
352
353
353
354
359
361
365
Examples: TEMPLATE Procedure: Managing Template Stores . . . . . . . . . . . . . 366
Example 1: Listing Templates in a Template Store . . . . . . . . . . . . . . . . . . . . . . . . 366
Example 2: Using a WHERE Expression to Select Items in a Template Store . . . 368
Example 3: Viewing the Source of a Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Overview: Template Stores
What Is a Template Store?
A template store is an item store that stores items that were created by the TEMPLATE
procedure. Items that SAS provides are in the item store Sashelp.Tmplmst. You can store
items that you create in any template store where you have Write access.
Note: A template store can contain multiple levels known as directories. When you
specify a template store in the ODS PATH statement, however, you specify a twolevel name that includes a libref and the name of a template store in the SAS library
that the libref references.
350
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Why Use the TEMPLATE Procedure to Manage Template Stores?
You can use the TEMPLATE procedure to manage and navigate the template stores that
store the items that SAS supplies or that you create. The TEMPLATE procedure enables
you to perform the following management tasks for the template stores:
•
delete column templates, header templates, footer templates, styles, table templates,
or tagsets
•
list items in one or more template stores
•
view the source code of column templates, header templates, footer templates, styles,
table templates, or tagsets
•
test the most recently created item
You can navigate around the template stores by doing the following:
•
create links to existing items
•
specify which locations to write to or read from when you create or use PROC
TEMPLATE items, and specify the order in which to search for them
Concepts: Template Stores and the TEMPLATE
Procedure
The Contents of Templates That SAS Supplies
SAS provides templates for these items:
•
tables
•
crosstabulation tables
•
SAS statistical graphics
•
styles
•
tagsets
To view the contents of a template, use the SAS windowing environment, the SAS
window command ODSTEMPLATES, or the TEMPLATE procedure.
•
SAS Windowing Environment
1. From the SAS Explorer, select View ð Results.
2. In the Results window, select the Results folder. Right-click to open the
Templates window.
3. To view the definitions or templates that SAS supplies, click the plus sign that is
next to the Sashelp.Tmplmst item store.
4. Click the plus sign that is next to an icon to view the contents of that template
store or directory in a template store. If there is no plus sign next to the icon,
double-click the icon to view the contents of that directory.
•
SAS Windowing Command
Concepts: Template Stores and the TEMPLATE Procedure
351
1. To view the Templates window, submit this command in the command bar:
odstemplates
This display shows the Templates window that contains the item stores
Sasuser.Templat and Sashelp.Tmplmst.
2. When you double-click an item store, such as Sashelp.Tmplmst, that item store
expands to list the directories where ODS templates are stored. The templates
that SAS provides are in the item store Sashelp.Tmplmst.
•
TEMPLATE Procedure
The SOURCE statement writes the source code for the specified template to the SAS
log. For example, if you want to view the source for all the objects in Base SAS,
submit this code:
proc template;
source base;
run;
Note: For more information, see “SOURCE Statement” on page 361.
From the Templates window, you can see the definitions and templates that SAS supplies
or that you created. This figure shows the styles that SAS supplies.
Figure 12.1 Templates That SAS Supplies
352
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Syntax: TEMPLATE Procedure: Managing
Template Stores
PROC TEMPLATE;
DELETE item-path< / STORE=libref.template-store >;
LINK item-path-1 TO item-path-2 </option(s)>;
LIST <starting-path></ option(s)>;
PATH location(s);
SOURCE item-path </option(s)><STORE=libref.template-store>;
TEST DATA=data-set< / STORE=libref.template-store>;
Statement
Task
Example
PROC
TEMPLATE
Begin a PROC TEMPLATE template
Ex. 1, Ex. 2,
Ex. 3
DELETE
Delete the specified item
LINK
Create a link to an existing item
LIST
List items in one or more template stores
Ex. 1, Ex. 2
PATH
Specify which locations to write to or read from when you
create or use PROC TEMPLATE items, and specify the
order in which to search for them
Ex. 1, Ex. 2,
Ex. 3
SOURCE
Write the source code for the specified item to the SAS
log
Ex. 3
TEST
Test the most recently created item by binding it to the
specified data set
PROC TEMPLATE Statement
Begins a PROC TEMPLATE template.
Syntax
PROC TEMPLATE;
DELETE item-path< / STORE=libref.template-store >;
LINK item-path-1 TO item-path-2 </option(s)>;
LIST <starting-path></ option(s)>;
PATH location(s);
SOURCE item-path </option(s)><STORE=libref.template-store>;
TEST DATA=data-set< / STORE=libref.template-store>;
LINK Statement
353
DELETE Statement
Deletes the specified item.
Examples:
“Example 2: Comparing the EDIT Statement to the DEFINE TABLE Statement” on
page 618
“Example 1: Editing a Table Template That a SAS Procedure Uses” on page 613
Syntax
DELETE item-path < / STORE=template-store; >
Required Argument
item-path
specifies an item to delete. An item-path consists of one or more names, separated by
periods. Each name represents a directory in a template store. (A template store is a
type of SAS file.) If the same item exists in multiple template stores, PROC
TEMPLATE deletes the item from the first template store in the current path where
you have Write access.
CAUTION:
Deleting a directory in a template store deletes all subdirectories and items
in the directory. If the path that you specify is a directory rather than an item,
PROC TEMPLATE deletes all the directories and all the items in that directory.
Optional Argument
STORE= template-store
specifies the template store where the template that you want to delete is stored.
LINK Statement
Creates a link to an existing item.
Tip:
Creating a link to an item has the same effect as creating a new item that inherits its
characteristics from another item (see the discussion of “PARENT= Statement” on
page 469. However, using a link is more efficient than using inheritance, because
linking does not actually create a new item.
Syntax
LINK item-path-1 TO item-path-2 </ option(s)>;
Required Arguments
item-path-1
specifies the path of the item to create. PROC TEMPLATE creates the item in the
first template store in the path that you can write to.
354
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
item-path-2
specifies the path of the item to link to. If the same item exists in multiple template
stores, PROC TEMPLATE uses the one from the first template store in the current
path that you can read.
Tip
PROC TEMPLATE does not confirm that item-path-2 exists when it compiles
the item.
Optional Arguments
NOTES= 'text'
specifies notes to store in the item.
Requirement
Enclose the text in quotation marks.
Tip
Notes of this type become part of the compiled item, which you can
view with the SOURCE statement, whereas SAS comments do not.
STORE=libref.template-store
specifies the location where the link is created.
Restriction
The STORE= option syntax does not become part of the compiled
item.
Tip
The link always points to the first item with the same name that it finds
in the ODS path.
LIST Statement
Lists the items in one or more template stores.
Example:
“Example 1: Listing Templates in a Template Store” on page 366
Syntax
LIST <starting-path></ option(s)>;
Optional Argument
starting-path
specifies a level within each template store where PROC TEMPLATE starts listing
items. For example, if starting-path is base.univariate, PROC TEMPLATE
lists only base.univariate and the items within it and within all the levels that it
contains.
Default
If you omit a starting-path, then the LIST statement lists all items in all
template stores unless the ODS PATH statement confines the search to
the specified template stores.
Restriction
This option must precede the forward slash (/) in the LIST statement.
LIST Statement
355
Options
SORT=statistic <sorting-order>
sorts the list of items by the specified statistic in the specified sorting order.
statistic
is one of the following:
CREATED
is the date on which the item was created.
NOTES
is the content of any NOTES statement in the PROC TEMPLATE step that
created the item.
Alias
LABEL
LINK
is the name of the item that the current item links to (see “LINK Statement”
on page 353).
PATH
is the path to the current item in the template store. (The path does not
include the name of the template store).
SIZE
is the size of the item.
TYPE
is the type of the item: COLUMN, FOOTER, HEADER, STYLE, TABLE, or
LINK. If the item is simply a level in the item store, its type is DIR.
Default
PATH
sorting-order
specifies whether SORT= sorts from low values to high values or from high
values to low values.
ASCENDING
sorts from low values to high values.
Alias
A
DESCENDING
sorts from high values to low values.
Alias
Default
D
ASCENDING
STATS=ALL | STORE | (statistic-1 <, … statistic-n>)
specifies the information to include in the list of items.
ALL
includes all available information.
STORE
specifies the name of the template store that contains the items.
(statistic-1 <, … statistic-n>)
includes the specified information. statistic is one or more of the following:
356
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
CREATED
is the date on which the item was created.
NOTES
is the content of any NOTES statement in the PROC TEMPLATE step that
created the item.
Alias
LABEL
LINK
is the name of the item that the current item links to (see “LINK Statement”
on page 353).
SIZE
is the size of the item.
Default
Whether or not you specify STATS=, the list of items always includes
an observation number, the path to the item, and its type.
STORE=libref.template-store
specifies the template store to process.
Default
All template stores in the current template path.
See
For information about setting the current template path, see the “PATH
Statement” on page 359.
WHERE=where-expression
selects, for listing, items that meet a particular condition. For example, the following
statement lists items that contain the word "Default" in the path to the current
template:
list / where=(path ? 'Default');
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
where-expression has this form:
(subsetting-variable <comparison-operator where-expression-n>)
subsetting-variable
is a special type of WHERE expression operand used by the SOURCE
statement to help you find common values in items. Subsetting variables are
one or more of the following:
PATH | _PATH_
is the fully qualified path of a template.
Aliases
NAME | _NAME_
TEMPLATE | _TEMPLATE_
Example
This SOURCE statement displays the code for all items that
contain the word "Default" in the name of the current
template:
source / where=(path ? 'Default'); run;
.
LIST Statement
357
STORE
is the name of the template store that contains the item.
TYPE | _TYPE_
is the type of the item. TYPE is one of the following:
COLUMN
specifies that the template is a column in a table.
FOOTER
specifies that the template is a footer in a table.
HEADER
specifies that the template is a header in a table.
LINK
specifies that the template is a link or URL.
STYLE
specifies that the definition is a style.
TABLE
specifies that the definition is a table template.
TAGSET
specifies that the definition is a tagset.
Example
This SOURCE statement displays the source code for all tagsets that have
the word "Default" in the path:
source / where=(lowcase(type) = 'tagset' && _path_ ? 'Default');
The LOWCASE function converts all letters in an argument to lowercase.
NOTES
is the content of any NOTES statement in the PROC TEMPLATE step
that created the item. The contents is displayed in the LABEL field.
Alias
LABEL
Example
This SOURCE statement displays the source code for all items
where the label contains the words "common matrix" and the item
is a link:
source / where=(lowcase(label) ?
'common matrix' && _type_ = 'Link');
run;
The LOWCASE function converts all letters in an argument to
lowercase.
SIZE
is the size of the item in bytes.
Example
This SOURCE statement displays the source code for all items
that are larger than 70000 bytes:
source / where=(size > 70000);
run;
CREATED
is the date on which the item was created.
358
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Example
This SOURCE statement displays the source code for all of
the items that were created today in all of the template stores
in the current template path:
source / where=(datepart(created) = today());
The DATEPART function extracts the date from a SAS
datetime value.
CDATE | _CDATE_
is the creation date of the item.
Example
This SOURCE statement displays the source code for all of
the items with a creation date of 16JUL2004:
source / where=(_cdate_ = '16JUL2004'd);
run;
CDATETIME | _CDATETIME_
is the creation datetime of the item.
Example
This SOURCE statement displays the source code for all items
with a creation SAS datetime of May 1, 2003 at 9:30:
source / where=(_cdatetime_ = '01may04:9:30:00'dt);
run;
CTIME | _CTIME_
is the creation time of the item.
Example
This SOURCE statement displays the source code of all items
with a creation time of 9:25:19 PM:
source / where=(_ctime_ = '9:25:19pm't);
run;
MDATE | _MDATE_
is the modification date of the item.
Example
This SOURCE statement displays the source code of all items
with a modification date of 16JUL2004:
source / where=(_mdate_ = '16JUL2004'd);
run;
MDATETIME | _MDATETIME_
is the modification datetime of the item.
Example
This SOURCE statement displays the source code of all items
with a modification SAS datetime of May 1, 2003 at 9:30:
source / where=(_mdatetime_ = '01may04:9:30:00'dt);
run;
MODIFIED
is the date on which the item was modified.
Example
This SOURCE statement displays the source code of all items
that were modified today in all of the template stores in the
current template path:
source / where=(datepart(modified) = today());
The DATEPART function extracts the date from a SAS
datetime value.
PATH Statement
359
MTIME |_MTIME_
is the modification time of the item.
Example
This SOURCE statement displays the source code of all items
with a modification time of 9:25:19 PM:
source / where=(_mtime_ = '9:25:19pm't);
run;
comparison-operator
compares a variable with a value or with another variable. The following
table lists the comparison operators:
Table 12.1
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
See
For information about expressions that you can use in the WHERE data
set option, see the WHERE data set option and the section on WHEREExpression Processing.
Example
“Example 2: Using a WHERE Expression to Select Items in a Template
Store ” on page 368
PATH Statement
Specifies locations to write to or read from when you create or use PROC TEMPLATE templates or
definitions, and specifies the order in which to search for them. This statement overrides the ODS PATH
statement for the duration of the PROC TEMPLATE step.
Examples:
“Example 1: Listing Templates in a Template Store” on page 366
“Example 3: Viewing the Source of a Template” on page 370
Syntax
PATH <(APPEND) | (PREPEND) | (REMOVE)> location(s);
PATH path-argument;
360
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Required Arguments
location(s)
specifies one or more locations to write to or read from when creating or using
PROC TEMPLATE items and the order in which to search for them. ODS searches
the locations in the order in which they appear on the statement. It uses the first
definition that it finds that has the appropriate access mode (Read, Write, or Update)
set.
Each location has this form:
<libref.>item-store <(READ | UPDATE | WRITE)>
<libref.>item-store
identifies an item store to read from, to write to, or to update. If an item store
does not already exist, then the PATH statement creates it.
(READ | UPDATE | WRITE)
specifies the access mode for the item. An access mode is one of the following:
READ
provides Read-Only access.
WRITE
provides Write access (always creating a new template store) as well as Read
access.
UPDATE
provides Update access (creating a new template store only if the specified
one does not exist) as well as Read access.
Default
READ
Default
The general default path is as follows: Sasuser.Templat (UPDATE),
Sashelp.Tmplmst (READ). If you have specified the RSASUSER SAS
system option, then the default path is as follows:
Work.Templat(UPDATE), Sasuser.Templat (READ),
Sashelp.Tmplmst(READ). SAS stores all the items that it provides in
Sashelp.Tmplmst.
Tip
If you want to be able to ignore all the items that you create, then keep
them in their own item stores so that you can leave them out of the list of
item stores that ODS searches.
See
“RSASUSER System Option” in SAS System Options: Reference for more
information about how to open the Sasuser library for Read access or
Read-Write access.
path-argument
sets or displays the ODS path.
path-argument is one of the following:
RESET
sets the ODS path to the default settings Sasuser.Templat (UPDATE) and
Sashelp.Tmplmst (READ).
SHOW
displays the current ODS path.
SOURCE Statement 361
VERIFY
sets the ODS path to include only templates supplied by SAS. Specifying
VERIFY is the same as specifying ODS PATH Sashelp.Tmplmst (READ).
Optional Argument
(APPEND | PREPEND | REMOVE )
adds one or more locations to a path, or removes one or more locations from a path.
APPEND
adds one or more locations to the end of a path. When you append a location to a
path, all duplicate instances (with the same name and same permissions) of that
item store are removed from the path. Only the last item store with the same
name and permissions is kept.
PREPEND
adds one or more locations to the beginning of a path. When you prepend a
location to a path, all duplicate instances (with the same name and same
permissions) of that item store are removed from the path. Only the first item
store with the same name and permissions is kept.
REMOVE
removes one or more locations from a path.
Default
If you omit an APPEND, PREPEND, or REMOVE option, then the PATH
statement overwrites the complete path.
SOURCE Statement
Writes the source code for the template specified to the SAS log.
Example:
“Example 3: Viewing the Source of a Template” on page 370
Syntax
SOURCE item-path </ option(s)>;
Required Argument
item-path
specifies the path of the item that you want to write to the SAS log. If the same item
exists in multiple template stores, PROC TEMPLATE uses the one from the first
template store that you can read in the current path.
Tip
PROC TEMPLATE stores items in compiled form. The SOURCE statement
actually decompiles the item. Because SAS comments are not compiled,
comments that are in the source code do not appear when you decompile the
item. If you want to annotate the item, use the NOTES statement inside the
item or the block of editing instructions, or use the NOTES= option in the
LINK statement. These notes do become part of the compiled item. (See the
“NOTES Statement” on page 603 and the discussion of the “LINK Statement”
on page 353. You can also specify notes as quoted strings in the DYNAMIC,
MVAR, NMVAR, REPLACE, and STYLE statements.)
362
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Optional Arguments
EXPAND
prints the source of all parents of a template.
The following PROC TEMPLATE block prints all of the parents of the
template base.contents.variables:
Example
proc template;
source base.contents.variables / expand;
run;
FILE= 'file-specification' | fileref
specifies a file to write the item to.
'file-specification'
is the name of an external file to write to.
Requirement
The external-file that you specify must be enclosed in quotation
marks.
fileref
is a file reference that has been assigned to an external file. Use the FILENAME
statement to assign a fileref.
Default
If you omit a filename where you want the source code written, then the
SOURCE statement writes the source code to the SAS log.
See
"Statements" in SAS Statements: Reference for information about the
FILENAME statement.
NOFOLLOW
specifies that the program does not resolve links in the PARENT= statement, which
specifies the item that the current item inherits from. For information about the
PARENT= statement, see “PARENT= Statement” on page 469 in the styles attribute
section.
STORE= libref.template-store
specifies the template store where the item is located.
Interaction
In most cases, the STORE= option is added to the definition statement
when PROC TEMPLATE displays the source code. However, if the
template store specified in the STORE= option is in the ODS path with
only Read permission, then PROC TEMPLATE does not include the
STORE= option in the source code that it displays. If there is no
STORE= option, when you run the code, then the item that it creates
goes to the first template store for which you have Update permission
in the ODS path.
WHERE=(where-expression)
selects items that meet a particular condition. For example, the following statement
displays the source code for items that contain the word "Default" in the path to the
current template: source / where=(path ? 'Default');
where-expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands.
where-expression has this form:
(subsetting-variable <comparison-operator where-expression-n>)
SOURCE Statement 363
subsetting-variable
a special type of WHERE expression operand used by the SOURCE
statement to help you find common values in items. Subsetting variables are
one or more of the following:
PATH | _PATH_
is the fully qualified path of a template.
Aliases
NAME | _NAME_
TEMPLATE | _TEMPLATE_
Example
This SOURCE statement displays the code for all items that
contain the word "Default" in the name of the current
template:
source / where=(path ? 'Default'); run;
TYPE | _TYPE_
is the type of the item. TYPE is one of the following:
COLUMN
specifies that the template is a column in a table.
FOOTER
specifies that the template is a footer in a table.
HEADER
specifies that the template is a header in a table.
LINK
specifies that the template is a link or URL.
STYLE
specifies that the definition is a style.
TABLE
specifies that the definition is a table template .
TAGSET
specifies that the definition is a tagset.
Example
This SOURCE statement displays the source code for all tagsets that have
the word "Default" in the path:
source / where=(lowcase(type) = 'tagset' && _path_ ? 'Default');
The LOWCASE function converts all letters in an argument to lowercase.
NOTES
is the content of any NOTES statement in the PROC TEMPLATE step
that created the item. The contents is displayed in the LABEL field.
Alias
LABEL
Example
This SOURCE statement displays the source code for all items
where the label contains the words "common matrix" and the item is
a link:
source / where=(lowcase(label) ?
'common matrix' && _type_ = 'Link');
run;
The LOWCASE function converts all letters in an argument to
lowercase.
364
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
SIZE
is the size of the item in bytes.
Example
This SOURCE statement displays the source code for all items
that are larger than 70000 bytes:
source / where=(size > 70000);
run;
CREATED
is the date on which the item was created.
Example
This SOURCE statement displays the source code for all of
the items that were created today in all of the template stores
in the current template path:
source / where=(datepart(created) = today());
The DATEPART function extracts the date from a SAS
datetime value.
CDATE | _CDATE_
is the creation date of the item.
Example
This SOURCE statement displays the source code for all of
the items with a creation date of 16JUL2004:
source / where=(_cdate_ = '16JUL2004'd);
run;
CDATETIME | _CDATETIME_
is the creation datetime of the item.
Example
This SOURCE statement displays the source code for all items
with a creation SAS datetime of May 1, 2003 at 9:30:
source / where=(_cdatetime_ = '01may04:9:30:00'dt);
run;
CTIME | _CTIME_
is the creation time of the item.
Example
This SOURCE statement displays the source code of all items
with a creation time of 9:25:19 PM:
source / where=(_ctime_ = '9:25:19pm't);
run;
MDATE | _MDATE_
is the modification date of the item.
Example
This SOURCE statement displays the source code of all items
with a modification date of 16JUL2004:
source / where=(_mdate_ = '16JUL2004'd);
run;
MDATETIME | _MDATETIME_
is the modification datetime of the item.
Example
This SOURCE statement displays the source code of all items
with a modification SAS datetime of May 1, 2003 at 9:30:
source / where=(_mdatetime_ = '01may04:9:30:00'dt);
run;
TEST Statement
365
MODIFIED
is the date on which the item was modified.
Example
This SOURCE statement displays the source code of all items
that were modified today in all of the template stores in the
current template path:
source / where=(datepart(modified) = today());
The DATEPART function extracts the date from a SAS
datetime value.
MTIME |_MTIME_
is the modification time of the item.
Example
This SOURCE statement displays the source code of all items
with a modification time of 9:25:19 PM:
source / where=(_mtime_ = '9:25:19pm't);
run;
comparison-operator
compares a variable with a value or with another variable. The following
table lists the comparison operators:
Table 12.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
See
For information about expressions that you can use in the WHERE data set
option, see the WHERE data set option and the section on WHEREExpression Processing.
TEST Statement
Tests the most recently created item by binding it to the specified data set.
366
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Syntax
TEST DATA=data-set </ STORE=libref.template-store>;
Required Argument
DATA=data-set
specifies the SAS data set to bind to the most recently created item. ODS sends this
output object to all open ODS destinations.
Optional Argument
STORE=libref.template-store
specifies the template store where the item is located.
Requirement
If you specify this option, then the template store that you specify
must match the template store in the DEFINE statement that created
the item.
Examples: TEMPLATE Procedure: Managing
Template Stores
Example 1: Listing Templates in a Template Store
Features:
PATH statement
LIST statement:
starting-path option
SORT= option
Details
This example lists the items for the Base.Univariate directory in the item store
Sashelp.Tmplmst.
Program
proc template;
path sashelp.tmplmst;
list base.univariate / sort=path descending;
run;
Program Description
Specify which locations to search for items that were created by PROC TEMPLATE.
The PATH statement specifies to search for templates and definitions that were created
by PROC TEMPLATE in the Sashelp.Tmplmst item store.
Example 1: Listing Templates in a Template Store
367
proc template;
path sashelp.tmplmst;
List in descending order the items that are stored within a specified level of the
template store. The LIST statement lists the templates and definitions in one or more
template stores. The starting path base.univariate specifies the level within the
template store where PROC TEMPLATE is to start listing the items. The SORT= option
sorts the list of items. The items are sorted in descending order.
list base.univariate / sort=path descending;
run;
368
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Output
Output 12.1 Partial Listing of Base.Univariate Template Store
Example 2: Using a WHERE Expression to Select Items in a Template
Store
Features:
PATH statement
LIST statement:
where-expression option
starting-path option
Example 2: Using a WHERE Expression to Select Items in a Template Store
369
SORT= option
Details
This example uses a WHERE expression to select, for listing, fitted distribution table
templates in the Base.Univariate directory.
Program
proc template;
path sashelp.tmplmst;
list base.univariate / sort=path descending
where=(lowcase(path) ? 'fit');
run;
Program Description
Specify which locations to search for items that were created by PROC TEMPLATE.
The PATH statement specifies to search for items that were created by PROC
TEMPLATE in the Sashelp.Tmplmst item store.
proc template;
path sashelp.tmplmst;
List, in descending order, the items with the word "fit" in their pathname. The LIST
statement lists the items in one or more template stores. The starting path
base.univariate specifies the level within the template store where PROC
TEMPLATE is to start listing the items. The WHERE expression finds items in the
template store that have the word "fit" in their pathname. The LOWCASE function
converts all letters in an argument to lowercase. The SORT= option sorts the list of
items. The items are sorted in descending order.
list base.univariate / sort=path descending
where=(lowcase(path) ? 'fit');
run;
370
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Output
Output 12.2 Listing of Fitted Distribution Templates in the Base.Univariate Template Store
Example 3: Viewing the Source of a Template
Features:
PATH statement
SOURCE statement
Details
This example displays the source code for the Style_popup tagset that SAS provides.
Program
proc template;
path sashelp.tmplmst;
source Tagsets.Style_popup;
run;
Program Description
Specify which locations to search for items that were created by PROC TEMPLATE.
The PATH statement specifies to search for items that were created by PROC
TEMPLATE in the Sashelp.Tmplmst item store.
proc template;
Example 3: Viewing the Source of a Template
371
path sashelp.tmplmst;
Write the source code of the specified item. The SOURCE statement writes the source
code for the tagset Style_popup that SAS provides. The source code is written to the
SAS log.
source Tagsets.Style_popup;
run;
372
Chapter 12
•
TEMPLATE Procedure: Managing Template Stores
Partial Source Code of the Template Tagset.Style_Popup That Is Written to
the SAS Log
1
proc template;
NOTE: Writing HTML Body file: sashtml.htm
2
path sashelp.tmplmst;
3
source Tagsets.Style_popup;
define tagset Tagsets.Style_popup;
notes "This is HTML pop up styles.";
define
put
put
put
event style_class;
"." HTMLCLASS " {font-family: " HTMLCLASS "}" NL;
"." HTMLCLASS NL;
"{" NL;
trigger stylesheetclass;
put "}" NL;
trigger linkclass /if exists( linkcolor);
trigger vlinkclass /if exists( visitedlinkcolor);
trigger alinkclass /if exists( activelinkcolor);
end;
define event doc_head;
start:
put "<head>" NL;
put VALUE NL;
finish:
trigger popup_script;
put "</head>" NL NL;
end;
define event stylesheet_link;
set $stylesheet_idx "0";
break /if ^exists( url);
put "<style type=""text/css"">" NL "<!--" NL;
trigger alignstyle;
put "-->" NL "</style>" NL;
set $urlList url;
... more log output ...
%nrstr("
if %( element.parentElement &&
element.parentElement.parentElement &&
element.parentElement.parentElement.className %)") NL;
put "
{" NL;
put "
element.style.backgroundColor = '#ff6666';" NL;
put "
element.style.color = 'white';" NL;
put "
element.title = element.parentElement.parentElement.className;"
NL;
put "
}" NL;
put %nrstr("
if %( element.parentElement &&
element.parentElement.className %)") NL;
put "
{" NL;
put "
element.style.backgroundColor = '#ff6666';" NL;
put "
element.style.color = 'white';" NL;
put "
element.title = element.parentElement.className;" NL;
put "
}" NL;
put "
if ( element.className )" NL;
put "
{" NL;
put "
element.style.backgroundColor = '#ff6666';" NL;
put "
element.style.color = 'white';" NL;
put "
element.title = element.className;" NL;
put "
}" NL;
put "
window.event.cancelBubble = 1;" NL;
373
Chapter 13
TEMPLATE Procedure: Creating
Crosstabulation Table Templates
Overview: ODS Crosstabulation Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . 374
Using the TEMPLATE Procedure to Create a Customized Crosstabulation Table 374
What Can You Do with a Crosstabulation Template? . . . . . . . . . . . . . . . . . . . . . . 374
Concepts: Crosstabulation Output and the TEMPLATE Procedure . . . . . . . . . . 377
What Makes the Crosstabulation Table Unique? . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Comparison between Table Templates and Crosstabulation Table Templates . . . . 377
Syntax: TEMPLATE Procedure: Creating Crosstabulation Table Templates . . . 378
PROC TEMPLATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
CELLSTYLE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
CELLVALUE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
DEFINE CELLVALUE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
DEFINE CROSSTABS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
DEFINE FOOTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
DEFINE HEADER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
DYNAMIC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
FOOTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
HEADER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
NOTES Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
TEXT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Using Crosstabulation Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Working with the CrossTabFreqs Crosstabulation Table Template . . . . . . . . . . . . 401
Crosstabulation Table Regions and Corresponding Attributes . . . . . . . . . . . . . . . . 402
Examples: TEMPLATE Procedure: Creating Crosstabulation Table Templates
Example 1: Creating a Customized Crosstabulation Table
Template with No Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 2: Creating a Crosstabulation Table Template with a
Customized Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 3: Adding Custom Formats to Cellvalues . . . . . . . . . . . . . . . . . . . . . . . .
403
403
416
428
374
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Overview: ODS Crosstabulation Table Templates
Using the TEMPLATE Procedure to Create a Customized
Crosstabulation Table
The TEMPLATE procedure enables you to customize the appearance of crosstabulation
(contingency) tables that are created with the FREQ procedure.
By default, crosstabulation tables are formatted according to the CrossTabFreqs template
that SAS provides. However, you can create a customized CrossTabFreqs table template
by using the TEMPLATE procedure with the statements in the following table.
Table 13.1
PROC TEMPLATE Statements
Task
Statement
Create a crosstabulation table template
DEFINE CROSSTABS
Define a value that appears in the crosstabulation
cells
DEFINE CELLVALUE
Specify the order in which the cellvalues are
stacked in the cells
CELLVALUE
Create a template for a footer
DEFINE FOOTER
Create a template for a header
DEFINE HEADER
End a crosstabulation table template
END
What Can You Do with a Crosstabulation Template?
The CrossTabFreqs crosstabulation template describes how to display PROC FREQ's
crosstabulation table. You can create a customized CrossTabFreqs crosstabulation
template to do the following:
•
use custom formats for cellvalues
•
specify a style for each value in a cell
•
change the stacking order of values in a cell
•
change and style headers and footers
•
use variable labels in headers and footers
•
style table regions independently
•
change or remove the legend
The following display shows a crosstabulation table that has been created with the
default crosstabulation table template:
Overview: ODS Crosstabulation Table Templates
Figure 13.1
375
Crosstabulation Table Created with Default Crosstabulation Table Template
The following display shows PROC FREQ output that has been created with a modified
CrossTabFreqs template:
376
Chapter 13
Figure 13.2
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Crosstabulation Table Created with Modified Crosstabulation Table Template
The following are some of the customizations that were made to the preceding
crosstabulation table:
•
The legend text has been italicized and made smaller than the rest of the header text.
•
The header text now uses the variable label "Gender of Patient" instead of the
variable name.
•
Row variable labels and column variable labels are used now instead of row variable
names and column variable names.
•
The background color of the non-summary rows alternates.
•
The values in the grand total cell are now bold and italic.
•
The Deviation cellvalues are now red when the deviation exceeds abs (2.0).
•
The TotalPercent cellvalue has been moved from the middle of the other cellvalues
to the bottom of the cellvalues.
Concepts: Crosstabulation Output and the TEMPLATE Procedure
377
Concepts: Crosstabulation Output and the
TEMPLATE Procedure
What Makes the Crosstabulation Table Unique?
Crosstabulation tables produced by PROC FREQ are different from other tables that
SAS produces. Most other tables consist of rows and columns with one value for each
row-column combination. However, the crosstabulation table has these distinctive
characteristics:
multiple values per cell
The crosstabulation table can have up to nine values for each row-column
combination, depending on the options specified by the TABLES statement. Most
other tables that SAS creates have only one value for each row-column combination.
legend
Crosstabulation tables have a separate box that is called a legend. The legend
contains the labels for the cellvalues. No other table that SAS produces has a legend.
row variable column
The far left column contains the row variable values. Each value in this column
provides a label for the row in the same way that the column variable values provide
labels for the columns.
column variable headers
Each value in these headers provides a label for the columns of the table.
row and column totals
The far right column contains the row totals. The bottom row contains the column
totals.
grand total cell
The grand total cell is the last cell of the row and column totals.
Comparison between Table Templates and Crosstabulation Table
Templates
Because the crosstabulation table is unique, the syntax used to create crosstabulation
templates differs significantly from other table templates.
•
The crosstabulation template has no parent template, and it cannot serve as a parent
to another template.
•
Most of the attributes, such as CENTER and PANELS=, that are defined for classic
table templates are not defined in the crosstabulation table template.
•
Crosstabulation table templates use DEFINE CELLVALUE blocks instead of the
DEFINE COLUMN blocks that are used in other table templates.
•
Crosstabulation table templates use the CELLVALUE statement instead of the
COLUMN statement that is used in other table templates.
•
Both crosstabulation table templates and other table templates use DEFINE
HEADER and DEFINE FOOTER blocks. However, the attributes that can be used in
each of these blocks differ.
378
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
•
DEFINE HEADER and DEFINE FOOTER blocks can contain multiple TEXT
statements only in crosstabulation table templates. ODS then chooses which TEXT
statement to use at execution time.
•
A TEXT statement can specify a WHERE expression only in crosstabulation table
templates. ODS uses the WHERE expression to determine whether to use the TEXT
statement text as the header text.
•
The CELL_STYLE, COLS_HEADER, COL_TOTAL_STYLE, COL_VAR_STYLE,
GRAND_TOTAL_STYLE, LEGEND_STYLE, ROWS_HEADER, and
ROW_VAR_STYLE attributes are unique to the crosstabulation table.
•
The ROWS_HEADER and COLS_HEADER attributes are unique to the
crosstabulation table.
•
The NVAR, MVAR, and TRANSLATE-INTO statements are not supported for
crosstabulation templates.
Syntax: TEMPLATE Procedure: Creating
Crosstabulation Table Templates
PROC TEMPLATE
DEFINE CROSSTABS table-path </ STORE=libref.template-store>;
<table-attribute-1; <table-attribute-n>;>
CELLVALUE cellvalues;
DEFINE CELLVALUE cellvalue;
statements-and-attributes;
END;
DEFINE HEADER header-name;
statements-and-attributes;
END;
DEFINE FOOTER footer-name;
statements-and-attributes;
END;
DYNAMIC variable-1 <'text-1'> <variable-n <'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
NOTES text;
END;
Statement
Task
Example
PROC
TEMPLATE
Begin a PROC TEMPLATE template
Ex. 1, Ex. 2,
Ex. 3
CELLSTYLE AS
Set the style element of the cells in the column according
to the values of the variables
Ex. 1, Ex. 2
CELLVALUE
Specify the order in which the cellvalues are stacked in
the cells
Ex. 1, Ex. 2
PROC TEMPLATE Statement
379
Statement
Task
Example
DEFINE
CELLVALUE
Define a value that appears in the crosstabulation cells
Ex. 1, Ex. 2
DEFINE
CROSSTABS
Create a crosstabulation table template
Ex. 1, Ex. 2,
Ex. 3
DEFINE
FOOTER
Create a template for a footer
Ex. 1, Ex. 2
DEFINE
HEADER
Create a template for a header
Ex. 1, Ex. 2
DYNAMIC
Define a symbol that references a value that the data
component supplies from the procedure or DATA step
Ex. 1, Ex. 2
END
End a template
Ex. 1, Ex. 2,
Ex. 3
FOOTER
Declare a symbol as a footer in the table and specify the
order of the footers
Ex. 1, Ex. 2
HEADER
Declare a symbol as a header in the table and specify the
order of the headers
Ex. 1, Ex. 2
NOTES
Provide information about a template
Ex. 1, Ex. 2
TEXT
Specify the text of the header or the footer
Ex. 1, Ex. 2
PROC TEMPLATE Statement
Begins a PROC TEMPLATE template.
380
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Syntax
PROC TEMPLATE
DEFINE CROSSTABS table-path </ STORE=libref.template-store>;
<table-attribute-1; <table-attribute-n>;>
CELLVALUE cellvalues;
DEFINE CELLVALUE cellvalue;
statements-and-attributes;
END;
DEFINE HEADER header-name;
statements-and-attributes;
END;
DEFINE FOOTER footer-name;
statements-and-attributes;
END;
DYNAMIC variable-1 <'text-1'> <variable-n <'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
NOTES text;
END;
CELLSTYLE AS Statement
Sets the style element of the cells in the column according to the values of the variables. Use this
statement to set the presentation characteristics (such as foreground color, font face, and flyover) of
individual cells in all destinations except the LISTING destinations.
Restriction:
See:
The CELLSTYLE AS statement can be used only with the DEFINE CELLVALUE
statement.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
Required Argument
expression
is an expression that is evaluated for each cell. If expression resolves to TRUE (a
nonzero value), the style element that is specified is used for the current cell. If
expression is FALSE (zero), the next expression in the statement is evaluated. Thus,
you can string multiple expressions together to format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
CELLSTYLE AS Statement
381
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
1
is a fixed value that you can use to set a constant style element.
Example
These statements set the cellvalue Frequency background to gray:
define cellvalue Frequency;
other–statements ...;
cellstyle 1 as {backgroundcolor=gray};
end;
_VAL_
is the value of the current cell.
Example
The following statements change the foreground color of the cellvalue
Percent depending on its magnitude:
define cellvalue Percent;
other–statements ...;
cellstyle _val_ > 75.00 as {color=red},
_val_ > 50.00 as {color=orange}, _val_ > 25.00 as {color=green};
end;
comparison-operator
compares a variable with a value or with another variable.
Table 13.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Tip
Using an expression of 1 as the last expression in the CELLSTYLE AS
statement sets the style element for any cells that did not meet an earlier
condition.
382
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Optional Arguments
style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general
form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a column template, see
Chapter 22, “Style Attributes,” on page 859.
Default
If you do not specify any style attributes to modify, ODS uses the
unmodified style-element-name.
Note
Neither style-attribute-specification nor style-element-name is required.
However, you must use at least one of them.
style-element-name
is the name of the style element that displays the data in the column. The style
element must be part of a style that is registered with the Output Delivery System.
SAS provides some styles. You can create customized styles by using PROC
TEMPLATE. For more information, see “DEFINE STYLE Statement” on page 462.
By default, ODS displays different parts of ODS output with different style elements.
For example, by default, the data in a column is displayed with the style element
Data. The style elements that you would probably use with the CELLSTYLE AS
statement in a column template are the following:
•
Data
•
DataFixed
•
DataEmpty
•
DataEmphasis
•
DataEmphasisFixed
•
DataStrong
•
DataStrongFixed
The style element provides the basis for displaying the column. Additional style
attributes that you provide can modify the display.
Default
Data
Note
Neither style-attribute-specification nor style-element-name is required.
However, you must use at least one of them.
See
“Viewing the Contents of a Style” on page 444
“Finding and Viewing the Default Style for ODS Destinations” on page
445
CELLVALUE Statement
Specifies the order in which the cellvalues are stacked in the cells.
Interaction:
If a cellvalue symbol that was specified by the DEFINE CELLVALUE statement is not
present in the list, it does not appear in the crosstabulation table.
DEFINE CELLVALUE Statement
See:
383
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
CELLVALUE cellvalue(s);
Required Argument
cellvalue(s)
specifies one of the nine possible cellvalues created by the DEFINE CELLVALUE
statement. cellvalues are ordered from the top to the bottom.
See
“DEFINE CELLVALUE Statement” on page 383
DEFINE CELLVALUE Statement
Defines a value that appears in the crosstabulation cells.
Note:
Example:
The DEFINE CELLVALUE statement begins a DEFINE CELLVALUE block. The
following statements are commonly used within the block: “CELLSTYLE AS
Statement” on page 380, “DYNAMIC Statement” on page 394, “NOTES Statement”
on page 397, and “END Statement” on page 396.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
DEFINE CELLVALUE <cellvalue>;
<cellvalue-attribute-1;> < cellvalue-attribute-n;>
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
DYNAMIC variable-1<'text-1'> < variable-n<'text-n'>>;
NOTES 'text';
END;
Optional Argument
cellvalue
specifies one of the possible values that PROC FREQ can produce for a
crosstabulation table. For a cellvalue to appear in a cell, it must meet one of these
requirements:
•
specified in a DEFINE CELLVALUE statement
•
included in the CELLVALUE statement
•
not suppressed by one of the following options for the TABLES statement in
PROC FREQ: NOFREQ, NOPERCENT, NOROW, NOCOL, or CUMCOL
•
requested by one of the following options: EXPECTED, DEVIATION,
CELLCHI2, or TOTPCT
384
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
To prevent a cellvalue from appearing in a table, you need to change only one of the
preceding specifications.
cellvalue is one of the following:
Frequency
is the frequency count.
Expected
is the expected frequency of the cell.
Deviation
is the deviation of the cell frequency from the expected value.
CellChiSquare
is the cell's contribution to the total Pearson chi-square statistic.
TotalPercent
is the percentage of total frequency on n-way tables when n>2.
Percent
is the percentage of the table frequency.
RowPercent
is the percentage of the row frequency.
ColPercent
is the percentage of the column frequency.
CumColPercent
is the cumulative percentage of the column frequency.
DEFINE CELLVALUE Attribute Statements
This section lists all the attribute statements that you can use in a cellvalue template and
the tasks that are associated with the statements. For all attributes that support a value of
ON, these forms are equivalent: ATTRIBUTE-NAME and ATTRIBUTE-NAME=ON.
Table 13.3
DEFINE CELLVALUE Attribute Statements
Task
Statement
Specify which format to use for the cellvalue
if both a crosstabulation template and a data
component specify a format
“DATA_FORMAT_OVERRIDE=ON | OFF;”
(p. 385)
Specify the format for the cellvalue
“ FORMAT=format_name <formatwidth<decimal-width >>;” (p. 385)
Override the width specified by the
FORMAT= attribute
“FORMAT_WIDTH=positive-integer ”
(p. 385)
Override the number of decimals specified by
the FORMAT= attribute
“FORMAT_NDEC=positive-integer” (p. 385)
Specify the text in the legend
“HEADER='text'” (p. 385)
For the Output destination, specify the label
for the data set column corresponding to the
cellvalue
“LABEL='text' ” (p. 385)
DEFINE CELLVALUE Statement
Task
Statement
Specify whether a cellvalue appears in the
crosstabulation table
“PRINT= ON | OFF” (p. 385)
385
DATA_FORMAT_OVERRIDE=<ON | OFF>;
specifies which format to use if both a crosstabulation template and a data
component specify a format for Frequency, Expected, and Deviation.
ON
selects the format specified in the data component.
OFF
selects the format specified in the crosstabulation template.
Default
OFF
Interaction
If you specify DATA_FORMAT_OVERRIDE=ON, and the FORMAT
option is specified in the TABLES statement in PROC FREQ, then the
data component specifies that format for the Frequency, Expected, and
Deviation cellvalues.
FORMAT=format_name <format-width<decimal-width >>;
specifies the format for the column.
Default
If you omit the FORMAT= option, PROC TEMPLATE uses the format
that the data component provides. If the data component does not
provide a format, PROC TEMPLATE uses one of the following:
BEST8. for integers, 12.3 for floating-point values, or the length of the
variable for character variables.
Range
The minimum cell width is 8, and the maximum width is 25.
Interaction
For LISTING output, the width of the cells is governed by the format
width. Cells are at least one character wider than the format width.
FORMAT_WIDTH=positive-integer
overrides the width specified by the FORMAT= attribute statement.
FORMAT_NDEC=positive-integer
overrides the number of decimals specified by the FORMAT= attribute statement.
HEADER='text'
specifies the text in the legend.
Tip
For LISTING output, only the first 15 characters of text are displayed.
LABEL='text'
for the OUTPUT destination, specifies the label for the data set column that
corresponds to the cellvalue.
PRINT= ON | OFF
specifies whether the cellvalue appears in the crosstabulation table.
Both this attribute and the TABLES statement option for the cellvalue control the
presence of the cellvalue in the table. For example, the expected cell frequency is
present only when the EXPECTED option is used and the Expected cellvalue
template has PRINT=ON specified.
386
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
DEFINE CROSSTABS Statement
Creates a crosstabulation table template.
Note:
Example:
The DEFINE CROSSTABS statement begins a crosstabs table template. The
following statements are typically used within a DEFINE CROSSTABS block:
“CELLVALUE Statement” on page 382, “DEFINE CELLVALUE Statement” on page
383, “DEFINE HEADER Statement” on page 392, “DEFINE FOOTER Statement” on
page 391, “DYNAMIC Statement” on page 394, “FOOTER Statement” on page
396, “HEADER Statement” on page 397, and “NOTES Statement” on page 397.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
DEFINE CROSSTABS table-path </ STORE=libref.template-store>;
<table-attribute-1; <table-attribute-n>;>
CELLVALUE cellvalues;
DEFINE CELLVALUE cellvalue;
statements-and-attributes;
END;
DEFINE HEADER header-name;
statements-and-attributes;
END;
DEFINE FOOTER footer-name;
statements-and-attributes;
END;
DYNAMIC variable-1 <'text-1'> <variable-n <'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
NOTES text;
END;
Summary of Optional Arguments
CELL_STYLE=<style-element-name><[style-attribute-specification(s)]> | stylename
Specify a style element and any changes to its attributes to use for the
cellvalues in the non-summary rows and columns
COL_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify the style element and any changes to its attributes to use for the
cellvalues in the last row in the table
COL_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify the style element and any changes to its attributes to use for the
column variable values used as headers over the column variable value
columns
COLS_HEADER=header-name
DEFINE CROSSTABS Statement 387
Specify the name of the header to use over the column variable value
columns in the table
GRAND_TOTAL_STYLE=<style-element-name><[style-attributespecification(s)]>
Specify the style element and any changes to its attributes to use for the
cellvalues in the rightmost column of the last row in the table
LABEL="text"
Specify a label for the table
LEGEND_STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify the style element and any changes to its attributes to use for the
legend table that appears near the upper left corner of the table
ROW_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify the style element and any changes to its attributes to use for the
cellvalues in the cells that contain row totals
ROW_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify the style element and any changes to its attributes to use for the row
variable values in the leftmost column of the table
ROWS_HEADER=header-name
Specify the name of the header to use over the row variable values (leftmost)
column in the table
STORE= template-store
Specify the template store in which to store the crosstabulation template.
STYLE=<style-element-name><[style-attribute-specification(s)]>
Specify a style element and any changes to its attributes to use for the table
Required Argument
table-path
specifies where to store the crosstabulation table template. A table-path consists of
one or more names, separated by periods. Each name represents a directory in a
template store, which is a type of SAS file. For more information about template
stores, see “Understanding Item Stores and Template Stores” in SAS Output Delivery
System: User's Guide. PROC TEMPLATE writes the template to the first writable
template store in the current path.
Requirement
Crosstabulation table templates must be named CrossTabFreqs.
Optional Argument
STORE= template-store
specifies the template store in which to store the crosstabulation template. If the
template store does not exist, it is created.
Restrictions
The STORE= option does not become part of the template.
If the template is nested inside another template, do not use the
STORE= option for the nested template, because the nested template
is stored where the original template is stored.
Requirement
The STORE= option must be proceeded by the forward slash (/)
symbol.
388
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
DEFINE CROSSTABS Attributes
This section lists all of the attributes that you can use in a crosstabulation template.
Table 13.4
Crosstabulation Attributes
Task
Statement
Specify a style element and any changes to its
attributes to use for the cellvalues in the nonsummary rows and columns
CELL_STYLE= (p. 388)
Specify the name of the header to use over
the column variable value columns in the
table
COLS_HEADER= (p. 389)
Specify the style element and any changes to
its attributes to use for the cellvalues in the
last row in the table
COL_TOTAL_STYLE= (p. 389)
Specify the style element and any changes to
its attributes to use for the column variable
values used as headers over the column
variable value columns
COL_VAR_STYLE= (p. 389)
Specify the style element and any changes to
its attributes to use for the cellvalues in the
rightmost column of the last row in the table
GRAND_TOTAL_STYLE= (p. 389)
Specify a label for the table
LABEL= (p. 389)
Specify the style element and any changes to
its attributes to use for the legend table that
appears near the upper left corner of the table
LEGEND_STYLE= (p. 389)
Specify the name of the header to use over
the row variable values (leftmost) column in
the table
ROWS_HEADER= (p. 390)
Specify the style element and any changes to
its attributes to use for the cellvalues in the
cells that contain row totals
ROW_TOTAL_STYLE= (p. 390)
Specify the style element and any changes to
its attributes to use for the row variable
values in the leftmost column of the table
ROW_VAR_STYLE= (p. 390)
Specify a style element and any changes to its
attributes to use for the table
STYLE= (p. 390)
CELL_STYLE=<style-element-name><[style-attribute-specification(s)]> | style-name
specifies the style element and any changes to its attributes that you can use for the
cellvalues in the non-summary rows and columns. This refers to the cellvalues that
are not in the row totals column (see ROW_TOTAL_STYLE), the column totals row
(see COL_TOTAL_STYLE), or the grand total cell (see GRAND_TOTAL_STYLE).
DEFINE CROSSTABS Statement 389
Default
Data
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
COLS_HEADER=header-name
specifies the name of the header to use over the column variable value columns in
the table.
See
“Crosstabulation Table Regions and Corresponding Attributes” on page 402
to see an illustration of the crosstabulation table regions and the DEFINE
CROSSTABS attributes that affect each region.
COL_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues
in the last row in the table.
Default
Data
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
COL_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the column
variable values used as headers over the column variable value columns.
Default
Header
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
GRAND_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues
in the rightmost column of the last row in the table.
Default
Data
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
LABEL="text"
specifies a label for the table.
Default
"Frequency Counts and Percentages"
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
LEGEND_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the legend table
that appears near the upper left corner of the table.
390
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Default
Header
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
ROWS_HEADER=header-name
specifies the name of the header to use over the row variable values (leftmost)
column in the table.
See
“Crosstabulation Table Regions and Corresponding Attributes” on page 402
to see an illustration of the crosstabulation table regions and the DEFINE
CROSSTABS attributes that affect each region.
ROW_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues
that contain row totals.
Default
Data
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
ROW_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the row
variable values in the leftmost column of the table.
Default
RowHeader
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
STYLE=<style-element-name><[style-attribute-specification(s)]>
Specifies the style element and any changes to its attributes to use for the table.
style-element-name
is the name of the style element to use to display the table. The style element
must be part of a style that is registered with the Output Delivery System. SAS
provides some style. You can create customized styles with PROC TEMPLATE.
For more information, see “DEFINE STYLE Statement” on page 462. By
default, ODS produces different parts of ODS output with different elements. For
example, by default, a table is produced with the style element Table. The Table
style element that SAS is provides is uniquely designed to describe elements
necessary to a table. However, you might have a user-defined style element at
your site that would be appropriate to specify.
The style element provides the basis for displaying the table. Additional style
attributes that you provide can modify the display.
style-element-name is either the name of a style element or a variable whose
value is a style element.
See
“Viewing the Contents of a Style” on page 444
“Finding and Viewing the Default Style for ODS Destinations” on page
445
DEFINE FOOTER Statement 391
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this
general form:
style-attribute-name=style-attribute-value
See
For information about the style attributes, see Chapter 22, “Style
Attributes,” on page 859.
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
Default
Table
See
“Crosstabulation Table Regions and Corresponding Attributes” on page
402 to see an illustration of the crosstabulation table regions and the
DEFINE CROSSTABS attributes that affect each region.
DEFINE FOOTER Statement
Creates a footer template.
Note:
See:
The DEFINE FOOTER statement begins a footer template block. The following
statements are commonly used within a DEFINE FOOTER block: “DYNAMIC
Statement” on page 394, “NOTES Statement” on page 397, and “TEXT Statement”
on page 398.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
DEFINE FOOTER symbol;
<attribute-1;>< attribute-n>;
DYNAMIC variable-1<'text-1'> < variable-n<'text-n'>>;
NOTES 'text';
TEXT header-specification </ expression>;
END;
Required Argument
The substatements in DEFINE FOOTER and the footer attributes are the same as the
substatements in DEFINE HEADER and the header attributes. For details about
substatements and footer attributes, see the “DEFINE HEADER Statement” on page
392.
392
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
DEFINE HEADER Statement
Creates a header template.
Note:
See:
The DEFINE HEADER statement begins a header template block. The following
statements are commonly used within a DEFINE HEADER block: “DYNAMIC
Statement” on page 394, “NOTES Statement” on page 397, and “TEXT Statement”
on page 398.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
DEFINE HEADER symbol;
<attribute-1;>< attribute-n>;
DYNAMIC variable-1<'text-1'> < variable-n<'text-n'>>;
NOTES 'text';
TEXT header-specification </ expression>;
END;
Summary of Optional Arguments
CINDENT='character'
Specify alignment for headers and footers that wrap
SPACE=positive-integer
Specify the number of blank lines to place between the current header and the
next header or between the current footer and the previous footer
STYLE=<[style-element-specification(s)]>
Specify the style element and any changes to its attributes to use for the
header or footer
Required Argument
symbol
specifies a name to be referenced by the HEADER statement.
DEFINE HEADER and DEFINE FOOTER Attribute Statements
This section lists the attributes that you can use in a header or footer template.
Table 13.5
DEFINE HEADER and DEFINE FOOTER Attribute Statements
Task
Attribute
Specify alignment for headers and footers that
wrap
“CINDENT='character' ” (p. 393)
DEFINE HEADER Statement 393
Task
Attribute
Specify the number of blank lines to place
between the current header and the next header
or between the current footer and the previous
footer
“SPACE=positive-integer ” (p. 393)
Specify the style element and any changes to its
attributes to use for the header or footer
“STYLE=<[style-elementspecification(s)]> ” (p. 393)
CINDENT='character'
specifies alignment for headers or footers that wrap. If a header or footer is too wide
to fit on a single line, insert the specified character at the column position at which
the second and subsequent lines should start. The first use of the CINDENT
character determines the column position. For example, the following TEXT
statement makes wrapped lines start at the same column as the open parenthesis:
text _COL_NAME_ "(;" _COL_LABEL_ ")"; CINDENT=';';
SPACE=positive-integer
specifies the number of blank lines to place between the current header and the next
header or between the current footer and the previous footer.
Default
0 for headers and 1 for footers
Tip
The SPACE= attribute is valid only in the LISTING destination.
Example
“Example 1: Creating a Customized Crosstabulation Table Template with
No Legend” on page 403
STYLE=<[style-element-specification(s)]>
specifies the style element and any changes to its attributes to use for the current
column. Neither style-attribute-specification nor style-element-name is required.
However, you must use at least one of them. You can use braces ({ and }) instead of
square brackets ([ and ]).
style-element-name
is the name of the style element to use to display the data in the column. The
style element must be part of a style template that is registered with the Output
Delivery System. SAS provides some styles. You can create customized styles
with PROC TEMPLATE. For details, see “DEFINE STYLE Statement” on page
462. By default, ODS produces different parts of ODS output with different
elements. For example, by default, a table header is displayed with the style
element Header. The style elements that you would most likely use with the
STYLE= attribute for a table header are as follows:
•
Header
•
HeaderFixed
•
HeaderEmpty
•
HeaderEmphasis
•
HeaderEmphasisFixed
•
HeaderStrong
•
HeaderStrongFixed
394
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
The style elements that you would most likely use with the STYLE= attribute for
a footer are as follows:
•
Footer
•
FooterFixed
•
FooterEmpty
•
FooterEmphasis
•
FooterEmphasisFixed
•
FooterStrong
•
FooterStrongFixed
The style element provides the basis for displaying the header or footer.
Additional style attributes that you provide can modify the display.
For more information, see “Viewing the Contents of a Style” on page 444.
style-element-name is either the name of a style element or a variable whose
value is a style element.
style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this
general form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can specify, see Chapter 22,
“Style Attributes,” on page 859.
Tips
The STYLE= attribute is valid only in the markup family, printer family,
and RTF destinations.
If you use the STYLE= attribute inside a quoted string, then add a space
before or after the carriage return to prevent errors. SAS does not
interpret a carriage return as a space. You must explicitly specify spaces
in quoted strings.
Example
“Example 1: Creating a Customized Crosstabulation Table Template with
No Legend” on page 403
DYNAMIC Statement
Defines a symbol that references a value that the data component supplies from the procedure or DATA
step.
Restriction:
Tip:
Example:
The DYNAMIC statement can be used only with the DEFINE CELLVALUE, DEFINE
HEADER, and DEFINE FOOTER statements.
A dynamic variable that is defined in a template is available to that template and all
the templates that it contains.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
DYNAMIC Statement
395
Syntax
DYNAMIC dynamic-variable(s);
Required Argument
dynamic- variable(s)
is a variable that is defined by SAS in the crosstabulation template. After a dynamic
variable has been defined, you can use it in the TEXT statement within a footer or
header template.
FMISSING
is the number of missing values in the table.
Requirement
The FMISSING dynamic variable must be specified by the
DYNAMIC statement before you can use the dynamic variable in
an expression.
NOTITLE
is set to 1 if the PROC FREQ's NOTITLE option was used, and it is set to 0 if the
NOTITLE option was not used.
Requirement
The NOTITLE dynamic variable must be specified by the
DYNAMIC statement before you can use the dynamic variable in
an expression.
SAMPLESIZE
is set to 0 if the table is empty. Otherwise, it is set to 1.
Requirement
The SAMPLESIZE dynamic variable must be specified by the
DYNAMIC statement before you can use the dynamic variable in
an expression.
STRATNUM
is the current stratum number if the table has multiple strata. If the table has only
one stratum, then the value is 0.
Requirement
The STRATNUM dynamic variable must be specified by the
DYNAMIC statement before you can use the dynamic variable in
an expression.
Example
“Example 1: Creating a Customized Crosstabulation Table
Template with No Legend” on page 403
STRATAVARIABLENAMES
is a string that identifies the current stratum by the name of the stratum variables.
var-1=value-1<var-n=value-n>
var-1–var-n
specifies the stratum variables.
value-1–value-n
specifies the values of the stratum variables.
Requirement
The DYNAMIC statement must specify the
STRATAVARIABLELABELS dynamic variables before the
dynamic variables can be used in an expression.
396
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
The value is undefined if the table has only one stratum.
Tip
STRATAVARIABLELABELS
is a string that identifies the current stratum by the label of the stratum variables.
var-1=value-1<var-n=value-n>
var-1–var-n
specifies the stratum variables.
value-1–value-n
specifies the values of the stratum variables.
Tip
The value is undefined when the table has only one stratum.
Requirement
Examples
The DYNAMIC statement must specify the
STRATAVARIABLELABELS dynamic variables before you can
use the dynamic variables in an expression.
“Example 1: Creating a Customized Crosstabulation Table Template
with No Legend” on page 403
“Example 2: Creating a Crosstabulation Table Template with a
Customized Legend” on page 416
END Statement
Ends the crosstabulation template or a DEFINE CELLVALUE, DEFINE HEADER, or DEFINE FOOTER
code block.
Restriction:
See:
The END statement must be used with the DEFINE CELLVALUE, DEFINE
HEADER, DEFINE FOOTER, and DEFINE CROSSTABS statements.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
END;
FOOTER Statement
Declares a symbol as a footer in the table and specifies the order of the footers.
Restriction:
The FOOTER statement can be used only within a crosstabulation table template.
Syntax
FOOTER footer-specification(s);
NOTES Statement 397
Required Argument
footer-specification(s)
specifies a symbol defined by the DEFINE FOOTER statement within the same table
template.
Default
If you omit a FOOTER statement, ODS creates a footer for each footer
template (DEFINE FOOTER statement) and places the footers in the same
order that the footer templates have in the table template.
See
“DEFINE FOOTER Statement” on page 391
HEADER Statement
Declares a symbol as a header in the table and specifies the order of the headers.
Restriction:
The HEADER statement can be used only within a crosstabulation table template.
Syntax
HEADER header-specification(s);
Required Argument
header-specification(s)
specifies a symbol defined by the DEFINE HEADER statement within the same
table template.
Default
If you omit a HEADER statement, then ODS makes a header for each
header template (DEFINE HEADER statement) and places the headers in
the same order that the header templates have in the table template.
NOTES Statement
Provides information about a template.
Restriction:
Tip:
The NOTES statement can be used only with the DEFINE CROSSTABS, DEFINE
CELLVALUE, and DEFINE HEADER statements.
The NOTES statement becomes part of the compiled template, which you can view
with the SOURCE statement. SAS comments do not become part of the compiled
template.
Syntax
NOTES 'text';
Required Argument
'text'
provides information about the template.
398
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
TEXT Statement
Specifies the text of the header or the footer.
Restriction:
Example:
TheTEXT statement can be used only with the DEFINE HEADER or DEFINE
FOOTER statements.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
TEXT header-specification(s) </ option(s)>;
Required Argument
header-specification(s)
specifies the text of the header. header-specification(s) can be any dynamic variable
that is specified by the DYNAMIC statement, or it can be one of the following:
dynamic-variable
is a variable that is automatically defined by SAS in the crosstabulation template.
dynamic-variable can be one of the following:
_COL_LABEL_
is the label of the column variable, which is the last variable in a table
request.
_COL_NAME_
is the name of the column variable, which is the last variable in a table
request. If the column variable does not have a name, then the value of
_COL_LABEL_ is an empty text string (" ").
_ROW_LABEL_
is the label of the row variable, which is the next to the last variable in a table
request. If the row variable does not have a label, the value of
_ROW_LABEL_ is an empty text string (" ").
_ROW_NAME_
is the name of the row variable, which is the next to the last variable in a
table request.
text-specification(s)
specifies the text to use in the header. Each text-specification is one of the
following:
•
a quoted string.
•
a variable followed by an optional format. The variable is any variable that is
declared in a DYNAMIC statement or is any of the variables above.
Tip
If the quoted string is a blank and it is the only item in the header
specification, the header is a blank line.
TEXT Statement
399
Optional Argument
expression
is an expression that is evaluated for a header or footer. If expression is omitted, the
default is 1. Each DEFINE HEADER statement can contain any number of TEXT
statements. The template evaluates each expression in turn from top to bottom and
thereby determines the text of the header. The header-specification in the first TEXT
statement whose expression evaluates to true becomes the header text. After an
expression evaluates to true, the template examines no more TEXT statements. If no
expression is true, then the header is not used.
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value, such as a number or text string.
dynamic variable
is a variable that is defined by SAS in the crosstabulation template or by the
DYNAMIC statement within a header or footer template.
_COL_LABEL_
specifies the label of the column variable, which is the last variable in a
table request. If the column variable does not have a label, then the value
of _COL_LABEL_ is an empty text string (" ").
_COL_NAME_
specifies the name of the column variable, which is the last variable in a
table request. If the column variable does not have a name, then the value
of _COL_NAME_ is an empty text string (" ").
FMISSING
is the number of missing values in the table.
Requirement
The FMISSING dynamic variable must be specified by
the DYNAMIC statement before you can use it in an
expression.
NOTITLE
is set to 1 if PROC FREQ's NOTITLE option was used, and it is set to 0
if the NOTITLE option was not used.
Requirement
The NOTITLE dynamic variable must be specified by the
DYNAMIC statement before you can use it in an
expression.
_ROW_LABEL_
is the label of the row variable, which is the next to the last variable in a
table request. If the row variable does not have a name, then the value of
_ROW_LABEL_ is an empty text string (" ").
_ROW_NAME_
specifies the name of the row variable, which is the next to the last
variable in a table request. If the row variable does not have a name, then
the value of _ROW_NAME_ is an empty text string (" ").
400
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
SAMPLESIZE
is set to 0 if the table is empty. Otherwise, it is set to 1.
Requirement
The SAMPLESIZE dynamic variable must be specified
by the DYNAMIC statement before you can use it in an
expression.
STRATNUM
is the current stratum number if the table has multiple strata. If the table
has only one stratum, then the value is 0.
Requirement
The STRATNUM dynamic variable must be specified by
the DYNAMIC statement before you can use it in an
expression.
STRATAVARIABLENAMES
is a string that identifies the current stratum by the name of the stratum
variables.
var-1=value-1<var-n=value-n>
var-1–var-n
specifies the stratum variables.
value-1–value-n
specifies the values of the stratum variables.
Tip
The value is undefined when the table has only one stratum.
Requirement
The STRATAVARIABLENAMES dynamic variable must
be specified by the DYNAMIC statement before you can
use it in an expression.
STRATAVARIABLELABELS
is a string that identifies the current stratum by the label of the stratum
variables. STRATAVARIABLELABELS has the following form:
var-1=value-1<var-n=value-n?>
var-1–var-n
specifies the stratum variables.
value-1–value-n
specifies the values of the stratum variables.
Tip
The value is undefined when the table has only one stratum.
Requirement
The DYNAMIC statement must specify the
STRATAVARIABLELABELS dynamic variables before
you can use them in an expression.
comparison-operator
compares a variable with a value or another variable.
Table 13.6
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
Using Crosstabulation Table Templates
Symbol
Mnemonic Equivalent
Definition
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
401
Using Crosstabulation Table Templates
Working with the CrossTabFreqs Crosstabulation Table Template
When creating your own crosstabulation table template, you always define the new table
with the same name as the existing table, which is Base.Freq.CrossTabFreqs. By default,
the existing crosstabulation table that PROC FREQ creates is stored in the
Sashelp.Tmplmst template store.
With PROC TEMPLATE, you can create a modified version of
Base.Freq.CrossTabFreqs that you can save in a different template store by using the
ODS PATH statement. All crosstabulation templates must have the same name. If you
want to have multiple crosstabulation templates, put each one in a different template
store. Then you can use the ODS PATH statement to add the template store that contains
the version of the crosstabulation template that you want to use.
For example, suppose that you have a crosstabulation template in the template store
Corporat.Template and another crosstabulation template in Govment.Templat. In the
following code, the first ODS PATH statement adds the template store Corporat.Templat.
The first PROC FREQ code is then formatted using the crosstabulation table template
from Corporat.Templat. The second ODS PATH statement removes Corporat.Templat,
and the third ODS PATH statement adds Govment.Templat. The last PROC FREQ step
then uses the crosstabulation template from Corporat.Templat.
ods
...
ods
ods
...
path(prepend) corporat.templat(read);
proc freq code ...
path(remove) corporat.templat;
path(prepend) govment.templat;
proc freq code ...
For more information about the ODS PATH statement, see “ODS PATH Statement” in
SAS Output Delivery System: User's Guide.
402
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Crosstabulation Table Regions and Corresponding Attributes
When creating a crosstabulation template, you can use attributes to modify individual
table regions. The following figure and corresponding table identify the different parts of
the crosstabulation table and the attributes that control the style of each part.
Figure 13.3 Crosstabulation Table Regions That Can Be Modified
Most regions use DEFINE CROSSTABS style attributes to specify a style. The
following table shows the style attribute that effects each table region. For complete
documentation on DEFINE CROSSTABS attributes, see “DEFINE CROSSTABS
Attributes” on page 388. Headers and footers use the STYLE= attribute that is valid for
the DEFINE HEADER and DEFINE FOOTER statements. For information about the
STYLE= attribute, see “DEFINE HEADER and DEFINE FOOTER Attribute
Statements” on page 392.
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
403
Table 13.7
Item
Table Region and Corresponding Style Attribute
Crosstabulation Table Region
Style Attribute
1
Legend
LEGEND_STYLE=
2
Row variable name
ROWS_HEADER=
3
Row variable value
ROW_VAR_STYLE=
4
Data cell
CELL_STYLE=
5
Column total
COL_TOTAL_STYLE=
6
Footer
STYLE=
7
Grand total
GRAND_TOTAL_STYLE=
8
Row total
ROW_TOTAL_STYLE
9
Column variable name
COLS_HEADER=
10
Header
STYLE=
11
Column variable value
COL_VAR_STYLE=
Examples: TEMPLATE Procedure: Creating
Crosstabulation Table Templates
Example 1: Creating a Customized Crosstabulation Table Template with
No Legend
Features:
crosstabs-attributes statements
CELLVALUE statement
DEFINE CELLVALUE statement
CELLSTYLE AS statement
END statement
FORMAT= attribute
HEADER= attribute
LABEL= attribute
DEFINE HEADER statement
END statement
SPACE= attribute
STYLE= attribute
TEXT statement
404
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
DEFINE FOOTER statement
END statement
DYNAMIC statement
SPACE= attribute
STYLE= attribute
TEXT statement
END statement
FOOTER statement
HEADER statement
NOTES statement
Other features:
Other ODS features
ODS HTML statement
ODS PATH statement
DEFINE STYLE statement
Details
The following example creates the crosstabulation table template
Base.Freq.CrossTabFreqs. The template has the following features:
•
footnote used to display cellvalue labels instead of a legend
•
modified headers and footers
•
variable labels used in headers
•
modified table regions
Program
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
.='
?';
Value Colfg
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
Value Rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
other='black';
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
405
run;
data gov;
Label Citygovt='City Government Form'
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
3 3 27
3 4 55
3 . 1
;
ods path (prepend) work.templat(update);
ods noproctitle;
proc template;
define style white;
parent=styles.htmlblue;
style body /
backgroundcolor=white;
style systemtitle /
backgroundcolor=white
fontsize=6
fontweight=bold
fontstyle=italic;
style systemfooter /
backgroundcolor=white
fontsize=2
fontstyle=italic;
style proctitle /
backgroundcolor=white
color=#6078bf
fontweight=bold
fontstyle=italic;
end;
define crosstabs Base.Freq.CrossTabFreqs;
notes "Crosstabulation table";
style=table {backgroundcolor=#BFCFFF};
406
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
cell_style=data {backgroundcolor=#FFFFF0};
row_var_style=rowheader {backgroundcolor=#BFCFFF color=rowfg.};
col_var_style=header {backgroundcolor=#BFCFFF color=colfg.};
row_total_style=data {backgroundcolor=#F0F0F0};
col_total_style=data {backgroundcolor=#F0F0F0};
grand_total_style=datastrong {backgroundcolor=#F0F0F0};
legend_style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
rows_header=RowsHeader cols_header=ColsHeader;
label = "Frequency Counts and Percentages";
define header TableOf;
text "Table of " _ROW_LABEL_ " by " _COL_LABEL_ / _ROW_LABEL_ ^= ''
& _COL_LABEL_ ^= '';
text "Table of " _ROW_LABEL_ " by " _COL_NAME_ / _ROW_LABEL_ ^= '';
text "Table of " _ROW_NAME_ " by " _COL_LABEL_ / _COL_LABEL_ ^= '';
text "Table of " _ROW_NAME_ " by " _COL_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
end;
define header RowsHeader;
text _ROW_LABEL_ / _ROW_LABEL_ ^= '';
text _ROW_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
space=0;
end;
define header ColsHeader;
text _COL_LABEL_ / _COL_LABEL_ ^= '';
text _COL_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
space=1;
end;
define header ControllingFor;
dynamic StratNum StrataVariableNames StrataVariableLabels;
text "Controlling for" StrataVariableNames / StratNum > 0;
style=header;
end;
define footer Missing;
dynamic FMissing;
text "Frequency Missing = " FMissing -12.99 / FMissing ^= 0;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
space=1;
end;
define footer NoObs;
dynamic SampleSize;
text "Effective Sample Size = 0" / SampleSize = 0;
space=1;
style=header;
end;
define cellvalue Frequency;
header="";
label="Frequency Count";
format=BEST7.; data_format_override=on; print=on;
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
407
cellstyle _val_ < 10 as datastrong {color=green},
_val_ > 40 & _val_ < 50 as datastrong {color=orange},
_val_ >= 50 as datastrong {color=red};
end;
define cellvalue Expected;
header="";
label="Expected Frequency";
format=BEST6. data_format_override=on print=on;
end;
define cellvalue Deviation;
header="";
label="Deviation from Expected Frequency";
format=BEST6. data_format_override=on print=on;
end;
define cellvalue CellChiSquare;
header="";
label="Cell Chi-Square";
format=BEST6. print=on;
end;
define cellvalue TotalPercent;
header="";
label="Percent of Total Frequency";
format=6.2 print=on;
end;
define cellvalue Percent;
header="";
label="Percent of Two-Way Table Frequency";
format=6.2 print=on;
end;
define cellvalue RowPercent;
header="";
label="Percent of Row Frequency";
format=6.2 print=on;
end;
define cellvalue ColPercent;
header="";
label="Percent of Column Frequency";
format=6.2 print=on;
end;
define cellvalue CumColPercent;
header="";
label="Cumulative Percent of Column Frequency";
format=6.2 print=on;
end;
cellvalue
Frequency Expected Deviation
CellChiSquare TotalPercent Percent
408
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
RowPercent ColPercent CumColPercent;
header TableOf ControllingFor;
footer NoObs Missing;
end;
ods html file='MyCrosstabsTable.html' style=white;
title "City Government Form by Number of Meetings Scheduled";
footnote "Cellvalues are stacked in the following order:";
footnote2 "Frequency";
footnote3 "Percent";
footnote4 "Row Percent";
footnote5 "Column Percent";
ods noproctitle;
proc freq;
tables citygovt*robgrp / missprint;
run;
ods html close;
Program Description
Create the user-defined formats and create the data set. The FORMAT procedure
creates two user-defined formats that can be used in the crosstabulation template. The
DATA step creates the Gov data set.
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
.='
?';
Value Colfg
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
Value Rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
other='black';
run;
data gov;
Label Citygovt='City Government Form'
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
409
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
3 3 27
3 4 55
3 . 1
;
Establish the ODS path and create the White style. The ODS PATH statement
specifies the locations to write to or read from when creating the PROC TEMPLATE
templates. The PROC TEMPLATE statement, DEFINE STYLE statement, and
collection of STYLE statements create the style template White. The ODS
NOPROCTITLE statement suppresses the writing of the title of the FREQ procedure.
ods path (prepend) work.templat(update);
ods noproctitle;
proc template;
define style white;
parent=styles.htmlblue;
style body /
backgroundcolor=white;
style systemtitle /
backgroundcolor=white
fontsize=6
fontweight=bold
fontstyle=italic;
style systemfooter /
backgroundcolor=white
fontsize=2
fontstyle=italic;
style proctitle /
backgroundcolor=white
color=#6078bf
fontweight=bold
fontstyle=italic;
end;
Create the crosstabulation template Base.Freq.CrossTabFreqs. The DEFINE
statement creates the crosstabulation template Base.Freq.CrossTabFreqs in the first
410
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
template store in the path for which you have Write access (Work, in this example). The
NOTES statement provides information about the crosstabulation table.
define crosstabs Base.Freq.CrossTabFreqs;
notes "Crosstabulation table";
Change the appearance of individual table regions. The following DEFINE
CROSSTABS statement attributes modify the appearance of individual table regions.
Each attribute corresponds to a specific region of the table.
To see which attribute corresponds to which table region, see “Crosstabulation Table
Regions and Corresponding Attributes” on page 402 .
style=table {backgroundcolor=#BFCFFF};
cell_style=data {backgroundcolor=#FFFFF0};
row_var_style=rowheader {backgroundcolor=#BFCFFF color=rowfg.};
col_var_style=header {backgroundcolor=#BFCFFF color=colfg.};
row_total_style=data {backgroundcolor=#F0F0F0};
col_total_style=data {backgroundcolor=#F0F0F0};
grand_total_style=datastrong {backgroundcolor=#F0F0F0};
legend_style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
Specify a row header, a column header, and a label for the table. The
ROWS_HEADER= style attribute specifies RowsHeader as the header for rows. The
COLS_HEADER= style attribute specifies ColsHeader as the header for columns. The
LABEL= attribute specifies a label for the crosstabulation template. The label appears in
the Results window.
rows_header=RowsHeader cols_header=ColsHeader;
label = "Frequency Counts and Percentages";
Create the TableOf header template. The DEFINE HEADER statement and its
attributes create the header template TableOf, which is specified by the HEADER
statement later on in the program. The TEXT statement specifies the text of the header
by using dynamic variables that represent label variables and names. The TEXT
statements also use expressions to determine whether row labels and column labels are
assigned to the row and column variables. Only TEXT statements that have true
expressions are displayed in the output. In this example, both the row label and the
column label exist. Therefore, the first TEXT statement is used and the text resolves to:
"Table of City Government Form by Number of Meetings Scheduled". The STYLE=
attribute specifies style information for the header.
define header TableOf;
text "Table of " _ROW_LABEL_ " by " _COL_LABEL_ / _ROW_LABEL_ ^= ''
& _COL_LABEL_ ^= '';
text "Table of " _ROW_LABEL_ " by " _COL_NAME_ / _ROW_LABEL_ ^= '';
text "Table of " _ROW_NAME_ " by " _COL_LABEL_ / _COL_LABEL_ ^= '';
text "Table of " _ROW_NAME_ " by " _COL_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
end;
Create the RowsHeader header template. The DEFINE HEADER statement creates
the header RowsHeader. RowsHeader is specified as a row heading by the preceding
ROWS_HEADER= style attribute. The TEXT statements specify the text of the header
by using dynamic variables that represent label variables and names. The first TEXT
statement uses an expression to determine whether a label is assigned to the variable. If
there is no label, the next TEXT statement, which specifies the row name, is used. In this
example there is a row label for the row variable, so in the output, _ROW_LABEL_
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
411
resolves to "City Government Form". The STYLE= attribute specifies style information
for the header, and the SPACE attribute specifies that the current header and the previous
header should have one blank line between them.
define header RowsHeader;
text _ROW_LABEL_ / _ROW_LABEL_ ^= '';
text _ROW_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
space=0;
end;
Create the ColsHeader header template. The DEFINE HEADER statement creates the
header ColsHeader. ColsHeader is specified as a column heading by the preceding
COLS_HEADER= style attribute. The TEXT statements specify the text of the header
by using dynamic variables that represent label variables and names. The first TEXT
statement uses an expression to determine whether a label is assigned to the column
variable. If there is no label, the next TEXT statement, which specifies the row name, is
used. In this example there is a column label, so in the output, _COL_LABEL_ resolves
to "Number of Meetings Scheduled". The STYLE= attribute specifies style information
for the header, and the SPACE attribute specifies that the current header and the previous
header should have one blank line between them.
define header ColsHeader;
text _COL_LABEL_ / _COL_LABEL_ ^= '';
text _COL_NAME_;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
space=1;
end;
Create the ControllingFor header template. The DEFINE HEADER statement and its
attributes create the header template ControllingFor. The DYNAMIC statement declares
dynamic variables so that they can be used in expressions. The TEXT statement
specifies the text of the header by using dynamic variables that represent label variables
and names. In this example, the expression in the TEXT statement resolves to false, so
the ControllingFor header does not show up in the output. The STYLE= attribute
specifies style information for the headers.
define header ControllingFor;
dynamic StratNum StrataVariableNames StrataVariableLabels;
text "Controlling for" StrataVariableNames / StratNum > 0;
style=header;
end;
Create footer templates. Each of these DEFINE FOOTER statements and its attributes
creates a footer template. For the footers to show up in the output, they must be specified
by the FOOTER statement. The DYNAMIC statements declare the dynamic variables
FMissing and SampleSize, so that they can be used in the TEXT statements. The TEXT
statements conditionally select text to use as footers. In the first TEXT statement, the
expression is true, because FMissing is not 0. Therefore, the first TEXT statement is
displayed in the output. In the second TEXT statement, the expression resolves to false,
so the NoObs footer does not appear in the output. The STYLE attribute specifies style
information for the footers, and the SPACE attribute specifies that the current footer and
the previous footer should have one blank line between them.
define footer Missing;
dynamic FMissing;
text "Frequency Missing = " FMissing -12.99 / FMissing ^= 0;
style=header {backgroundcolor=#BFCFFF color=#6078bf fontstyle=italic};
412
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
space=1;
end;
define footer NoObs;
dynamic SampleSize;
text "Effective Sample Size = 0" / SampleSize = 0;
space=1;
style=header;
end;
Create the cellvalue definitions. The DEFINE CELLVALUE statements define the
values that will appear in the cells of the crosstabulation table. The HEADER= attribute
specifies the text that appears in the legend. Because there is no text specified for any of
these cellvalues, there is no legend in the output. The FORMAT= attribute specifies the
format to use for the cellvalue. The DATA_FORMAT_OVERRIDE=ON attribute
specifies to use the format specified in the data component. The PRINT=ON attribute
specifies the cellvalue to appear in the table. The CELLSTYLE AS statement uses
expressions to set the style element of the cells conditionally according to the values of
the variables for the Frequency cellvalue. The _VAL_ variable represents the value of a
cell. Therefore, in this example, if the value in a cell is less than ten, then the font color
for the DataStrong style element is green. If the value in the cell is between 40 and 50,
then the font color for the DataStrong style element is orange. If the value is greater than
50, then the font color is red.
define cellvalue Frequency;
header="";
label="Frequency Count";
format=BEST7.; data_format_override=on; print=on;
cellstyle _val_ < 10 as datastrong {color=green},
_val_ > 40 & _val_ < 50 as datastrong {color=orange},
_val_ >= 50 as datastrong {color=red};
end;
define cellvalue Expected;
header="";
label="Expected Frequency";
format=BEST6. data_format_override=on print=on;
end;
define cellvalue Deviation;
header="";
label="Deviation from Expected Frequency";
format=BEST6. data_format_override=on print=on;
end;
define cellvalue CellChiSquare;
header="";
label="Cell Chi-Square";
format=BEST6. print=on;
end;
define cellvalue TotalPercent;
header="";
label="Percent of Total Frequency";
format=6.2 print=on;
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
413
end;
define cellvalue Percent;
header="";
label="Percent of Two-Way Table Frequency";
format=6.2 print=on;
end;
define cellvalue RowPercent;
header="";
label="Percent of Row Frequency";
format=6.2 print=on;
end;
define cellvalue ColPercent;
header="";
label="Percent of Column Frequency";
format=6.2 print=on;
end;
define cellvalue CumColPercent;
header="";
label="Cumulative Percent of Column Frequency";
format=6.2 print=on;
end;
Specify which cellvalues appear in the table and the order in which the cellvalues
are stacked in the cells. The CELLVALUE statement specifies which cellvalues appear
in the output. In this example, all of the cellvalues that were created appear in the table.
The CELLVALUE statement also specifies the order in which the cellvalues are stacked
in the cells.
cellvalue
Frequency Expected Deviation
CellChiSquare TotalPercent Percent
RowPercent ColPercent CumColPercent;
Specify which headers and footers appear in the output. The HEADER statement
specifies which header templates are applied to your output. The FOOTER statement
specifies which footer templates are applied to your output. In order for any of the
headers and footers defined by a DEFINE statement to appear in your output, they must
be specified by the FOOTER or HEADER statement.
header TableOf ControllingFor;
footer NoObs Missing;
end;
Create the HTML output and specify the name of the HTML file. The ODS HTML
statement opens the HTML destination and creates HTML output. The STYLE= option
specifies template White for the output style.
ods html file='MyCrosstabsTable.html' style=white;
Specify a title and footnote, and suppress the printing of the procedure title. The
TITLE and FOOTNOTE statements specify titles and footnotes for the output. The ODS
NOPROCTITLE statement prevents the printing of the FREQ procedure’s title in the
output.
414
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
title "City Government Form by Number of Meetings Scheduled";
footnote "Cellvalues are stacked in the following order:";
footnote2 "Frequency";
footnote3 "Percent";
footnote4 "Row Percent";
footnote5 "Column Percent";
ods noproctitle;
Create the crosstabulation table. The FREQ procedure creates a Citygovt by Robgrp
crosstabulation table.
proc freq;
tables citygovt*robgrp / missprint;
run;
Close the HTML destination. The ODS HTML CLOSE statement closes the HTML
destination, as well as all the files that are open for that destination.
ods html close;
Example 1: Creating a Customized Crosstabulation Table Template with No Legend
415
Output
Output 13.1 Output Using Customized Crosstabulation Table Template
416
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Output 13.2 Output Using Default Crosstabulation Table
Example 2: Creating a Crosstabulation Table Template with a
Customized Legend
Features:
crosstabs-attributes statements
CELLVALUE statement
DEFINE CELLVALUE statement
CELLSTYLE AS statement
END statement
FORMAT= attribute
HEADER= attribute
LABEL= attribute
DEFINE HEADER statement
END statement
SPACE= attribute
STYLE= attribute
TEXT statement
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
DEFINE FOOTER statement
END statement
DYNAMIC statement
SPACE= attribute
STYLE= attribute
TEXT statement
END statement
FOOTER statement
HEADER statement
NOTES statement
Other features:
Other ODS features
ODS HTML statement
ODS PATH statement
DEFINE STYLE statement
Details
The following example creates a new crosstabulation table template for the
CrossTabFreqs table. The template has the following features:
•
a legend with customized text
•
modified headers and footers
•
variable labels used in headers
•
modified table regions
•
customized styles for cellvalues
Program
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
.='
?';
Value colfg
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
Value rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
417
418
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
other='black';
run;
data gov;
Label Citygovt='City Government Form'
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
3 3 27
3 4 55
3 . 1
;
ods path (prepend) work.templat(update);
proc template;
define crosstabs Base.Freq.CrossTabFreqs;
notes "Crosstabulation table with legend";
rows_header=RowsHeader cols_header=ColsHeader;
label = "Frequency Counts and Percentages";
grand_total_style=data {fontweight=bold};
define header ControllingFor;
dynamic StratNum StrataVariableNames StrataVariableLabels;
text "Controlling for" StrataVariableNames / StratNum > 0;
style=header;
end;
define header RowsHeader;
text _ROW_LABEL_ / _ROW_LABEL_ ^= '';
text _ROW_NAME_;
space=0;
style=header;
cindent=';';
end;
define header ColsHeader;
text _COL_LABEL_ / _COL_LABEL_ ^= '';
text _COL_NAME_;
space=1;
style=header;
cindent=';';
end;
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
419
define footer TableOf;
notes 'NoTitle is 1 if the NOTITLE option was specified.';
dynamic StratNum NoTitle;
text "Table " StratNum 3. " of " _ROW_LABEL_ " by " _COL_LABEL_ /
& StratNum > 0 & _ROW_LABEL_ ^= '' & _COL_LABEL_ ^= '';
text "Table " StratNum 3. " of " _ROW_LABEL_ " by " _COL_NAME_ /
& StratNum > 0 & _ROW_LABEL_ ^= ''
;
text "Table " StratNum 3. " of " _ROW_NAME_ " by " _COL_LABEL_ /
& StratNum > 0 & _COL_LABEL_ ^= '';
text _ROW_LABEL_ " by " _COL_LABEL_ / NoTitle = 0 & _ROW_LABEL_
& _COL_LABEL_ ^= '';
text _ROW_LABEL_ " by " _COL_NAME_ / NoTitle = 0 & _ROW_LABEL_
text _ROW_NAME_ " by " _COL_LABEL_ / NoTitle = 0 & _COL_LABEL_
text "Table " StratNum 3. " of " _ROW_NAME_ " by " _COL_NAME_ /
& StratNum > 0;
text _ROW_NAME_ " by " _COL_NAME_ / NoTitle = 0;
style=header;
end;
define footer Missing;
dynamic FMissing;
text "Frequency Missing = " FMissing -12.99 / FMissing ^= 0;
space=1;
style=header;
end;
define footer NoObs;
dynamic SampleSize;
text "Effective Sample Size = 0" / SampleSize = 0;
space=1;
style=header;
end;
define cellvalue Frequency;
header="Frequency";
format=BEST7.;
label="Frequency Count";
data_format_override=on print=on;
end;
define cellvalue Expected;
header="Expected";
format=BEST6.;
label="Expected Frequency";
data_format_override=on print=on;
end;
define cellvalue Deviation;
header="Deviation";
format=BEST6.;
label="Deviation from Expected Frequency";
data_format_override=on print=on;
end;
define cellvalue CellChiSquare;
header="Cell Chi-Square";
NoTitle= 0
NoTitle= 0
NoTitle= 0
^=''
^='';
^='';
NoTitle= 0
420
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
format=BEST6.;
label="Cell Chi-Square";
print=on;
end;
define cellvalue TotalPercent;
header="Total Percent";
format=6.2;
label="Percent of Total Frequency";
print=on;
end;
define cellvalue Percent;
header="Percent";
format=6.2;
label="Percent of Two-Way Table Frequency";
print=on;
cellstyle _val_ > 20.0 as {color=#BF6930};
end;
define cellvalue RowPercent;
header="Row Percent";
format=6.2;
label="Percent of Row Frequency";
print=on;
end;
define cellvalue ColPercent;
header="Column Percent";
format=6.2;
label="Percent of Column Frequency";
print=on;
end;
define cellvalue CumColPercent;
header="Cumulative Column Percent";
format=6.2;
label="Cumulative Percent of Column Frequency";
print=on;
end;
header ControllingFor;
footer TableOf NoObs Missing;
cellvalue
Frequency Expected Deviation
CellChiSquare TotalPercent Percent
RowPercent ColPercent CumColPercent;
end;
run;
title "City Government Form by Number of Meetings Scheduled";
ods html file='MyCrosstabsTableLegend.html' style=ocean;
proc freq;
tables citygovt*robgrp / missprint;
run;
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
421
ods html close;
Program Description
Create the user-defined formats and the data set. The FORMAT procedure creates
two user-defined formats that can be used in the crosstabulation template. The DATA
step creates the Gov data set.
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
.='
?';
Value colfg
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
Value rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
other='black';
run;
data gov;
Label Citygovt='City Government Form'
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
422
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
3 3 27
3 4 55
3 . 1
;
Establish the ODS path. The ODS PATH statement specifies the locations to write to or
read from when you create the PROC TEMPLATE templates.
ods path (prepend) work.templat(update);
Create the crosstabulation template Base.Freq.CrossTabFreqs. The DEFINE
statement creates the crosstabulation template Base.Freq.CrossTabFreqs in the first
template store in the path for which you have Write access. The NOTES statement
provides information about the crosstabulation table.
proc template;
define crosstabs Base.Freq.CrossTabFreqs;
notes "Crosstabulation table with legend";
Specify a row heading, a column heading, and a label for the table. The
ROWS_HEADER= style attribute specifies RowsHeader as the header for rows. The
COLS_HEADER= style attribute specifies ColsHeader as the header for columns. The
LABEL= attribute specifies a label for the crosstabulation template. The
GRAND_TOTAL_STYLE= changes the FontWeight style attribute in the Data style
element to bold. This change affects the values in the rightmost column of the last row in
the table.
rows_header=RowsHeader cols_header=ColsHeader;
label = "Frequency Counts and Percentages";
grand_total_style=data {fontweight=bold};
Create the ControllingFor header template. The DEFINE HEADER statement and its
attributes create the header template ControllingFor. The DYNAMIC statement declares
dynamic variables so that they can be used in expressions. The TEXT statement
specifies the text of the header by using dynamic variables that represent label variables
and names. In this example, the expression in the TEXT statement resolves to false, so
the ControllingFor header does not show up in the output. The STYLE= attribute
specifies style information for the headers.
define header ControllingFor;
dynamic StratNum StrataVariableNames StrataVariableLabels;
text "Controlling for" StrataVariableNames / StratNum > 0;
style=header;
end;
Create the RowsHeader header template. The DEFINE HEADER statement creates
the header RowsHeader, which is specified by the preceding ROWS_HEADER= style
attribute. The TEXT statements specify the text of the header by using dynamic
variables that represent label variables and names. The first TEXT statement uses an
expression to determine whether a label is assigned to the row variable. If there is no
label, the next TEXT statement is used, which specifies the row name. In this example
there is a row label for the row variable, so in the output, _ROW_LABEL_ resolves to
"City Government Form".The STYLE= attribute specifies style information for the
header. The SPACE= attribute specifies that the current header and the previous header
should have one blank line between them. The CINDENT= attribute specifies that
wrapped lines start at the same column as the open parenthesis.
define header RowsHeader;
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
423
text _ROW_LABEL_ / _ROW_LABEL_ ^= '';
text _ROW_NAME_;
space=0;
style=header;
cindent=';';
end;
Create the ColsHeader header template. The DEFINE HEADER statement creates the
header ColsHeader, which is specified by the preceding COLS_HEADER= style
attribute. The TEXT statements specify the text of the header by using dynamic
variables that represent label variables and names. The first TEXT statement uses an
expression to determine whether a label is assigned to the variable. If there is no label,
the next TEXT statement is used, which specifies the row name. In this example there is
a column label, so in the output, _COL_LABEL_ resolves to "Number of Meetings
Scheduled".The STYLE= attribute specifies style information for the header. The
SPACE= attribute specifies that the current header and the previous header should have
one blank line between them. The CINDENT= attribute specifies that wrapped lines start
at the same column as the open parenthesis.
define header ColsHeader;
text _COL_LABEL_ / _COL_LABEL_ ^= '';
text _COL_NAME_;
space=1;
style=header;
cindent=';';
end;
Create the TableOf footer template. The DEFINE FOOTER statement and its attributes
create the footer template TableOf, which is specified by the FOOTER statement later on
in the program. The TEXT statements specify the text of the header by using dynamic
variables that represent label variables and names, the NOTITLE option, and the current
stratum number. The TEXT statements use expressions with these variables to determine
which text is displayed. Only the TEXT statements that have a true expression are
displayed in the output. In this example, the only text statement that has a true
expression is the fourth TEXT statement, and the text resolves to: " City Government
Form by Number of Meetings Scheduled".
define footer TableOf;
notes 'NoTitle is 1 if the NOTITLE option was specified.';
dynamic StratNum NoTitle;
text "Table " StratNum 3. " of " _ROW_LABEL_ " by " _COL_LABEL_ /
& StratNum > 0 & _ROW_LABEL_ ^= '' & _COL_LABEL_ ^= '';
text "Table " StratNum 3. " of " _ROW_LABEL_ " by " _COL_NAME_ /
& StratNum > 0 & _ROW_LABEL_ ^= ''
;
text "Table " StratNum 3. " of " _ROW_NAME_ " by " _COL_LABEL_ /
& StratNum > 0 & _COL_LABEL_ ^= '';
text _ROW_LABEL_ " by " _COL_LABEL_ / NoTitle = 0 & _ROW_LABEL_
& _COL_LABEL_ ^= '';
text _ROW_LABEL_ " by " _COL_NAME_ / NoTitle = 0 & _ROW_LABEL_
text _ROW_NAME_ " by " _COL_LABEL_ / NoTitle = 0 & _COL_LABEL_
text "Table " StratNum 3. " of " _ROW_NAME_ " by " _COL_NAME_ /
& StratNum > 0;
text _ROW_NAME_ " by " _COL_NAME_ / NoTitle = 0;
style=header;
end;
NoTitle= 0
NoTitle= 0
NoTitle= 0
^=''
^='';
^='';
NoTitle= 0
424
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Create additional footer templates. Each of these DEFINE FOOTER statements and
each of its attributes creates a footer template. To apply these footers to your output, you
must specify them in the FOOTER statement. The DYNAMIC statements declare the
dynamic variables FMissing, Stratnum, NoTitle, and SampleSize, so that they can be
used in the TEXT statements. The TEXT statements conditionally select text to use as
footers. In the first TEXT statement, the expression is true, because FMissing is not 0.
Therefore, the first TEXT statement is displayed in the output. In the second TEXT
statement, the expression resolves to false, and the NoObs footer does not appear in the
output. The STYLE attribute specifies style information for the footers. The SPACE
attribute specifies that the current footer and the previous footer should have one blank
line between them.
define footer Missing;
dynamic FMissing;
text "Frequency Missing = " FMissing -12.99 / FMissing ^= 0;
space=1;
style=header;
end;
define footer NoObs;
dynamic SampleSize;
text "Effective Sample Size = 0" / SampleSize = 0;
space=1;
style=header;
end;
Create the cellvalue definitions. The DEFINE CELLVALUE statements define the
values that appear in the cells of the crosstabulation table. The HEADER= attribute
specifies the text that appears in the legend. The LABEL= attribute specifies the label for
the data set column that corresponds to the cellvalue. The LABEL= attribute affects only
the Output destination. The DATA_FORMAT_OVERRIDE=ON attribute specifies to
use the format specified in the data component. The PRINT=ON attribute causes the
cellvalue to appear in the table. The CELLSTYLE AS statement uses expressions to
conditionally set the style element of the cells according to the values of the variables for
the Percent cellvalue. The _VAL_ variable represents the value of a cell. Therefore, in
this example, if the value in a cell is less than ten, then the font color for the DataStrong
style element is green. If the value in the cell is greater than twenty, the font color is
#BF6930.
define cellvalue Frequency;
header="Frequency";
format=BEST7.;
label="Frequency Count";
data_format_override=on print=on;
end;
define cellvalue Expected;
header="Expected";
format=BEST6.;
label="Expected Frequency";
data_format_override=on print=on;
end;
define cellvalue Deviation;
header="Deviation";
format=BEST6.;
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
425
label="Deviation from Expected Frequency";
data_format_override=on print=on;
end;
define cellvalue CellChiSquare;
header="Cell Chi-Square";
format=BEST6.;
label="Cell Chi-Square";
print=on;
end;
define cellvalue TotalPercent;
header="Total Percent";
format=6.2;
label="Percent of Total Frequency";
print=on;
end;
define cellvalue Percent;
header="Percent";
format=6.2;
label="Percent of Two-Way Table Frequency";
print=on;
cellstyle _val_ > 20.0 as {color=#BF6930};
end;
define cellvalue RowPercent;
header="Row Percent";
format=6.2;
label="Percent of Row Frequency";
print=on;
end;
define cellvalue ColPercent;
header="Column Percent";
format=6.2;
label="Percent of Column Frequency";
print=on;
end;
define cellvalue CumColPercent;
header="Cumulative Column Percent";
format=6.2;
label="Cumulative Percent of Column Frequency";
print=on;
end;
Specify header and footer templates. The HEADER statement specifies the header
templates that are applied to your output. The FOOTER statement specifies the footer
templates that are applied to your output. In order for any of the headers and footers that
were defined by a DEFINE statement to appear in your output, they must be specified by
the FOOTER or HEADER statement.
header ControllingFor;
footer TableOf NoObs Missing;
426
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Specify cellvalues and their order. The CELLVALUE statement specifies which
cellvalues appear in the table and the order. In this example, all of the cellvalues that you
created appear in the table, in the order specified by the CELLVALUE statement.
cellvalue
Frequency Expected Deviation
CellChiSquare TotalPercent Percent
RowPercent ColPercent CumColPercent;
end;
run;
Specify a title, create the HTML output, and specify the name of the HTML file. The
TITLE statement provides a title for the output. The ODS HTML statement with the
STYLE= option specifies the style template Ocean for the output.
title "City Government Form by Number of Meetings Scheduled";
ods html file='MyCrosstabsTableLegend.html' style=ocean;
Create the crosstabulation table. The FREQ procedure creates a Citygovt by Robgrp
crosstabulation table.
proc freq;
tables citygovt*robgrp / missprint;
run;
Close the HTML destination. The ODS HTML CLOSE statement closes the HTML
destination and all the files that are open for that destination.
ods html close;
Example 2: Creating a Crosstabulation Table Template with a Customized Legend
Output
Output 13.3 Output Using Customized Crosstabulation Table Template
427
428
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
Output 13.4 Output Using Default Crosstabulation Table
Example 3: Adding Custom Formats to Cellvalues
Features:
Other features:
EDIT statement
Other ODS features
ODS HTML statement
ODS PATH statement
Details
This example does not use the DEFINE CROSSTABS statement. Instead, it uses the
EDIT statement to edit the crosstabulation table template Base.Freq.CrossTabFreqs that
was created in “Example 2: Creating a Crosstabulation Table Template with a
Customized Legend” on page 416 by changing the formats of several cellvalues. In
“Example 2: Creating a Crosstabulation Table Template with a Customized Legend” on
page 416, the following format values were used:
Example 3: Adding Custom Formats to Cellvalues
•
Frequency: BEST6
•
Percent, RowPercent, ColPercent: 6.2
In this example, the Frequency cellvalue is changed to COMMA12; and the Percent,
RowPercent, and ColPercent cellvalues are changed to 6.3.
Program
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
other='black';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
.='
?';
Value colfg
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
run;
data gov;
Label Citygovt='City Government Form'
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
3 3 27
429
430
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
3 4 55
3 . 1
;
ods noproctitle;
ods path (prepend) work.templat(update);
proc template;
edit Base.Freq.CrossTabFreqs;
edit Frequency;
format=COMMA12.;
end;
edit Percent;
format=6.3;
end;
edit RowPercent;
format=6.3;
end;
edit ColPercent;
format=6.3;
end;
end;
run;
ods html file="userfmt.html" style=ocean;
title "Applying Custom Formats to Cellvalues";
proc freq;
tables citygovt*robgrp / missprint;
run;
ods html close;
Program Description
Create the user-defined formats and the data set. The FORMAT procedure creates
four user-defined formats that can be used in the crosstabulation template. The DATA
step creates the Gov data set.
Proc Format;
Value Govtfmt -3='Council Manager'
0='Commission'
3='Mayor Council'
.N='Not Applicable'
.='
?';
Value rowfg
-3='red'
0='purple'
3='blue'
.N='green'
.='black'
other='black';
Value Robfmt
1='100 or Less'
2='101-200'
3='201-300'
4='Over 300'
.N='Not
Known'
Example 3: Adding Custom Formats to Cellvalues
Value colfg
431
.='
?';
1='yellow'
2='red'
3='blue'
4='purple'
.N='green'
.='black'
other='black';
run;
data gov;
Label Citygovt='City Government Form'
Robgrp='Number of Meetings Scheduled';
Input Citygovt Robgrp Weight; Missing N;
Format Citygovt Govtfmt. Robgrp Robfmt.;
LOOP: OUTPUT; WEIGHT=WEIGHT-1; IF WEIGHT>0 THEN GOTO LOOP;
DROP WEIGHT;
datalines;
0 1 6
0 3 3
0 2 7
0 4 5
N N 10
-3 1 47
-3 3 49
-3 2 63
-3 4 52
. 2 1
3 1 31
3 2 37
3 3 27
3 4 55
3 . 1
;
Establish the ODS path. The ODS PATH statement specifies the locations to write to or
read from when creating the PROC TEMPLATE templates. The ODS NOPROCTITLE
statement suppresses the title of the FREQ procedure.
ods noproctitle;
ods path (prepend) work.templat(update);
Edit the crosstabulation template Base.Freq.CrossTabFreqs. The EDIT statement
changes the crosstabulation table template
Base.Freq.CrossTabFreqs that was created in “Example 2: Creating a Crosstabulation
Table Template with a Customized Legend” on page 416.
proc template;
edit Base.Freq.CrossTabFreqs;
Apply new formats to the cellvalues Frequency, Percent, RowPercent, and
ColPercent. The FORMAT= attribute specifies a format for the cellvalues. The format
COMMA12. is applied to Frequency, and the format 6.3 is applied to Percent,
RowPercent, and ColPercent.
edit Frequency;
format=COMMA12.;
432
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
end;
edit Percent;
format=6.3;
end;
edit RowPercent;
format=6.3;
end;
edit ColPercent;
format=6.3;
end;
end;
run;
Create the HTML output and specify the name of the HTML file. The ODS HTML
statement with the STYLE= option specifies the style template Ocean for the output.
ods html file="userfmt.html" style=ocean;
Create the crosstabulation table and add a title. The FREQ procedure creates a
Citygovt by Robgrp crosstabulation table. The TITLE statement specifies a title.
title "Applying Custom Formats to Cellvalues";
proc freq;
tables citygovt*robgrp / missprint;
run;
Close the HTML destination. The ODS HTML CLOSE statement closes the HTML
destination and all the files that are open for that destination.
ods html close;
Example 3: Adding Custom Formats to Cellvalues
Output
Output 13.5 Crosstabulation Output with Custom Formats Applied to Cellvalues
433
434
Chapter 13
•
TEMPLATE Procedure: Creating Crosstabulation Table Templates
435
Chapter 14
TEMPLATE Procedure: Creating
ODS Graphics
Introduction to the Graph Template Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Syntax: TEMPLATE Procedure: Creating ODS Graphics . . . . . . . . . . . . . . . . . . 438
Where to Go from Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Introduction to the Graph Template Language
Graphics are an indispensable part of statistical analysis. Graphics reveal patterns,
identify differences, and provoke meaningful questions about your data. Graphics add
clarity to an analytical presentation and stimulate deeper investigation.
SAS 9.2 introduces the Graph Template Language (GTL), a powerful new language for
defining clear and effective statistical graphics. The GTL enables you to generate
various types of plots, such as model fit plots, distribution plots, comparative plots,
prediction plots, and more.
The GTL applies accepted principles of graphics design to produce plots that are clean
and uncluttered. Colors, fonts, and relative sizes of graph elements are all designed for
optimal impact. By default, the GTL produces PNG files, which support true color (the
full 24-bit RGB color model) and enable visual effects such as anti-aliasing and
transparency, but retain a small file size. GTL statement options enable you to control
the content and appearance of the plot down to the smallest detail.
The GTL is designed to produce graphics with minimal syntax. The GTL uses a flexible,
building-block approach to create a graph by combining statements in a template called a
STATGRAPH template. STATGRAPH templates are defined with the TEMPLATE
procedure.
You can create custom graphs by defining your own STATGRAPH templates. To create
a custom graph, you must perform the following steps:
1. Define a STATGRAPH template with the TEMPLATE procedure.
2. Use the Graph Template Language to specify the parameters of your graph.
3. Associate your data with the template by using the SGRENDER procedure.
With a few statements, you can create the plots that you need to analyze your data. For
example, you can create the following model fit plot with these statements:
proc template;
define statgraph mytemplate;
436
Chapter 14
•
TEMPLATE Procedure: Creating ODS Graphics
beginGraph;
entrytitle "Model Weight by Height";
layout overlay;
bandplot x=height limitupper=upper limitlower=lower;
scatterplot y=weight x=height;
seriesplot y=predict x=height;
endlayout;
endGraph;
end;
run;
proc sgrender data=sashelp.classfit
template=mytemplate;
run;
Figure 14.1
Model Fit Plot Using Mytemplate and Sashelp.Classfit
This example defines a STATGRAPH template named mytemplate, which uses values
from the data set Sashelp.Classfit. This data set contains data variables HEIGHT and
WEIGHT and precomputed values for the fitted model (PREDICT) and confidence band
(LOWER and UPPER). The SGRENDER procedure uses the data in Sashelp.Classfit
and the template mytemplate to render the graph. (This example is member
GTLMFIT1 in the SAS Sample Library.)
The following two graphics are just examples of what you can do with ODS graphics.
Introduction to the Graph Template Language
Figure 14.2
PROC SGSCATTER (SAS) with LISTING Style
437
438
Chapter 14
Figure 14.3
•
TEMPLATE Procedure: Creating ODS Graphics
Custom Template Rendered with PROC SGRENDER (SAS) and a Custom Style
Syntax: TEMPLATE Procedure: Creating ODS
Graphics
See:
For complete documentation on the syntax and usage of the Graph Template
Language, see the following documentation: SAS Graph Template Language:
Reference and SAS Graph Template Language: User's Guide.
PROC TEMPLATE;
DEFINE STATGRAPH graph-path </ STORE=libref.template-store>;
DYNAMIC variable-1<'text-1'><variable-n<'text-n'>>;
MVAR variable-1<'text-1'><variable-n<'text-n'>>;
NMVAR variable-1<'text-1'><variable-n<'text-n'>>;
NOTES 'text';
graph-template-language-statements
END;
END;
Where to Go from Here
439
Where to Go from Here
Creating statistical graphics with ODS:
For reference information about the Graph Template Language, see SAS Graph
Template Language: Reference.
Creating statistical graphics with ODS:
For usage information about PROC TEMPLATE and the Graph Template Language,
see SAS Graph Template Language: User's Guide.
Managing the various templates stored in template stores:
For reference information about the PROC TEMPLATE statements that help you
manage and navigate around the many ODS templates, see Chapter 12,
“TEMPLATE Procedure: Managing Template Stores,” on page 349.
Modifying an existing style or creating your own style:
For reference information about the style template statements in PROC TEMPLATE,
see Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page 442.
440
Chapter 14
•
TEMPLATE Procedure: Creating ODS Graphics
441
Chapter 15
TEMPLATE Procedure: Creating
a Style Template
Overview: ODS Style Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Using the TEMPLATE Procedure to Create a Style . . . . . . . . . . . . . . . . . . . . . . . . 442
Default Style for HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Customized Version of the HTML Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Concepts: Styles and the TEMPLATE Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Viewing the Contents of a Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Working with Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
ODS Styles with Graphical Style Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Understanding Styles, Style Elements, and Style Attributes . . . . . . . . . . . . . . . . . 448
Understanding Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
Understanding Style References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Using the FROM Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Inheritance Compatibility across Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Syntax: TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . . . .
PROC TEMPLATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DEFINE STYLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CLASS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EDIT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IMPORT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOTES Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PARENT= Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
REPLACE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STYLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
461
462
462
464
465
467
467
468
469
470
470
Style Attributes Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Style Attributes Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Detailed Information for All Style Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Style Attribute Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Examples: TEMPLATE Procedure: Creating a Style Template . . . . . . . . . . . . . . 521
Example 1: Creating a Stand-Alone Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Example 2: Using User-Defined Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Example 3: Modifying the Default Style with the CLASS Statement . . . . . . . . . . 537
Example 4: Defining a Table and Graph Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Example 5: Defining Multiple Style Elements in One STYLE Statement . . . . . . . 551
Example 6: Importing a CSS File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Example 7: Table Header and Footer Border Formatting . . . . . . . . . . . . . . . . . . . 563
Example 8: Enhancing Titles and Footnotes in PDF Output . . . . . . . . . . . . . . . . . 568
442
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Example 9: Customizing Graphic and Tabular Titles in PDF Output . . . . . . . . . . 571
Overview: ODS Style Templates
Using the TEMPLATE Procedure to Create a Style
The TEMPLATE procedure enables you to customize the look of your SAS output. The
TEMPLATE procedure creates and modifies styles. The Output Delivery System then
uses these styles to produce customized formatted output.
By default, ODS output is formatted according to the various styles that the procedure or
DATA step specifies. However, you can also customize the appearance of the output by
using the DEFINE STYLE statement in the TEMPLATE procedure.
Default Style for HTML
By default, ODS uses styles to display the procedure or DATA step results. Modify the
appearance of the output by customizing these styles. The first output that follows shows
the HTML output from PROC PRINT using the default style. The second output that
follows shows the same HTML output from PROC PRINT with a customized style. The
default style for HTML output is Styles.HTMLBlue.
Figure 15.1
HTML Output from PROC PRINT That Uses the Default Style (Viewed with Microsoft Internet Explorer)
Overview: ODS Style Templates
443
Customized Version of the HTML Style
When you are working with styles, you are more likely to modify a SAS style than to
write a completely new style. The next display shows the types of changes that you can
make to the default style for the HTML output. The new style affects both the contents
file and the body file in the HTML output. In particular, in the contents file, the style
makes changes to the following attributes:
•
the background of the contents file
•
the background of the contents title
•
the name of the table of contents (Contents instead of Table of Contents)
In the body file, the new style makes changes to the following attributes:
•
the text of the header and the text that identifies the procedure that produced the
output
•
the colors for some parts of the text
•
the colors of the borders
•
the background colors
Figure 15.2 HTML Output from PROC PRINT with the Customized Style (Viewed with Microsoft Internet Explorer)
444
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Concepts: Styles and the TEMPLATE Procedure
Terminology
For more definitions of terms used in this section, see “Terminology: TEMPLATE
Procedure” on page 338.
child
within a dimension hierarchy, a descendant in level n-1 of a member that is at level
n. For example, if a Geography dimension includes the levels Country and City, then
Bangkok would be a child of Thailand, and Hamburg would be a child of Germany.
parent
within a dimension hierarchy, the ancestor in level n of a member in level n-1. For
example, if a Geography dimension includes the levels Country and City, then
Thailand would be the parent of Bangkok, and Germany would be the parent of
Hamburg. The parent value is usually a consolidation of all of its children's values.
Viewing the Contents of a Style
To view the contents of a style, use the SAS windowing environment, the command line,
or the TEMPLATE procedure.
•
Using the SAS Windowing Environment
1. In the Results window, select the Results folder. Right-click and select
Templates to open the Templates window.
2. Double-click Sashelp.Tmplmst to view the contents of that directory.
3. Double-click Styles to view the contents of that directory.
•
Using the Command Line
1. To view the Templates window, submit this command in the command line:
odstemplates
The Templates window contains the item stores Sasuser.Templat and
Sashelp.Tmplmst.
2. Double-click an item store, such as Sashelp.Tmplmst, to expand the list of
directories where ODS templates are stored. The templates that SAS provides are
in the item store Sashelp.Tmplmst.
3. To view the styles that SAS provides, double-click theStyles item store.
4. Right-click the style, such as Journal, and select Open. The style template is
displayed in the Template Browser window.
•
Using the TEMPLATE Procedure
1. Submit this code to view the contents of the default HTML style that SAS
supplies.
proc template;
source styles.htmlblue;
run;
Concepts: Styles and the TEMPLATE Procedure
445
2. View any of the SAS styles by specifying STYLES.style-template in the
SOURCE statement. The SAS styles are in the Sashelp.Tmplmst item store.
Working with Styles
Finding and Viewing the Default Style for ODS Destinations
The default styles for the ODS output destinations are stored in the Styles item store in
the template store Sashelp.Tmplmst, along with the other styles that are supplied by
SAS. You can view the styles from the Templates window, or you can submit this PROC
TEMPLATE step to write the style to the SAS log:
proc template;
source styles.template-name;
run;
The following table lists the ODS destinations and their default styles:
Table 15.1
Recommended Styles for ODS Destinations
Destination
EPUB
Recommended Styles
Default Style
Daisy
Daisy
*Moonflower
Printer family of statements
FancyPrinter
Pearl
FestivalPrinter
GrayscalePrinter
MeadowPrinter
MonoChromePrinter
Monospace
NormalPrinter
Pearl
Printer
Sapphire
SasDocPrinter
SeasidePrinter
RTF
RTF
RTF
TAGSETS.RTF
RTF
RTF
ODS destination for
PowerPoint
PowerPointDark
PowerPointLight
SASREPORT for Enterprise
Guide
EGDefault
PowerPointLight
HTMLBlue
HTMLBlue
446
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Destination
Recommended Styles
Default Style
SASREPORT for Web Report
Studio
Normal
Plateau
Plateau
Seaside
LISTING
Listing
Listing
HTML
Minimal
HTMLBlue
EGDefault
Normal
Seaside
HTMLBlue
Analysis
BarrettsBlue
BlockPrint
Default
Dove
Dtree
Festival
Gantt
Harvest
HighContrast
Journal
Journal1
Journal1a
Journal2
Journal2a
Journal3
Journal3a
Meadow
Netdraw
NoFontDefault
Normal
Ocean
Plateau
Raven
SasWeb
Seaside
StatDoc
Statistical
Concepts: Styles and the TEMPLATE Procedure
Destination
Recommended Styles
Default Style
TAGSETS.EXCELXP
Default
Default
447
* The Moonflower style for ODS EPUB is designed for nighttime or low-light reading.
Modifying Style Elements in the Default Style for HTML and Markup
Languages
When you work with styles, it is often more efficient to modify a SAS style than to write
a completely new style. “Example 3: Modifying the Default Style with the CLASS
Statement” on page 537 shows you how to modify the default style.
To customize the style for use at a specific site, it is helpful to know what each style
element in the style specifies. For a list of the default HTML and markup languages style
elements, see Chapter 21, “Style Elements,” on page 831.
ODS Styles with Graphical Style Information
SAS provides ODS styles that incorporate graphical style information. These styles use a
number of style attributes that are used by other style elements, but they also use several
style attributes that are unique to graph styles. For example, use the STARTCOLOR=
style attribute and the ENDCOLOR= style attribute to produce a gradient effect that
gradually changes from the starting color to the ending color in a specified element.
When either the STARTCOLOR= style attribute or the ENDCOLOR= style attribute, but
not both, is specified, then the style attribute that was not specified is transparent when
the TRANSPARENCY= style attribute is being used. In “Example 4: Defining a Table
and Graph Style” on page 543, only the ENDCOLOR= style attribute is specified.
Therefore, the starting color is transparent.
The TRANSPARENCY= style attribute is another style attribute that is unique to graph
styles. With transparency, specify the level of transparency (from 0.0 to 1.0) to indicate
the percentage of transparency (0 to 100 %) for the graph element. While you can use
the BACKGROUNDIMAGE= style attribute in other style elements to stretch an image,
in graph styles, you can also use the IMAGE= style attribute to position or tile an image.
With graph styles, elements, or templates, you can also combine images and colors to
create a blending affect. The blending works best when you use a gray-scale image with
a specified color. Blending is done in these style elements: GraphLegendBackground,
GraphCharts, GraphData#, GraphFloor, and GraphWalls. To blend, specify a color using
the BACKGROUNDCOLOR= or COLOR= style attribute and specify an image using
the BACKGROUNDIMAGE= or IMAGE= style attribute.
Note: When using the GraphData# style element, you can use the COLOR= style
attribute, but not the BACKGROUNDCOLOR= style attribute to specify a color
value.
See “Style Attributes Tables ” on page 473 for a complete listing of style attributes. For
a complete list of style elements see Chapter 21, “Style Elements,” on page 831.
In addition to using defined ODS styles, you can also modify an existing style or create
an entirely new style using the new graph style elements. “Example 4: Defining a Table
and Graph Style” on page 543 describes how a defined ODS style was generated.
See “Viewing the Contents of a Style” on page 444 for information about viewing the
code for the ODS styles that are delivered with SAS.
448
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Understanding Styles, Style Elements, and Style Attributes
The appearance of SAS output is controlled by style templates (styles). A style is a type
of ODS template that defines the visual aspects (colors, fonts, lines, markers, and so on)
of SAS output. A style determines the overall look of the documents that use it. Style
templates consist of style elements and style attributes.
•
A style element is a named collection of style attributes that apply to a particular part
of the output. Each area of ODS output has a style element name that is associated
with it. The style element name specifies where the style attributes are applied. For
example, a style element might contain instructions for the presentation of column
headings or for the presentation of the data inside the cells. Style elements might also
specify default colors and fonts for output that uses the style.
•
A style attribute is a visual property, such as color, font properties, and line
characteristics, that is defined in ODS with a reserved name and value. Style
attributes are collectively referenced by a style element within a style template. Each
style attribute specifies a value for one aspect of the presentation. For example, the
BACKGROUNDCOLOR= attribute specifies the color for the background of an
HTML table or for a colored table in printed output. The FONTSTYLE= attribute
specifies whether to use a Roman font or an italic font.
Note: Because styles control the presentation of the data, they have no effect on output
objects that go to the LISTING, DOCUMENT, or OUTPUT destination.
Available styles are in the SASHELP.TMPLMST item store. In SAS Enterprise Guide,
the list of style sheets is shown by the Style Wizard. In batch mode or SAS Studio, you
can display the list of available style templates by submitting this code:
proc template;
list styles / store=sashelp.tmplmst;
run;
For complete information about viewing ODS styles, see “Viewing ODS Styles Supplied
by SAS” on page 789.
By default, HTML output uses the HTMLBlue style template. To help you become
familiar with styles, style elements, and style attributes, look at the relationship between
them. The diagram that follows shows the relationship between the style, the style
elements, and the style attributes. The following figure illustrates the structure of a style:
Concepts: Styles and the TEMPLATE Procedure
Figure 15.3
Diagram of the HtmlBlue Style
449
450
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
The following list corresponds to the numbered items in the preceding figure:
1
Styles.HtmlBlue is the style. Styles describe how to display presentation aspects
(color, font, font size, and so on) of the SAS output. A style determines the overall
appearance of the ODS documents that use it. The default style for HTML output is
HtmlBlue. Each style consists of style elements. Each destination has a default style
that is applied to all output that is written to the destination.
•
The default style for HTML output is HTMLBlue.
•
The default style for PRINTER output is Pearl.
•
The default style for RTF output is RTF.
You can create new styles with the “DEFINE STYLE Statement” on page 462. New
styles can be created independently or from an existing style. You can use
“PARENT= Statement” on page 469 to create a new style from an existing style. For
complete documentation about ODS styles, see “Style Templates” in SAS Output
Delivery System: User's Guide.
2
Header and Footer are examples of style elements. A style element is a collection of
style attributes that apply to a particular part of the output for a SAS program. For
example, a style element might contain instructions for the presentation of column
headings or for the presentation of the data inside table cells. Style elements might
also specify default colors and fonts for output that uses the style. Style elements
exist inside styles and consist of one or more style attributes. Style elements can be
user-defined or supplied by SAS. User-defined style elements can be created by the
“STYLE Statement” on page 470.
Note: For a list of the default style elements used for HTML and markup languages
and their inheritance, see “Style Elements” in SAS Output Delivery System:
User's Guide.
3
BORDERCOLOR=, BACKGROUNDCOLOR=, and COLOR= are examples of
style attributes. Style attributes specify a value for one aspect of the area of the
output that its style element applies to. For example, the COLOR= attribute specifies
the value cx112277 for the font color. For a list of style attributes supplied by SAS,
see “Style Attributes” in SAS Output Delivery System: User's Guide.
Style attributes can be referenced with style references. See “style-reference” on page
521 for more information about style references.
The following table shows commonly used style attributes that you can set with the
STYLE= option in PROC PRINT, PROC TABULATE, and PROC REPORT. Most of
these attributes apply to parts of the table other than cells (for example, table borders and
the lines between columns and rows). Note that not all attributes are valid in all
destinations. For more information about these style attributes, their valid values, and
their applicable destinations, see “Style Attributes Tables ” on page 473.
Table 15.2
Attribute
ASIS=
Style Attributes for PROC REPORT, PROC TABULATE, and PROC PRINT
PROC
REPORT
STATEMENT
REPORT
Area
PROC
REPORT
Areas:
CALLDEF,
COLUMN,
HEADER,
LINES,
SUMMARY
X
X
PROC
TABULATE
STATEMENT
TABLE
PROC
TABULATE
STATEMENTS
VAR, CLASS,
BOX,
CLASSLEV,
KEYWORD
X
PROC
PRINT
TABLE
location
PROC
PRINT:
all
locations
other
than
TABLE
X
451
Concepts: Styles and the TEMPLATE Procedure
PROC
REPORT
STATEMENT
REPORT
Area
PROC
REPORT
Areas:
CALLDEF,
COLUMN,
HEADER,
LINES,
SUMMARY
BACKGOUNDCOLOR
=
X
BACKGOUNDIMAGE=
PROC
TABULATE
STATEMENT
TABLE
PROC
TABULATE
STATEMENTS
VAR, CLASS,
BOX,
CLASSLEV,
KEYWORD
PROC
PRINT
TABLE
location
PROC
PRINT:
all
locations
other
than
TABLE
X
X
X
X
X
X
X
X
X
X
X
BORDERBOTTOMCOL
OR=
X
X
BORDERBOTTOMSTY
LE=
X
X
X
X
BORDERBOTTOMWID
TH=
X
X
X
X
BORDERLEFTCOLOR
=
X
X
BORDERLEFTSTYLE=
X
X
X
X
BORDERLEFTWIDTH
=
X
X
X
X
BORDERCOLOR=
X
X
X
X
X
BORDERCOLORDARK
=
X
X
X
X
X
X
BORDERCOLORLIGH
T=
X
X
X
X
X
X
BORDERRIGHTCOLO
R=
X
X
BORDERRIGHTSTYLE
=
X
X
X
X
BORDERRIGHTWIDT
H=
X
X
X
X
BORDERTOPCOLOR=
X
X
BORDERTOPSTYLE=
X
X
X
X
BORDERTOPWIDTH=
X
X
X
X
BORDERWIDTH=
X
X
X
X
X
X
CELLPADDING=
X
X
X
CELLSPACING=
X
X
X
Attribute
X
X
X
X
452
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
PROC
REPORT
STATEMENT
REPORT
Area
PROC
REPORT
Areas:
CALLDEF,
COLUMN,
HEADER,
LINES,
SUMMARY
PROC
TABULATE
STATEMENT
TABLE
PROC
TABULATE
STATEMENTS
VAR, CLASS,
BOX,
CLASSLEV,
KEYWORD
CELLWIDTH=
X
X
X
X
CLASS=
X
X
X
X
COLOR=
X
X
X
FLYOVER=
X
X
FONT=
X
X
X
X
X
X
FONTFAMILY=
X
X
X
X
X
X
FONTSIZE=
X
X
X
X
X
X
FONTSTYLE=
X
X
X
X
X
X
FONTWEIGHT=
X
X
X
X
X
X
FONTWIDTH=
X
X
X
X
FRAME=
X
HEIGHT=
X
Attribute
HREFTARGET=
PROC
PRINT
TABLE
location
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
NOBREAKSPACE=
X
X
OUTPUTWIDTH=
X
X
X
X
X
POSTHTML=*
X
X
X
X
X
X
POSTIMAGE=
X
X
X
X
X
X
POSTTEXT=*
X
X
X
X
X
X
PREHTML=*
X
X
X
X
X
X
PREIMAGE=
X
X
X
X
X
X
PRETEXT=*
X
X
X
X
X
X
X
X
X
X
TAGATTR=
X
X
X
X
X
X
RULES=
X
X
HTMLSTYLE=
PROTECTSPECIALCH
ARS=
X
PROC
PRINT:
all
locations
other
than
TABLE
X
X
X
X
X
X
453
Concepts: Styles and the TEMPLATE Procedure
Attribute
TEXTALIGN=
PROC
REPORT
STATEMENT
REPORT
Area
PROC
REPORT
Areas:
CALLDEF,
COLUMN,
HEADER,
LINES,
SUMMARY
X
X
PROC
TABULATE
STATEMENT
TABLE
PROC
TABULATE
STATEMENTS
VAR, CLASS,
BOX,
CLASSLEV,
KEYWORD
PROC
PRINT
TABLE
location
PROC
PRINT:
all
locations
other
than
TABLE
X
X
X
X
URL=
X
X
X
VERTICALALIGN=
X
X
X
WIDTH=
X
X
X
X
X
* When you use these attributes in this location, they affect only the text that is specified with the PRETEXT=, POSTTEXT=,
PREHTML=, and POSTHTML= attributes. To alter the foreground color or the font for the text that appears in the table, you must set
the corresponding attribute in a location that affects the cells rather than the table. For complete documentation about style attributes
and their values, see Chapter 22, “Style Attributes,” on page 859.
Understanding Inheritance
Overview
Inheritance can be initiated by the PARENT= statement or the FROM= option in the
STYLE statement.
The PARENT= statement specifies that PROC TEMPLATE copy all of the style
elements from the parent style to the new child style. The style elements are used in the
new template unless the new template has style elements that overrides them.
The FROM= option specifies that PROC TEMPLATE copy all of the style attributes
from the parent style element to the specified child style element.
Inheritance between Styles
Inheritance between styles is initiated by the PARENT= option, and involves the
following process:
1. When the PARENT= statement is specified, style elements in the parent style are
copied into the new style. This copying occurs before any inheritance can occur
within the new style.
2. If there is a like-named style element within the child style that does not have a
FROM option specified, then the style element from the child style overrides the
style element from the parent style.
3. If there is a like-named style element within the child style that does have the FROM
option specified, then the child style element absorbs the style attributes from the
parent style element. If there are like-named style attributes in the two style
elements, then the style attributes from the child style element are used.
The following code shows an example of inheritance between two styles:
Example Code 15.1
Original Code for Creating Style2
define style style1;
style fonts /
454
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
"docfont" = ("Arial", 3)
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
font = fonts("docfont");
style table from output /
borderspacing = 2
font = fonts("tablefont");
style header /
backgroundcolor=white
color=blue
fontfamily="arial, helvetica"
fontweight=bold;
end;
define style style2;
parent = style1;
style fonts from fonts /
"docfont" = ("Helvetica", 3);
style table from table /
borderspacing = 4;
style header /
fontstyle=roman
fontsize=5;
end;
The Style2 style from the previous code could also be written this way:
Example Code 15.2
Expanded Version of Style2
define style style2;
style fonts/
"docfont" = ("Helvetica", 3)
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
font = fonts("docfont");
style table from output /
borderspacing=4
font = fonts("tablefont");
style header /
fontstyle=roman
fontsize=5;
end;
Inheritance between Style Elements
The FROM option in a STYLE statement is used to initiate inheritance from another
style element. The style element referenced by the FROM option can exist in either the
current style or the parent style (if a parent template is specified using the PARENT=
statement).
For example, in both the Example Code 15.1 on page 453 and the Example Code 15.2 on
page 454 the Table style element, which is created with the style table from
output / ..., statement, ends up with the following style attributes:
Concepts: Styles and the TEMPLATE Procedure
•
cellpadding= 5
•
borderspacing= 4
•
font=fonts("tablefont")
455
Understanding Style References
A style reference references a style attribute in a style element. The style element can
exist either in the current style or in the parent style.
For example, suppose that you create a style element named DataCell that uses the
COLOR= and BACKGROUNDCOLOR= style attributes:
style datacell / backgroundcolor=blue
color=white;
To ensure that another style element, NewCell, uses the same background color, use a
style reference in the NewCell element, like this:
style newcell / backgroundcolor=datacell(backgroundcolor);
The style reference datacell(backgroundcolor) indicates that the value for the
style attribute BACKGROUNDCOLOR= of the style element named DataCell should be
used.
Similarly, suppose that you create a style element named HighLighting that defines three
style attributes:
style highlighting /
"go"=green
"caution"=yellow
"stop"=red;
You can then define a style element named Messages that references the colors that are
defined in the HighLighting style element:
style messages;
"note"=highlighting("go")
"warning"=highlighting("caution")
"error"=highlighting("stop");
Because you used style references, multiple style elements can use the colors defined in
the HighLighting style element. If you change the value of go to blue in the
HighLighting style element, then every style element that uses the style reference
highlighting("go") will use blue instead of green.
In the following code, the FONT= style attribute in the Output style element is defined
in terms of the Fonts style element. The value fonts("docfont") tells PROC
TEMPLATE to go to the last instance of the style element named Fonts and use the
value for the style attribute DocFont.
The FONT= style attribute in the Table style element is also defined in terms of the
Fonts style element. The value fonts("tablefont") tells PROC TEMPLATE to go
to the last instance of the style element named Fonts and use the value for the style
attribute TableFont.
Example Code 15.3 Program with Unresolved Style References
define style style1;
style fonts /
"docfont" = ("Arial", 3)
456
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
font = fonts("docfont");
style table from output /
borderspacing = 2
font = fonts("tablefont");
style header /
backgroundcolor=white
color=blue
fontfamily="arial, helvetica"
fontweight=bold;
end;
define style style2;
parent = style1;
style fonts from fonts /
"docfont" = ("Helvetica", 3);
style table from table /
borderspacing = 4;
style header /
fontstyle=roman
fontsize=5;
end;
When you submit the code in SAS, the output is created as if you submitted the
following program. Notice that in the Output style element, the style reference resolves
to ("helvetica", 3), not ("Arial", 3). This is because the "DocFont" usersupplied style attribute in the Style2 style overrides the like-named style attribute in the
Style1 style.
Example Code 15.4
Program with Unresolved Style References
define style style1;
style fonts /
"docfont" = ("Arial", 3)
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
/*** Resolved from "docfont" in Style2***/
font = fonts("helvetica", 3);
style table from output /
borderspacing = 2
/*** Resolved from "tablefont" in Style1***/
font = fonts("Times", 2);
style header /
backgroundcolor=white
color=blue
fontfamily="arial, helvetica"
fontweight=bold;
end;
define style style2;
parent = style1;
Concepts: Styles and the TEMPLATE Procedure
457
style fonts from fonts /
"docfont" = ("Helvetica", 3);
style table from table /
borderspacing = 4;
style header /
fontstyle=roman
fontsize=5;
end;
Using the FROM Option
The FROM option is used with a style element in order to inherit from another style
element. If you omit the FROM option, then you can have an incomplete style element
in the child style.
For example, in the following SAS program, the style Concepts.Style2 inherits all of its
style elements and style attributes from the style Concepts.Style1. However, the instance
of the style element Colors in Concepts.Style2 overrides the instance of Colors in
Concepts.Style1. This is because there is no FROM option in the STYLE statement that
creates Colors in Concepts.Style2. Therefore, Colors has one style attribute:
"dark"=dark blue.
When you run the program, the only style references to Color that resolve are references
that refer to the "dark" style attribute. Style references in Concepts.Style1 and
Concepts.Style2 such as colors("fancy") and colors("medium") do not resolve
because they refer to attributes that were not copied into the current instance of the
Colors style element. The resulting output is Figure 15.4 on page 458.
To correct this, in the following program, you can add the FROM option to the STYLE
statement that creates the Colors style element in Concepts.Style2:
style colors from colors /
"dark"=dark blue;
Note: In the following code, Concepts is a folder that is created in Templates ð
Sasuser.Templat. Style1 is a template that is created in the Concepts folder.
Example Code 15.5
Creating the Colors Style Element without the FROM Option
proc template;
define style concepts.style1;
style colors /
"default"=white
"fancy"=very light vivid blue
"medium"=red ;
style celldatasimple /
fontfamily=arial
backgroundcolor=colors("fancy")
color=colors("default");
style celldataemphasis from celldatasimple /
color=colors("medium")
fontstyle=italic;
style celldatalarge from celldataemphasis /
fontweight=bold
fontsize=3;
end;
run;
458
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
proc template;
define style concepts.style2;
parent=concepts.style1;
style colors /
"dark"=dark blue;
style celldataemphasis from celldataemphasis /
backgroundcolor=white;
style celldatasmall from celldatalarge /
fontsize=5
color=colors("dark")
backgroundcolor=colors("medium");
end;
run;
For the complete SAS code that created the following output, see the version of the code
without the FROM option in “Using the FROM option” in SAS Output Delivery System:
User's Guide.
Figure 15.4
Output Created without the FROM Option
For the complete SAS code that created the following output, see the version of the code
with the FROM option in “Using the FROM option” in SAS Output Delivery System:
User's Guide.
Concepts: Styles and the TEMPLATE Procedure
Figure 15.5
459
Output Created with the FROM Option
Inheritance Compatibility across Versions
In most cases, an ODS style element or style that was created in a previous version of
SAS will still be compatible with later versions of SAS. However, beginning with SAS
9.2, style inheritance is completely expanded before style element inheritance takes
place. This change can cause discrepancies between the output a program creates in a
previous version of SAS and the output that same program creates in SAS 9.2.
The following program creates different output depending on whether it is run in SAS
9.2 or in a previous version of SAS. In SAS 9.2, the yellow background that
CellDataEmphasis has in Concepts.Style2 is passed to CellDataLarge and
CellDataSmall. However, in previous versions of SAS, the yellow background is not
passed to CellDataLarge and CellDataSmall. For more information about the using the
FROM option, see “Using the FROM Option” on page 457.
Note: In the following code, Concepts is a folder that is created in Templates ð
Sasuser.Templat. Style1 is a template that is created in the Concepts folder.
proc template;
define style concepts.style1;
style celldatasimple /
fontfamily=arial
backgroundcolor=very light vivid blue
color=white;
style celldataemphasis from celldatasimple /
color=red 1
fontstyle=italic;
style celldatalarge from celldataemphasis /
fontweight=bold
fontsize=5;
end;
run;
proc template;
define style concepts.style2;
460
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
parent=concepts.style1;
style celldataemphasis from celldataemphasis 3 /
backgroundcolor=yellow 2 ;
style celldatasmall from celldatalarge /
fontsize=2;
end;
run;
The output this program creates when you run it in a previous version of SAS is different
from the output the program creates in SAS 9.2 and beyond. This is because, when you
change the value of the COLOR= attribute in CellDataEmphasis from red (1) to yellow
(2), the change affects only style elements that inherit from CellDataEmphasis in
Concepts.Style2. Within Concepts.Style2, there are no style elements that inherit from
CellDataEmphasis (3). Therefore, only CellDataEmphasis in Concepts.Style2 has yellow
text. Beginning with SAS 9.2, all style elements in parent style templates also pick up
the color change.
For the complete SAS code that created this output, see the SAS 9.1 version of the code
in “Inheritance Compatibility Across SAS Versions” in SAS Output Delivery System:
User's Guide.
Figure 15.6
SAS 9.2 Output
Syntax: TEMPLATE Procedure: Creating a Style Template
Figure 15.7
461
SAS 9.1 Output
Syntax: TEMPLATE Procedure: Creating a Style
Template
PROC TEMPLATE;
DEFINE STYLE style-path | Base.Template.Style </ STORE=libref.template-store>;
PARENT=style-path;
NOTES "text";
CLASS style-element-name(s) <"text">
</ style-attribute-specification(s)>;
STYLE style-element-name(s) <FROM style-element-name | _SELF_ > <"text">
</ style-attribute-specification(s)>;
END;
END;
Statement
Task
Example
PROC
TEMPLATE
Begin a PROC TEMPLATE template
Ex. 1, Ex. 2,
Ex. 3, Ex. 4,
Ex. 5, Ex. 6,
Ex. 7
DEFINE STYLE
Create a style for any destination that supports the
STYLE= option
Ex. 1, Ex. 2,
Ex. 3, Ex. 4,
Ex. 5, Ex. 6,
Ex. 7
462
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Statement
Task
Example
CLASS
Create a style element from a like-named style element
Ex. 3, Ex. 6
END
End the style
Ex. 1, Ex. 2,
Ex. 3, Ex. 4,
Ex. 5, Ex. 6,
Ex. 7
EDIT
Edit a style
IMPORT
Import Cascading Style Sheet (CSS) information from a
file into the style
NOTES
Provide information about the style
PARENT=
Specify the style from which the current style inherits
Ex. 3, Ex. 4,
Ex. 6, Ex. 7
STYLE
Create or modify one or more style elements
Ex. 1, Ex. 2,
Ex. 4, Ex. 5,
Ex. 7
Ex. 6
PROC TEMPLATE Statement
Begins a PROC TEMPLATE template.
Syntax
PROC TEMPLATE;
DEFINE STYLE style-path | Base.Template.Style </ STORE=libref.template-store>;
PARENT=style-path;
NOTES "text";
CLASS style-element-name(s) <"text">
</ style-attribute-specification(s)>;
STYLE style-element-name(s) <FROM style-element-name | _SELF_ > <"text">
</ style-attribute-specification(s)>;
END;
END;
DEFINE STYLE Statement
Creates a style for any destination that supports the STYLE= option. The DEFINE STYLE statement
begins a DEFINE STYLE statement block.
Requirement:
Supports:
An END statement must be the last statement in the template.
The DEFINE STYLE statement supports the following statements: “CLASS
Statement” on page 464, “IMPORT Statement” on page 467, “NOTES Statement”
on page 397, “PARENT= Statement” on page 469, and “STYLE Statement” on page
470.
DEFINE STYLE Statement
Examples:
463
“Example 1: Creating a Stand-Alone Style” on page 521
“Creating a Cover Page with the LAYOUT_ABSOLUTE Method” in SAS Output
Delivery System: Advanced Topics
“Example 1: Adding Text to Multiple Destinations ” on page 61
“Example 5: Setting the Style Element for a Specific Column, Row, and Cell” on page
637
“Example 7: Table Header and Footer Border Formatting” on page 647
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
DEFINE STYLE style-path | Base.Template.Style </ STORE=libref.template-store>;
PARENT=style-path;
NOTES "text";
CLASS style-element-name(s)<"text">
</ style-attribute-specification(s)>;
IMPORT style-specification <media-type-1 <, media-type-2> …>;
STYLE style-element-name(s) <FROM style-element-name | _SELF_ > <"text">
</ style-attribute-specification(s)>;
END;
Required Arguments
style-path
specifies where to store the style. A style-path consists of one or more names,
separated by periods. Each name represents a directory in a template store. PROC
TEMPLATE writes the style to the first writable template store in the current path.
Base.Template.Style
creates a style that is the parent of all styles that do not explicitly specify a parent.
After this template is created, you do not need to explicitly specify it in your SAS
programs. It is automatically applied to all output until you specifically remove it
from the item store.
To view the Base.Template.Style using the SAS Windowing Environment:
1. In the Results window, select the Results folder. Right-click and select
Templates to open the Templates window.
2. Double-click Sashelp.Tmplmst to view the contents of that directory.
3. Double-click Base to view the contents of that directory.
4. Double-click Template to view the contents of that directory.
CAUTION:
The Base.Template.Style supplied by SAS contains inheritance information
used by many styles. If this inheritance information is not retained, some
style elements might not appear in the output. To safely create your own
Base.Template.Style, you can start with the existing Base.Template.Style
template by writing it to an external file and editing the existing template
contents.
464
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
If the PARENT= statement is specified, then PARENT= must refer to a
style other than Base.Template.Style.
Interaction
The Base.Template.Style master template attributes are overridden by
other style templates.
Tip
To view an existing style to base your own Base.Template.Style on, see
“Viewing the Contents of a Style” on page 444.
Optional Argument
STORE=libref.template-store
specifies the template store in which to store the style. If the template store does not
exist, then it is created.
Restriction
The syntax of the STORE= option does not become part of the
compiled template.
CLASS Statement
Creates a style element from a like-named style element.
Restriction:
Example:
The CLASS statement must be used within a DEFINE STYLE template block.
The following statements are equivalent:
class fonts;
style fonts from fonts;
style fonts from _self_;
Examples:
“Example 3: Modifying the Default Style with the CLASS Statement” on page 537
“Example 6: Importing a CSS File” on page 556
Syntax
CLASS style-element-name(s) <"text"> </ style-attribute-specification(s)>;
Required Argument
style–element-name
specifies one or more style elements to be duplicated and modified.
Tip
If there are multiple style element names specified within a style and an
attribute is specified more than once, then the value of the last attribute
specified is used.
See
For a complete description of style–element-name, see “style-element-name”
on page 470in the STYLE statement.
For a list of style elements, see Chapter 21, “Style Elements,” on page 831.
EDIT Statement 465
Optional Arguments
style-attribute-specification(s)
specifies new style attributes or modifications to existing style attributes for the new
style element. Each style-attribute-specification has this general form:
style-attribute-name=< | >style-attribute-value
style-attribute-name
is the name of an attribute that is listed in “Style Attributes Tables ” on page 473,
or it is the name of a user-defined style attribute.
Tip
If style-attribute-name refers to a user-defined attribute, then enclose the
name in quotation marks. If style-attribute-name refers to an attribute that is
listed in “Style Attributes Tables ” on page 473, then do not enclose the
name in quotation marks.
style-attribute-value
assigns the value to the attribute. If an attribute from the table in “Style Attributes
Tables ” on page 473 is specified, then specify the type of value that the attribute
expects.
For more information about style-attribute values, see “Style Attribute Values”
on page 517.
|
prevents the style attribute from being inherited by any child style elements.
Restriction
If there are multiple style element names specified within a style and an
attribute is specified more than once, then the value of the last attribute
specified is used.
Tips
Override any attribute of the parent style element, whether it is
inherited or explicitly defined, by specifying it in the STYLE statement
without the FROM option.
If an attribute is defined in a like-named style element in the parent
style and it is not explicitly specified in the STYLE statement of the
new like-named style element, then the attribute is not inherited, unless
you specify the FROM option.
"text"
provides information about the STYLE statement. Text of this type becomes part of
the compiled template, which you can view with the SOURCE statement, whereas
SAS comments do not become part of the compiled style.
EDIT Statement
Edits an existing template. The EDIT statement replaces the DEFINE statement in a template block when
editing. You can use the EDIT statement in place of any DEFINE statement.
Restriction:
Requirement:
Interaction:
If you edit a template that is a link, the link is broken and a separate template is
created.
An END statement must follow the EDIT statement and all of the editing instructions.
In some cases, you can use an EDIT statement inside a set of editing instructions.
When you edit a table template, you can also edit one or more column, header, or
466
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
footer templates that are defined in the table. When you edit a column template, you
can also edit one or more header templates that are defined for that column.
Example:
“Example 1: Editing a Table Template That a SAS Procedure Uses” on page 613
Syntax
EDIT template-path-1 <AS template-path-2 > </ STORE=libref.template-store>;
template-statements;
END;
Required Argument
template-path-1
specifies a template to edit. template-path-1 consists of one or more names that are
separated by periods. Each name represents a directory in a template store, which is a
type of SAS file.
Interaction
The STORE= option specifies a particular template store to read from
and write to.
Tip
To determine the templates that a procedure or DATA step uses, submit
the ODS TRACE ON statement before you run the SAS program. (See
“ODS TRACE Statement” on page 68.)
Optional Arguments
AS template-path-2
specifies the location in which to store the edited template, where template-path-2
consists of one or more names that are separated by periods. Each name represents a
directory in a template store, which is a type of SAS file. By default, PROC
TEMPLATE writes the edited template to the first writable template store in the
current path.
Default
If you omit AS template-path-2, PROC TEMPLATE writes the edited
template to template-path-1 in the first writable template store.
Restriction
If the current EDIT statement is inside a set of editing instructions, do
not use the AS template-path-2 option.
STORE=libref.template-store
specifies the template store from which to read template-path-1 and in which to store
template-path-2.
template-statements
template-statements are any statements or attributes that are valid between the
DEFINE statement and the END statement.
Editing an Existing Template
When you use the EDIT statement, the following occurs:
•
By default, PROC TEMPLATE looks for template-path-1 in the list of template
stores that is defined by the PATH statement. (See “PATH Statement” on page 359.)
It opens a copy of the first template path that it finds in a template store that has
Read access.
IMPORT Statement
•
467
PROC TEMPLATE writes the modified template to the first template store in the
current path with Update access. If you omit a second template path to write to, then
PROC TEMPLATE uses template-path-1. Therefore, if the template store from
which template-path-1 is read has Update access, you are actually modifying the
original template. Otherwise, the modified file is written to a template store to which
you do have Update access.
If you do specify a second template path, then PROC TEMPLATE writes the edited
template to the specified path in the first template store to which you have Write
access.
END Statement
Ends the style.
Requirement:
An END statement must be the last statement in the template.
Syntax
END;
IMPORT Statement
Imports Cascading Style Sheet (CSS) information from a file into the style.
Restriction:
Requirement:
Example:
The IMPORT statement must be used within a DEFINE STYLE template block.
CSS files must be written in the same type of CSS that the ODS HTML statement
produces. Only class names that match ODS style element names are supported,
with no IDs and no context-based selectors. To view the CSS code that ODS
creates, you can specify the STYLESHEET= option, or you can view the source of
an HTML file and look at the code between the tags at the top of the file.
“Example 6: Importing a CSS File” on page 556
Syntax
IMPORT file-specification <media-type-1 <, media-type-2 …>>
Required Argument
file-specification
specifies a file, fileref, or URL that contains CSS code. After you import the CSS
code, it is converted to style attributes and style elements that can be used with
PROC TEMPLATE.
file-specification is one of the following:
"external-file"
is the name of the external CSS file.
Requirement
You must enclose external-file in quotation marks.
468
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
fileref
is a file reference that has been assigned to an external CSS file. Use the
FILENAME statement to assign a fileref.
See
For information about the FILENAME statement, see SAS Statements:
Reference.
"URL"
is a URL to an external CSS file.
Requirement
You must enclose external-file in quotation marks.
Optional Argument
media-type
specifies one or more media blocks that correspond to the type of media on which
your output will be rendered. CSS uses media type blocks to specify how a document
is to be presented on different media (for example, on the screen, on paper, with a
speech synthesizer, or with a braille device).
The media block is added to your output in addition to the CSS code that is not
contained in any media blocks. By using the media-type option, in addition to the
general CSS code, you can import the section of a CSS file intended only for a
specific media type.
Default
If no media-type is specified in your ODS statement, but you have
specified media types in your CSS file, then ODS uses the Screen
media type.
Range
You can specify up to ten different media types.
Requirement
You must separate multiple media-types with commas.
Tip
If you specify multiple media types, all of the style information in all
of the media types is applied to your output. However, if there is
duplicate style information in different media blocks, then the styles
from the last media block are used.
NOTES Statement
Provides information about the style.
Restriction:
Tip:
The NOTES statement must be used within a DEFINE STYLE template block.
The NOTES statement becomes part of the compiled style template, which you can
view with the SOURCE statement, whereas SAS comments do not.
Syntax
NOTES "text";
Required Argument
"text"
provides information about the style.
PARENT= Statement 469
PARENT= Statement
Specifies the style from which the current style inherits.
Restriction:
Examples:
The PARENT= statement must be used within a DEFINE STYLE template block.
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
“Creating a Cover Page with the LAYOUT_ABSOLUTE Method” in SAS Output
Delivery System: Advanced Topics
“Example 1: Adding Text to Multiple Destinations ” on page 61
“Example 5: Setting the Style Element for a Specific Column, Row, and Cell” on page
637
“Example 7: Table Header and Footer Border Formatting” on page 647
Syntax
PARENT=style-path;
Required Argument
style-path
specifies the style to inherit from.
style-path consists of one or more names, separated by periods. Each name
represents a directory in a template store. The current style inherits from the
specified style in the first readable template store in the current path.
When you specify a parent, all of the style elements, style attributes, and statements
that are specified in the parent's style template are used in the current style template
unless the current style template overrides them.
SAS provides some styles. You can specify one of these styles for style-path, or you
can specify a user-defined style. These are some of the styles that are currently
shipped with SAS:
•
Styles.Default
•
Styles.Journal
•
Styles.Grayscaleprinter
•
Styles.Statistical
•
Styles.Minimal
•
Styles.Pearl
•
Styles.Statdoc
For information about finding an up-to-date list of the styles and for viewing a style,
see “Viewing the Contents of a Style” on page 444.
Restriction
If the PARENT= statement is specified, then PARENT= must refer to a
style other than Base.Template.Style.
470
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
REPLACE Statement
The REPLACE statement is no longer supported. Use the STYLE statement or the CLASS statement to
create and modify style elements.
STYLE Statement
Creates or modifies one or more style elements.
Restriction:
Example:
The STYLE statement must be used within a DEFINE STYLE template block.
“Example 1: Creating a Stand-Alone Style” on page 521
Syntax
STYLE style-element-name(s)
<FROM existing-style-element-name | _SELF_ ><"text">
</ style-attribute-specification(s)>;
Required Argument
style-element-name
specifies one or more style elements to be created or modified. If style-element-name
is a new style element, then PROC TEMPLATE stores the style element in the
current style. If style-element-name overrides a style element that is a parent of
another element, then all of the descendents of style-element-name, including those
inherited from parent styles, also inherit the new attributes.
Style element inheritance follows these general guidelines:
•
If a like-named style element already exists in the child style and it is not created
by using the FROM option, then the style element in the child style overrides the
style element of the same name in the parent style.
•
If a like-named style element already exists in the child style and it is created by
using the FROM option, then the style attributes from the parent style element
are absorbed into the style element in the child style.
•
If an attribute is defined in a like-named style element in the parent style and it is
not explicitly specified in the STYLE statement of the new like-named style
element, then the attribute is not inherited, unless you specify the FROM option.
•
If there are multiple identical style element names specified within a style and an
attribute is specified more than once, then the value of the last attribute specified
is used.
Requirement
Style elements must be separated by commas.
See
Chapter 21, “Style Elements,” on page 831 for a list of style
elements
Example
The following STYLE statement uses a style element list:
style data, data1, dataempty from _self_ /
color = red
STYLE Statement
471
backgroundcolor = black;
That statement is equivalent to specifying the following STYLE
statements together:
style data from data /
color = red
backgroundcolor = black;
style data1 from data1/
color = red
backgroundcolor = black;
style dataempty from dataempty /
color = red
backgroundcolor = black
Example
“Example 5: Defining Multiple Style Elements in One STYLE
Statement” on page 551
Optional Arguments
FROM existing-style-element-name | _SELF_
specifies that the preceding style-element-name inherit the style attributes from the
existing-style-element-name.
existing-style-element-name
specifies the existing style element that another style element inherits from.
existing-style-element-name can have the same name as the preceding styleelement-name, or it can be the name of another style element. The style element
must exist in the current style or in the parent of the current style. Style
inheritance using the FROM option follows these general guidelines:
•
If a like-named style element already exists in the child style and it is not
created by using the FROM option, then the style element in the child style
overrides the style element of the same name in the parent style.
•
If a like-named style element already exists in the child style and it is created
by using the FROM option, then the style attributes from the parent style
element are absorbed into the style element in the child style.
•
If an attribute is defined in a like-named style element in the parent style and
it is not explicitly specified in the STYLE statement of the new like-named
style element, then the attribute is not inherited, unless you specify the
FROM option.
•
PROC TEMPLATE looks first in the current style for the style element. If
PROC TEMPLATE does not find the style element, then it looks in the parent
style.
Example
The following statement specifies that the style element Data1 be
created from the style element Data2, and that the COLOR=BLACK
style attribute be added.
style data1 from data2 / color=black;
_SELF_
specifies that the parent of the style element should have the same name as the
new style element.
Tip
The _SELF_ option is most useful when specifying multiple style
elements.
472
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
See
Chapter 21, “Style Elements,” on page 831 for a list of style elements
Example
The following STYLE statement uses the FROM _SELF_ option:
style data, data1, dataempty from _self_ /
color = red backgroundcolor = black;
That statement is equivalent to specifying the following STYLE
statements together:
style data from data /
color = red
backgroundcolor = black;
style data1 from data1 /
color = red
backgroundcolor = black;
style dataempty from dataempty /
color = red
backgroundcolor = black
style-attribute-specification(s)
specifies new style attributes or modifications to existing style attributes for the new
style element. Each style-attribute-specification has this general form:
style-attribute-name=< | >style-attribute-value
style-attribute-name
is the name of an attribute that is listed in “Style Attributes Tables ” on page 473,
or it is the name of a user-defined style attribute.
Tip
If style-attribute-name refers to a user-defined attribute, then enclose the
name in quotation marks. If style-attribute-name refers to an attribute that is
listed in “Style Attributes Tables ” on page 473, then do not enclose the
name in quotation marks.
style-attribute-value
assigns the value to the attribute. If an attribute from the table in “Style Attributes
Tables ” on page 473 is specified, then specify the type of value that the attribute
expects.
For more information about style-attribute values, see “Style Attribute Values”
on page 517.
|
prevents the style attribute from being inherited by any child style elements.
Restriction
If there are multiple style element names specified within a style and an
attribute is specified more than once, then the value of the last attribute
specified is used.
Tips
Override any attribute of the parent style element, whether it is
inherited or explicitly defined, by specifying it in the STYLE statement
without the FROM option.
If an attribute is defined in a like-named style element in the parent
style and it is not explicitly specified in the STYLE statement of the
Style Attributes Tables
473
new like-named style element, then the attribute is not inherited, unless
you specify the FROM option.
"text"
provides information about the STYLE statement. Text of this type becomes part of
the compiled template, which you can view with the SOURCE statement, whereas
SAS comments do not become part of the compiled style.
Style Attributes Overview
Style attributes influence the characteristics of individual cells, tables, documents,
graphs, and HTML frames. Style attributes exist within style elements and are specified
by the STYLE statement on page 470 or the CLASS statement on page 464. The default
value for an attribute depends on the style that is in use. For information about styles,
style elements, and style attributes, see “Understanding Styles, Style Elements, and Style
Attributes” on page 448. For information about using style attributes with ODS
Statistical Graphics, see the chapter on controlling the appearance of your graphics in
SAS Graph Template Language: User's Guide.
Style attributes can be supplied by SAS or user-defined. Style attributes can be
referenced with a style reference. See “Understanding Style References ” on page 455
and “style-reference” on page 521 for more information.
The implementation of an attribute depends on the ODS destination that formats the
output. When creating HTML output, the implementation of an attribute depends on the
browser that is used. For information about viewing the attributes in a style, see
“Viewing the Contents of a Style” on page 444.
For a list of the values that style attributes can specify, see “Style Attribute Values” on
page 517. For a list of style elements that you can specify style attributes in, see Chapter
21, “Style Elements,” on page 831.
See Also
•
For a table of style elements that can be used with style attributes, see Chapter 21,
“Style Elements,” on page 831.
•
For more information about using style attributes and style elements together, see
“Understanding Style References ” on page 455.
•
For information about style attribute values, see “Style Attribute Values” on page
517.
Style Attributes Tables
For detailed information about these style attributes and their aliases, see “Detailed
Information for All Style Attributes” on page 484.
474
Chapter 15
Table 15.3
•
TEMPLATE Procedure: Creating a Style Template
Table of General Style Attributes
Attribute
Task
Destinations
Affected Items
“ABSTRACT=ON | OFF” (p. 484)
Specify whether styles
used in an HTML
document are used in CSS
style files
Markup family
HTML
documents
“ACTIVELINKCOLOR=color” (p. 484)
Specify the color that a link
in an HTML document
changes to after you click
it, but before the browser
opens that file
Markup family
HTML
documents
“ASIS=ON | OFF” (p. 484)
Specify how to handle
leading spaces and line
breaks in an HTML
document
Markup family,
printer family, and
RTF
Table cells and
HTML
documents
“BACKGROUNDCOLOR=color” (p. 485)
Specify the color of the
background of tables, table
cells, or graphs
Markup family,
printer family, and
RTF
Table cells,
tables, graphs
“BACKGROUNDIMAGE="string"” (p. 485)
Specify an image to use as
the background
Markup family,
PCL, PS, and
TAGSETS.RTF.
Table cells,
tables, graphs.
For
TAGSETS.RTF,
only applies to
the document.
“BACKGROUNDPOSITION=position”
(p. 485)
Specify the position of the
background of the tables,
table cells, or graphs
Markup family,
printer family, and
RTF
Tables, graphs,
and HTML
documents
“BACKGROUNDREPEAT=option” (p. 486)
Specify whether an image
is repeated horizontally,
vertically, both, or not
repeated
Markup family
Individual tables
or table cells,
graphs
“BODYSCROLLBAR=YES | NO | AUTO”
(p. 486)
Specify whether to put a
scroll bar in the frame that
references the body file
Markup family
Individual frames
in HTML output
“BODYSIZE=dimension | dimension% | * ”
(p. 487)
Specify the width of the
frame that displays the
body file in the HTML
frame file
Markup family
Individual frames
in HTML output
“BORDERBOTTOMCOLOR=color ” (p. 487)
Specify the color of the
bottom border of the table
Markup family,
printer family, RTF,
and Measured RTF
Bottom border of
a table or table
cell
“BORDERBOTTOMSTYLE=line-style”
(p. 487)
Specify the line style of the
bottom border of the
selected cell
Markup family,
RTF, and Measured
RTF
Bottom border of
a table or table
cell
Style Attributes Tables
475
Attribute
Task
Destinations
Affected Items
“BORDERBOTTOMWIDTH=dimension ”
(p. 488)
Specify the width of the
bottom border of the table
Markup family,
printer family, RTF,
and Measured RTF
Bottom border of
a table or table
cell
“BORDERCOLLAPSE=COLLAPSE |
SEPARATE” (p. 488)
Specify whether the border
is collapsed or separated
Markup family,
printer family, RTF,
and Measured RTF
Tables
“BORDERCOLOR=color” (p. 488)
Specify the color of the
border in a table or table
cell if the border is just one
color
Markup family,
printer family, RTF,
and Measured RTF
Individual tables
or table cells
“BORDERCOLORDARK=color” (p. 488)
Specify the darker color to
use in a border that uses
two colors to create a
three-dimensional effect
Markup family and
printer family
Individual tables
or table cells
“BORDERCOLORLIGHT=color” (p. 488)
Specify the lighter color to
use in a border that uses
two colors to create a
three-dimensional effect
Markup family and
printer family
Individual tables
or table cells
“BORDERLEFTCOLOR=color” (p. 489)
Specify the color of the left
border of a table
Markup family,
printer family, RTF,
and Measured RTF
Left border of a
table or table cell
“BORDERLEFTSTYLE=line-style” (p. 489)
Specify the line style of the
left border of the specified
table cell
Markup family,
RTF, and Measured
RTF
Left border of the
specified table
cell
“BORDERLEFTWIDTH=dimension” (p. 489)
Specify the width of the
left border of the table
Markup family,
printer family, RTF,
and Measured RTF
Left border of a
table or table cell
“BORDERRIGHTCOLOR=color ” (p. 489)
Specify the color of the
right border of the table
Markup family,
printer family, RTF,
and Measured RTF
Right border of a
table or table cell
“BORDERRIGHTSTYLE=line-style” (p. 490)
Specify the line style of the
right border of the selected
cell
Markup family,
RTF, and Measured
RTF
Right border of
the selected cell
“BORDERRIGHTWIDTH=dimension ”
(p. 490)
Specify the width of the
right border of the table
Markup family,
printer family, RTF,
and Measured RTF
Right border of a
table
“BORDERSPACING=dimension” (p. 490)
Specify the thickness of the
spacing between cells in a
table
Markup family,
RTF, and printer
family
Tables
“BORDERTOPCOLOR=color” (p. 491)
Specify the color of the top
border of the table
Markup family,
printer family, RTF,
and Measured RTF
Top border of a
table or table cell
476
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Attribute
Task
Destinations
Affected Items
“BORDERTOPSTYLE=line-style” (p. 491)
Specify the line style of the
top border of the specified
table cell
Markup family,
RTF, and Measured
RTF
Top border of the
specified table
cell
“BORDERTOPWIDTH=dimension” (p. 491)
Specify the width of the
top border of the table
Markup family,
printer family, RTF,
and Measured RTF
Top border of a
table
“BORDERWIDTH=dimension” (p. 492)
Specify the width of the
border of the table
Markup family,
RTF, and printer
family
Individual tables
or table cells
“CELLPADDING=dimension | dimension%”
(p. 492)
Specify the amount of
white space on each of the
four sides of the content in
a table cell
Markup family,
RTF, and printer
family
Tables
“CLASS="string"” (p. 493)
Specify the name of the
style sheet class to use in
an HTML document for the
table or table cell
Markup family
Individual tables
or table cells
“COLOR=color” (p. 493)
Specify the color of the
foreground in tables, table
cells, or graphs, which is
primarily the color of text
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“CONTENTPOSITION=position” (p. 493)
Specify the position, within
the frame file, of the
frames that display the
contents and the page files
Markup family
Individual frames
in HTML output
“CONTENTSCROLLBAR=YES | NO |
AUTO” (p. 494)
Specify whether to put a
scroll bar in the frames in
the frame file that display
the contents and the page
files
Markup family
Individual frames
in HTML output
“CONTENTSIZE=dimension | dimension % |
*” (p. 494)
Specify the width of the
frames in the frame file
that display the contents
and the page files
Markup family
Individual frames
in HTML output
“CONTENTTYPE="string"” (p. 495)
Specify the value of the
content type for pages in an
HTML document that is
sent directly to a web
server rather than to a file
Markup family
Individual frames
in HTML output
“CONTRASTCOLOR=color” (p. 495)
Specify the alternate colors
for maps
Markup family,
RTF, and printer
family
Graphs
Style Attributes Tables
477
Attribute
Task
Destinations
Affected Items
“DOCTYPE="string"” (p. 497)
Specify the entire doctype
declaration for the HTML
document
Markup family
HTML
documents
“FILLRULEWIDTH=dimension” (p. 498)
Place a rule of the specified
width into the space around
the text (or entire cell if
there is no text) in a table
where white space would
otherwise appear
Printer family
HTML
documents
“FLYOVER="string"” (p. 498)
Specify the text to show in
a data tip for the table cell
Markup family and
PDF
Individual cells
“FONT=font-definition” (p. 498)
Specify a font definition to
use in tables, table cells,
and graphs
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FONTFAMILY="string-1<…, string-n>"”
(p. 499)
Specify the font to use in
table cells and graphs
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FONTSIZE=dimension | size” (p. 499)
Specify the size of the font
for tables, table cells, and
graphs
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FONTSTYLE=ITALIC | ROMAN | SLANT”
(p. 499)
Specify the style of the font
for tables, table cells, and
graphs
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FONTWEIGHT=weight” (p. 500)
Specify the font weight of
tables, table cells, and
graphs
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FONTWIDTH=relative-width” (p. 500)
Specify the font width of
tables, table cells, and
graphs compared to the
width of the usual design
of the table, table cell, or
graph
Markup family,
RTF, and printer
family
Individual tables
or table cells,
graphs
“FRAME=frame-type” (p. 501)
Specify the type of frame
to use on a table
Markup family,
RTF, and printer
family
Tables
“FRAMEBORDER=ON | OFF” (p. 501)
Specify whether to put a
border around the frame for
an HTML file that uses
frames
Markup family
Individual frames
in HTML output
“FRAMEBORDERWIDTH=dimension”
(p. 502)
Specify the width of the
border around the frames
for an HTML file that uses
frames
Markup family
Individual frames
in HTML output
478
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Attribute
Task
Destinations
Affected Items
“FRAMESPACING=dimension” (p. 502)
Specify the width of the
space between frames for
HTML that uses frames
Markup family
Individual frames
in HTML output
“HEIGHT=dimension ” (p. 502)
Specify the height of a
table cell, graph, or
graphics in an HTML
document 1
Markup family,
RTF, and printer
family
Table cells,
HTML
documents, and
graphs
“HREFTARGET="target" ” (p. 502)
Specify the window or
frame in which to open the
target of the link
Markup family
Individual cells
“HTMLID="string"” (p. 503)
Specify an ID for the table
or table cell
Markup family
Individual tables
or table cells
“HTMLSTYLE="string"” (p. 503)
Specify individual
attributes and values for a
table or table cell in an
HTML document
Markup family
Individual tables
or table cells
“IMAGE="string"” (p. 504)
Specify the image to
appear in a graph
Markup family,
printer family, and
RTF
Graphs
“LINKCOLOR=color” (p. 504)
Specify the color for the
links in an HTML
document that have not yet
been visited
Markup family,
printer family, and
RTF
HTML
documents
“LISTENTRYANCHOR=ON | OFF ” (p. 505)
Specify whether to make
the entry in the table of
contents a link to the body
file
Markup family
HTML
documents
“LISTSTYLETYPE=bullet-type” (p. 505)
Specify the string to use for
the bullets in the contents
file
Markup family
Individual frames
in HTML output
“MARGINBOTTOM=dimension” (p. 506)
Specify the bottom margin
for the HTML document
Markup family,
printer family, and
RTF
HTML
documents
“MARGINLEFT=dimension” (p. 506)
Specify the left margin for
the HTML document
Markup family,
printer family, and
RTF
HTML
documents
“MARGINRIGHT=dimension” (p. 506)
Specify the right margin
for the HTML document
Markup family,
printer family, and
RTF
HTML
documents
“MARGINTOP=dimension” (p. 506)
Specify the top margin for
the HTML document
Markup family,
printer family, and
RTF
HTML
documents
Style Attributes Tables
479
Attribute
Task
Destinations
Affected Items
“NOBREAKSPACE=ON | OFF ” (p. 507)
Specify how to handle
space characters
Markup family,
printer family, and
RTF
Individual cells
“OVERHANGFACTOR=nonnegative-number”
(p. 508)
Specify an upper limit for
extending the width of the
column in an HTML
document
Markup family and
printer family
HTML
documents
“PADDING=dimension | dimension%”
(p. 508)
Specify the amount of
white space between the
content of the table cell and
the border
Markup family,
RTF, and printer
family
Table cells
“PADDINGBOTTOM=dimension | dimension
%” (p. 508)
Specify the amount of
white space on the bottom
of the content of the table
cell
Markup family,
RTF, and printer
family
Table cells
“PADDINGLEFT=dimension | dimension%”
(p. 508)
Specify the amount of
white space on the left side
of the content of the table
cell
Markup family,
RTF, and printer
family
Table cells
“PADDINGRIGHT=dimension | dimension%”
(p. 509)
Specify the amount of
white space on the right
side of the content of the
table cell
Markup family,
RTF, and printer
family
Table cells
“PADDINGTOP=dimension | dimension%”
(p. 509)
Specify the amount of
white space on the top of
the content of the table cell
Markup family,
RTF, and printer
family
Table cells
“PAGEBREAKHTML="string"” (p. 509)
Specify HTML to place at
page breaks in an HTML
document
Markup family
HTML
documents
“POSTHTML="string"” (p. 509)
Specify the HTML code to
place after the table or
table cell
Markup family
Individual tables
or table cells
“POSTIMAGE="string" | fileref” (p. 509)
Specify an image to place
before the table or table
cell
Markup family
Individual tables
or table cells
“POSTTEXT="string"” (p. 510)
Specify text to place after
the table cell or table
Markup family,
printer family, and
RTF
Individual tables
or table cells
“PREHTML="string"” (p. 510)
Specify the HTML code to
place before the table or
table cell
Markup family
Individual tables
or table cells
480
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Attribute
Task
Destinations
Affected Items
“PREIMAGE="string" | fileref” (p. 510)
Specify an image to place
before the table or table
cell
Markup family,
printer family, and
RTF
Individual tables
or table cells
“PRETEXT="string"” (p. 510)
Specify text to place before
the table cell or table
Markup family,
printer family, and
RTF
Individual tables
or table cells
“PROTECTSPECIALCHARS=ON | OFF |
AUTO” (p. 511)
Specify how less-than
signs (<), greater-than
signs (>), and ampersands
(&) are interpreted in table
cells
Markup family,
printer family, and
RTF
Individual tables
or table cells
“RULES=rule-type” (p. 511)
Specify the types of rules
to use in tables
Markup family,
printer family, and
RTF
Tables
“STARTCOLOR=color” (p. 512)
Specify the start fill color
for a graph
HTML
Graphs
“TAGATTR="string"” (p. 512)
Specify text to insert in the
HTML
Markup family
Individual cells
“TEXTALIGN=alignment” (p. 512)
Specify justification in
tables, table cells, and
graphs
Printer family and
RTF
Individual tables
or table cells,
graphs
“TEXTDECORATION=presentation–options”
(p. 513)
Change the visual
presentation of the text
Markup family,
RTF, and printer
family
Individual tables
or table cells
“TEXTINDENT=n” (p. 514)
Specify the number of
spaces that the first line of
output is indented
Markup family,
RTF, and printer
family
Individual tables
or table cells
“TEXTJUSTIFY=INTER_WORD |
INTER_CHARACTER” (p. 514)
Specify if the words of the
text are to be spaced evenly
or if the characters are to
be evenly justified
HTML, RTF, and
TAGSETS.RTF
Titles, footnotes,
and text
“TRANSPARENCY=dimension” (p. 514)
Specify a transparency
level for graphs
HTML
Graphs
“URL="uniform-resource-locator"” (p. 514)
Specify a URL to link to
Markup family,
RTF, and printer
family
Individual cells
“VERTICALALIGN=BOTTOM | MIDDLE |
TOP ” (p. 515)
Specify vertical
justification
Markup family,
printer family, and
RTF
Individual cells
and graphs
Style Attributes Tables
481
Attribute
Task
Destinations
Affected Items
“VISITEDLINKCOLOR=color” (p. 515)
Specify the color for links
that have been visited in an
HTML document
Markup family
HTML
documents
“WATERMARK=ON | OFF” (p. 515)
Specify whether to make
the image that is specified
by
BACKGROUNDIMAGE=
into a "watermark "
Markup family
HTML
documents
“WHITESPACE=options” (p. 516)
Specify how the browser
handles multiple
whitespace characters and
line breaks.
Markup family,
printer family, RTF,
and Measured RTF
Lines of text
“WIDTH=dimension ” (p. 516)
Specify the width of a table
cell, table, line, or a graph
Markup family,
printer family, and
RTF
Tables
1
This attribute can also be used to influence other characteristics as described in another
section of the table
Note: You can use the value _UNDEF_ for any style attribute. ODS treats an attribute
that is set to _UNDEF_ as if its value had never been set, even in the parent or
beyond.
Graphical style attributes can be used in graphical style elements for device-based
graphics or template-based graphics (ODS graphics). Different style attributes are valid
for different style elements. For a table of style elements and the style attributes that are
valid in each one, see “Style Elements Affecting Template-Based Graphics” on page
841 and “Style Elements Affecting Device-Based Graphics” on page 849.
Device-based graphics are all SAS/GRAPH output where there is a user-specified or
default device (DEVICE= option) that controls certain aspects of the graphical output.
Supplied device drivers are stored in the Sashelp.Devices catalog. Examples of device
drivers are SASPRTC, GIF, WIN, ACTIVEX, PDF, and SVG. Common SAS/GRAPH
procedures that produce device-based graphics are GPLOT, GCHART, and GMAP. Most
device-based graphics produce a GRSEG catalog entry as output and use the
GOPTIONS statement to control the graphical environment.
Template-based graphics include all SAS/GRAPH output where a compiled ODS
template of type STATGRAPH is used to produce graphical output. Supplied templates
are stored in Sashelp.Tmplmst. Device drivers and some global statements such as
SYMBOL, PATTERN, AXIS, and LEGEND have no affect on this form of graphics.
Common SAS/GRAPH procedures that produce template-based graphics are SGPLOT,
SGPANEL, and SGRENDER, in addition to many SAS/STAT, SAS/ETS, and SAS/QC
procedures. ODS graphics always produce output as image files and use the ODS
GRAPHICS statement to control the graphical environment.
482
Chapter 15
Table 15.4
•
TEMPLATE Procedure: Creating a Style Template
Table of Graphical Style Attributes
Attribute
Task
Graphics
Environment
“BACKGROUNDIMAGE="string"”
(p. 485)
Specify an image file path
Device-based graphics
Image that can be
stretched, but not
positioned in
graph, chart,
walls, floor
“CAPSTYLE=line-shape” (p. 492)
Specify the shape of the
line at the end of a box
whisker graph
Template-based graphics
Shape of line at
end of box
whisker
“COLOR=color” (p. 493)
Specify the color of the
foreground in tables, table
cells, or graphs, which is
primarily the color of text
All graphics
environments
Background color
of the graph,
walls, or floor;
color of text
“CONNECT=connect-line-type” (p. 493)
Specify characteristics of a
box plot connect line
Template-based graphics
Box plot connect
line
“CONTRASTCOLOR=color” (p. 495)
Specify the color a line or
marker
Template-based graphics
Color of line or
marker
“DATASKIN=CRISP | GLOSS | MATTE |
NONE | PRESSED | SHEEN” (p. 495)
Specify the type of skin to
apply to plots and charts
other than KPIs to give
them a raised appearance
Template-based graphics
Graph
background,
legend
background,
charts, walls,
floors
“DISPLAYOPTS="display-feature"”
(p. 496)
Specify display features
for graphs
Template-based graphics
Displayed
features of box
plots, ellipses,
histograms, bands
“DROPSHADOW=ON | OFF ” (p. 497)
Specify whether the drop
shadow color for text is
displayed
Device-based graphics
Drop shadow
color for text
“ENDCOLOR=color ” (p. 497)
Specify the final color used
with a two- or three-color
ramp
All graphics
environments
Contours,
gradient legends
“FILLPATTERN=fillpattern-value”
(p. 497)
Specify the fill pattern to
be displayed on a chart
Template-based graphics
“FONT=font-definition” (p. 498)
Specify a font definition to
use in tables, table cells,
and graphs
All graphics
environments
All text font
attributes
“FONTFAMILY="string-1<…, stringn>"” (p. 499)
Specify the font to use in
table cells and graphs
All graphics
environments
Font family
Affected Items
Style Attributes Tables
Graphics
Environment
483
Attribute
Task
Affected Items
“FONTSIZE=dimension | size” (p. 499)
Specify the size of the font
for tables, table cells, and
graphs
All graphics
environments
Font size
“FONTSTYLE=ITALIC | ROMAN |
SLANT” (p. 499)
Specify the style of the
font for tables, table cells,
and graphs
All graphics
environments
Font style
“FONTSTYLE=ITALIC | ROMAN |
SLANT” (p. 499)
Specify the font weight of
tables, table cells, and
graphs
All graphics
environments
Font weight
“FRAMEBORDER=ON | OFF” (p. 501)
Specify whether there is a
graph wall border
All graphics
environments
Graph wall
border
“GRADIENT_DIRECTION="YAXIS" |
"XAXIS "” (p. 502)
Specify the direction of the
gradient
Device-based graphics
Graph
background,
legend
background,
charts, walls,
floors
“IMAGE="string"” (p. 504)
Specify the path to an
image
Device-based graphics
Image that can be
positioned, but
not stretched in
graph, chart,
walls, floor
“KPISKIN=BASIC | MODERN | NONE |
ONYX | SATIN” (p. 504)
Specify the type of skin to
apply to KPI charts to give
them a raised, 3-D
appearance
Template-based graphics
Graph
background,
legend
background,
charts, walls,
floors
“LINESTYLE=pattern-number” (p. 504)
Specify the pattern of a
line
All graphics
environments
Borders, axis
lines, grid,
reference
“LINETHICKNESS=dimension” (p. 504)
Specify the thickness of a
line
All graphics
environments
Thickness of line
“MARKERSIZE=dimension” (p. 507)
Specify a marker size
All graphics
environments
Marker size
“MARKERSYMBOL=marker-symbol”
(p. 507)
Specify a marker symbol
All graphics
environments
Marker used
“NEUTRALCOLOR=color” (p. 507)
Specify the middle color of
a three-color ramp
Template-based graphics
Contours,
gradient legends
“OUTPUTHEIGHT=dimension” (p. 507)
Specify the height of a
graph
All graphics
environments
Height of graph
484
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Attribute
Task
Graphics
Environment
“OUTPUTWIDTH=dimension” (p. 508)
Specify the width of a
graph
All graphics
environments
Width of graph
“STARTCOLOR=color” (p. 512)
Specify the start fill color
for a graph
All graphics
environments
Contours,
gradient legends
“TEXTALIGN=alignment” (p. 512)
Specify the alignment of
an image
Device-based graphics
Image horizontal
positioning
“TICKDISPLAY="INSIDE" |
"OUTSIDE" | "ACROSS" ” (p. 514)
Specify the placement of
all major and minor axis
tick marks
Template-based graphics
Placement of all
major and minor
axis tick marks
“TRANSPARENCY=dimension” (p. 514)
Specify the transparency of
backgrounds, fills, lines,
and markers
All graphics
environments
Backgrounds,
fills, lines,
markers
“VERTICALALIGN=BOTTOM |
MIDDLE | TOP ” (p. 515)
Specify vertical
justification
Device-based graphics
Image vertical
positioning
Affected Items
Detailed Information for All Style Attributes
ABSTRACT=ON | OFF
specifies whether styles used in an HTML document are used in CSS style files.
ON
specifies that styles are used in CSS style files.
OFF
specifies that styles are not used in CSS style files.
Restriction
The ABSTRACT= attribute is valid only in markup family
destinations.
ACTIVELINKCOLOR=color
specifies the color that a link in an HTML document changes to after you click it, but
before the browser opens that file.
Restriction
The ACTIVELINKCOLOR= attribute is valid only in markup family
destinations.
See
color style attribute value on page 517
ASIS=ON | OFF
specifies how to handle leading spaces and line breaks in an HTML document.
ON
prints text with leading spaces and line breaks, in the same manner as the
LISTING output.
Detailed Information for All Style Attributes
485
OFF
trims leading spaces and ignores line breaks.
Default
OFF
Restriction
The ASIS= attribute is valid only in markup family destinations, printer
family destinations, and the RTF destination.
BACKGROUNDCOLOR=color
specifies the color of the background of the tables, table cells, or graphs.
Alias
BACKGROUND=
Restriction
The BACKGROUNDCOLOR= attribute is valid only in markup
family destinations, printer family destinations, and the RTF
destination.
Interaction
The CBACK= option in the SAS/GRAPH GOPTIONS statement
overrides the BACKGROUNDCOLOR= attribute.
Tip
Generally, the background color of the table cell overrides the
background color of the table. You see the background color for the
table only as the space between table cells (see
“BORDERSPACING=dimension” on page 490).
See
color style attribute value on page 517
Examples
“Example 1: Creating a Stand-Alone Style” on page 521
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
BACKGROUNDIMAGE="string"
specifies an image in a table, table cell, or graph to use as the background. Viewers
can tile or stretch the image as the background for the HTML table or graph that the
procedure creates. For graphs, the specified image is stretched.
string
is the name of a GIF, JPEG, or PNG file. Use a simple filename, a complete path,
or a URL. However, the most versatile approach is to use a simple filename and
to place all image files in the local directory.
Restriction
The BACKGROUNDIMAGE= attribute is valid in markup family
destinations, the PCL destination, and the PS destination. It is also
valid in the TAGSETS.RTF destination, but the background image
applies to the RTF document and not to a table or a table cell.
Interaction
The BACKGROUNDIMAGE= attribute is overridden by the IBACK=
and IMAGESTYLE=FIT options in the SAS/GRAPH GOPTIONS
statement.
See
string attribute value on page 521
BACKGROUNDPOSITION=position
specifies the position of the background of the tables, table cells, or graphs.
position can be one of the following:
•
BOTTOM
486
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
•
BOTTOM_CENTER
•
BOTTOM_LEFT
•
BOTTOM_RIGHT
•
CENTER
•
CENTER_BOTTOM
•
CENTER_CENTER
•
CENTER_LEFT
•
CENTER_RIGHT
•
CENTER_TOP
•
LEFT
•
LEFT_BOTTOM
•
LEFT_CENTER
•
LEFT_TOP
•
RIGHT
•
RIGHT_BOTTOM
•
RIGHT_CENTER
•
RIGHT_TOP
•
TOP
•
TOP_CENTER
•
TOP_LEFT
•
TOP_RIGHT
Default
TOP_LEFT
BACKGROUNDREPEAT=option
specifies whether an image is repeated horizontally, vertically, both, or not repeated.
option can be one of the following:
NO_REPEAT
specifies that the image is not repeated.
REPEAT
specifies that the image is repeated both horizontally and vertically.
REPEAT_X
specifies that the image is repeated horizontally.
REPEAT_Y
specifies that the image is repeated vertically.
Restriction
The BACKGROUNDREPEAT= attribute is valid in most markup
family destinations.
BODYSCROLLBAR=YES | NO | AUTO
specifies whether to put a scroll bar in the frame that references the body file.
YES
places a scroll bar in the frame that references the body file.
Detailed Information for All Style Attributes
487
NO
specifies not to put a scroll bar in the frame that references the body file.
AUTO
places a scroll bar in the frame that references the body file only if needed.
Restriction
The BODYSCROLLBAR= attribute is valid only in markup family
destinations.
Tip
Typically, BODYSCROLLBAR= is set to AUTO.
BODYSIZE=dimension | dimension% | *
specifies the width of the frame that displays the body file in the HTML frame file.
dimension
is a nonnegative number or the width of the frame specified as a percentage of
the entire display.
*
specifies to use whatever space is left after displaying the content and page files
as specified by the CONTENTSIZE= attribute.
Restriction
The BODYSIZE= attribute is valid only in markup family destinations.
Tip
If dimension is a nonnegative number, then the unit of measure is
pixels.
See
dimension attribute value on page 519
For information about the HTML files that ODS creates, see “HTML
Links and References Produced by the HTML Destination ” in SAS
Output Delivery System: User's Guide.
BORDERBOTTOMCOLOR=color
specifies the color of the bottom border of a table or table cell.
Restriction
The BORDERBOTTOMCOLOR= attribute is valid only in markup
family destinations, printer family destinations, RTF destination, and
the Measured RTF destination.
Tip
You might also need to specify a BORDERBOTTOMWIDTH=
attribute to override the style in the ODS destination.
See
color style attribute value on page 517
BORDERBOTTOMSTYLE=line-style
specifies the line style of the bottom border of the specified table cell.
line-style
can be one of the following:
•
DASHED
•
DOTTED
•
DOUBLE
•
GROOVE
•
HIDDEN
•
INSET
488
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
•
OUTSET
•
RIDGE
•
SOLID
Restriction
The BORDERBOTTOMSTYLE= attribute is valid only in markup
family destinations, the RTF destination, and the Measured RTF
destination.
Tip
You might also need to specify the BORDERBOTTOMWIDTH=
attribute to override the style in the ODS destination.
BORDERBOTTOMWIDTH=dimension
specifies the width of the bottom border of a table or table cell.
Restriction
The BORDERBOTTOMWIDTH= attribute is valid only in markup
family destinations, the RTF destination, printer family destinations,
and the Measured RTF destination.
See
dimension attribute value on page 519
BORDERCOLLAPSE=COLLAPSE | SEPARATE
specifies whether the border is collapsed or separated.
Default
SEPARATE
BORDERCOLOR=color
specifies the border color of a table or table cell. The color is applied to all four
borders.
Restriction
The BORDERCOLOR= attribute is valid only in markup family
destinations, the RTF destination, printer family destinations, and the
Measured RTF destination.
See
color style attribute value on page 517
BORDERCOLORDARK=color
in a table or table cell, specifies the darker color to use in a border that uses two
colors to create a three-dimensional effect.
Restriction
The BORDERCOLORDARK= attribute is valid only in markup family
destinations and printer family destinations.
Interaction
The BORDERCOLORDARK style attribute is ignored in HTML4
output because it is not part of the HTML4 standard. To create a color
border in the HTML4 output, use the BORDERCOLOR= style
attribute.
See
color style attribute value on page 517
Example
“Example 4: Defining a Table and Graph Style” on page 543
BORDERCOLORLIGHT=color
in a table or table cell, specifies the lighter color to use in a border that uses two
colors to create a three-dimensional effect.
Restriction
The BORDERCOLORLIGHT= attribute is valid only in markup
family destinations and printer family destinations.
Detailed Information for All Style Attributes
489
Interaction
The BORDERCOLORLIGHT style attribute is ignored in the creation
of HTML4 output because it is not part of the HTML4 standard. To
create a color border in HTML4 output, use the BORDERCOLOR=
style attribute.
See
color style attribute value on page 517
Example
“Example 4: Defining a Table and Graph Style” on page 543
BORDERLEFTCOLOR=color
specifies the color of the left border of the table.
Restriction
The BORDERLEFTCOLOR= attribute is valid only in markup family
destinations, the RTF destination, printer family destinations, and the
Measured RTF destination.
Tip
You might also need to specify the BORDERLEFTWIDTH= attribute
to override the style in the ODS destination.
See
color style attribute value on page 517
BORDERLEFTSTYLE=line-style
specifies the line style of the left border of the specified table cell.
line-style
can be one of the following:
•
DASHED
•
DOTTED
•
DOUBLE
•
GROOVE
•
HIDDEN
•
INSET
•
OUTSET
•
RIDGE
•
SOLID
Restriction
The BORDERLEFTSTYLE= attribute is valid only in markup family
destinations, the RTF destination, and the Measured RTF destination.
Tip
You might also need to specify the BORDERLEFTWIDTH= attribute
to override the style in the ODS destination.
BORDERLEFTWIDTH=dimension
specifies the width of the left border of a table or table cell.
Restriction
The BORDERLEFTWIDTH= attribute is valid only in markup family
destinations, the RTF destination, printer family destinations, and the
Measured RTF destination.
See
dimension attribute value on page 519
BORDERRIGHTCOLOR=color
specifies the color of the right border of a table or table cell.
490
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
The BORDERRIGHTCOLOR= attribute is valid only in markup
family destinations, the RTF destination, printer family destinations,
and the Measured RTF destination.
Tip
You might also need to specify the BORDERRIGHTWIDTH= attribute
to override the style in the ODS destination.
See
color style attribute value on page 517
BORDERRIGHTSTYLE=line-style
specifies the line style of the right border of the selected cell.
line-style
can be one of the following:
•
DASHED
•
DOTTED
•
DOUBLE
•
GROOVE
•
HIDDEN
•
INSET
•
OUTSET
•
RIDGE
•
SOLID
Restriction
The BORDERRIGHTSTYLE= attribute is valid only in markup family
destinations, the RTF destination, and the Measured RTF destination.
Tip
You might also need to specify the BORDERRIGHTWIDTH= attribute
to override the style in the ODS destination.
BORDERRIGHTWIDTH=dimension
specifies the width of the right border of the table.
Restriction
The BORDERRIGHTWIDTH= attribute is valid only in markup
family destinations, printer family destinations, RTF destination, and
the Measured RTF destination.
See
dimension attribute value on page 519
BORDERSPACING=dimension
specifies the vertical and horizontal thickness of the spacing between cells in a table.
Alias
CELLSPACING=
Default
0
Restriction
The BORDERSPACING= attribute is valid in markup family
destinations other than HTML5, printer family destinations, and the
RTF destination.
Interaction
If BORDERWIDTH= is nonzero, and if the background color of the
table cells contrasts with the background color of the table, then the
color of the table cell spacing is determined by the table's background.
Detailed Information for All Style Attributes
See
dimension attribute value on page 519
Examples
“Example 1: Creating a Stand-Alone Style” on page 521
491
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
BORDERTOPCOLOR=color
specifies the color of the top border of a table or table cell.
Restrictions
The BORDERTOPCOLOR= attribute is valid only in markup family
destinations, printer family destinations, RTF destination, and the
Measured RTF destination.
To ensure that the top border color is created, specify the
BORDERTOPWIDTH= attribute and the BORDERTOPCOLOR=
attribute for the RTF destination. For the RTF destination, specify the
BORDERTOPCOLOR= attribute in conjunction with the
BORDERTOPWIDTH= attribute to ensure that the top border color is
created.
Tip
You might also need to specify the BORDERTOPWIDTH= attribute
to override the style in the ODS destination.
See
color style attribute value on page 517
BORDERTOPSTYLE=line-style
specifies the line style of the top border of the specified table cell.
line-style
can be one of the following:
•
DASHED
•
DOTTED
•
DOUBLE
•
GROOVE
•
HIDDEN
•
INSET
•
OUTSET
•
RIDGE
•
SOLID
Restrictions
The BORDERTOPSTYLE= attribute is valid only in markup family
destinations, the RTF destination, and the Measured RTF destination.
For the RTF destination, specify the BORDERTOPSTYLE= attribute
in conjunction with the BORDERTOPWIDTH= attribute to ensure
that the style of the top border is the style that you specified.
Tip
You might also need to specify the BORDERTOPWIDTH= attribute
to override the style in the ODS destination.
BORDERTOPWIDTH=dimension
specifies the width of the top border of the table or table cell.
492
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
The BORDERTOPWIDTH= attribute is valid only in markup family
destinations, printer family destinations, RTF destination, and the
Measured RTF destination.
See
dimension attribute value on page 519
BORDERWIDTH=dimension
specifies the width of the table borders. The value of BORDERWIDTH= is applied
to all four borders.
Restriction
The BORDERWIDTH= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
Typically, when BORDERWIDTH=0, the ODS destination sets
RULES=NONE (see the discussion about “RULES=rule-type” on page
511) and FRAME=VOID (see the discussion about “FRAME=frametype” on page 501).
See
dimension attribute value on page 519
Examples
“Example 1: Creating a Stand-Alone Style” on page 521
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
CAPSTYLE=line-shape
specifies the shape of the line at the end of a box whisker. line-shape can be one of
the following:
•
"BRACKET"
•
"LINE"
•
"NONE"
•
"SERIF"
Requirement
You must enclose line-shape in quotation marks.
CELLPADDING=dimension | dimension%
specifies the amount of white space on each of the four sides of the content in a table
cell.
dimension
is a nonnegative number or the amount of white space on each of the four sides
of the text in a table cell specified as a percentage of the table.
Restrictions
The CELLPADDING= attribute is valid in markup family destinations
other than HTML5, printer family destinations, and the RTF
destination.
CELLPADDING= is not valid in the HTML5 destination. All padding
is done on the table cells.
See
dimension attribute value on page 519
Example
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
Detailed Information for All Style Attributes
493
CLASS="string"
specifies the name of the style sheet class to use in an HTML document for the table
or table cell.
Alias
HTMLCLASS=
Restriction
The CLASS= attribute is valid only in markup family destinations.
See
string attribute value on page 521
COLOR=color
specifies the color of the foreground in tables, table cells, or graphs, which is
primarily the color of text.
Alias
FOREGROUND=
Restriction
The COLOR= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Interaction
The COLOR= attribute is overridden by the CBACK= option in the
SAS/GRAPH GOPTIONS statement.
Tip
In a table, the COLOR= attribute affects only the text that is specified
with the PRETEXT=, POSTTEXT=, PREHTML=, and POSTHTML=
attributes. To alter the font for the text that appears in the table, set the
attribute for a table cell.
See
color style attribute value on page 517
Examples
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
“Example 1: Creating a Stand-Alone Style” on page 521
CONNECT=connect-line-type
specifies the characteristics of a box plot connect line. connect-line-type can be one
of the following:
•
"MAX"
•
"MEAN"
•
"MEDIAN"
•
"MIN"
•
"Q1"
•
"Q3"
Requirement
You must enclose connect-line-type in quotation marks.
CONTENTPOSITION=position
specifies the position, within the frame file, of the frames that display the contents
and the page files. position can be one of the following:
LEFT
places the frames on the left.
Alias
L
494
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
RIGHT
places the frames on the right.
Alias
R
TOP
places the frames at the top.
Alias
T
BOTTOM
places the frames at the bottom.
Alias
B
Restriction
The CONTENTPOSITION= attribute is valid only in markup family
destinations.
See
For information about the HTML files that ODS creates, see “HTML
Links and References Produced by the HTML Destination ” in SAS
Output Delivery System: User's Guide.
CONTENTSCROLLBAR=YES | NO |AUTO
specifies whether to put a scroll bar in the frames in the frame file that display the
contents and the page files. (For information about the HTML files that ODS creates,
see “HTML Links and References Produced by the HTML Destination ” in SAS
Output Delivery System: User's Guide.)
YES
places a scroll bar in the frames in the frame file that display the contents and the
page files.
NO
specifies not to put a scroll bar in the frames in the frame file that display the
contents and the page files.
AUTO
specifies that the browser put a scroll bar on the table of contents frame only if
the content in that panel is big enough to require scrolling.
Restriction
The CONTENTSCROLLBAR= attribute is valid only in markup
family destinations.
Tip
Typically, CONTENTSCROLLBAR= is set to AUTO.
See
For information about the HTML files that ODS creates, see “HTML
Links and References Produced by the HTML Destination ” in SAS
Output Delivery System: User's Guide.
CONTENTSIZE=dimension | dimension % | *
specifies the width of the frames in the frame file that display the contents and the
page files.
dimension
is a nonnegative number or the width of the frames specified as a percentage of
the entire display.
Detailed Information for All Style Attributes
495
*
specifies to use whatever space is left after displaying the body file as specified
by the BODYSIZE= attribute.
Restriction
The CONTENTSIZE= attribute is valid only in markup family
destinations.
Requirement
dimension % must be a positive number between 0 and 100.
Tip
If dimension is a nonnegative number, then the unit of measure is
pixels.
See
dimension attribute value on page 519
“BODYSIZE=dimension | dimension% | * ” on page 487
For information about the HTML files that ODS creates, see “HTML
Links and References Produced by the HTML Destination ” in SAS
Output Delivery System: User's Guide.
CONTENTTYPE="string"
specifies the value of the content type for pages in an HTML document that is sent
directly to a web server rather than to a file.
string
is the content type for the pages.
Requirement
string must be enclosed in quotation marks.
Tip
The value of string is usually "text/html".
See
string attribute value on page 521
Alias
HTMLCONTENTTYPE=
Restriction
The CONTENTTYPE= attribute is valid only in markup family
destinations.
CONTRASTCOLOR=color
specifies the alternate colors for maps. The alternate colors are applied to the blocks
on region areas in block maps.
Restriction
The CONTRASTCOLOR= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
color style attribute value on page 517
DATASKIN=CRISP | GLOSS | MATTE | NONE | PRESSED | SHEEN
specifies the type of skin to apply to plots and charts (other than KPIs) to give them a
raised, 3-D appearance.
The DATASKIN= style attribute is valid for the following plots and charts in the
Graph Template Language:
•
bar charts
•
pie charts
•
scatter plots
496
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
•
waterfall charts
The DATASKIN= style attribute is valid for the following plots and charts in the SG
procedures:
•
bar charts
•
scatter plots
•
waterfall charts
Table 15.5
DATASKIN Values
NONE
CRISP
GLOSS
MATTE
PRESSED
SHEEN
Restriction
In the first maintenance release of SAS 9.4 and later releases, 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.
DISPLAYOPTS="display-feature"
specifies one or more display features for ODS graphs. To specify multiple features,
enclose the list of features in quotation marks (for example: displayopts="fill
caps mean"). "display-feature" can be one of the following:
CAPS
displays caps at the ends of the whiskers.
Restriction
CAPS can be used only for box plots.
CONNECT
displays the line connecting multiple boxes.
Restriction
CONNECT can be used only for box plots.
FILL
displays filled boxes, bars, ellipses, and bands.
Restriction
FILL can be used only for box plots, histograms, ellipses, and
confidence bands.
MEAN
displays the mean symbol within a box.
Restriction
MEAN can be used only for box plots.
Detailed Information for All Style Attributes
497
MEDIAN
displays the median line within the box.
NOTCHES
displays notched boxes.
NOTCHES can be used only for box plots.
Restriction
OUTLIERS
displays markers for the outliers.
OUTLIERS can be used only for box plots.
Restriction
OUTLINE
displays outlined ellipses and bars.
OUTLINE can be used only for ellipses, bands, and histograms.
Restriction
Requirement
You must enclose "display-feature" in quotation marks.
DOCTYPE="string"
specifies the entire doctype declaration for the HTML document, including the
opening "<!DOCTYPE" and the closing ">".
string
is the doctype declaration.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Alias
HTMLDOCTYPE=
Restriction
The DOCTYPE= attribute is valid only in markup family destinations.
DROPSHADOW=ON | OFF
specifies whether the drop shadow color for text is displayed.
ENDCOLOR=color
specifies the final color used with a two- or three-color ramp.
See
color style attribute value on page 517
FILLPATTERN=fillpattern-value
specifies the fill pattern to be displayed on the chart. The valid values are: S, E, L1,
L2, L3, L4, L5, R1, R2, R3, R4, R5, X1, X2, X3, X4, and X5.
498
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
The FILLPATTERN= attribute is valid for bar charts only.
Tip
To display these fill patterns on the bar chart through the style, you
must also specify "fillpattern" as one of the DISPLAYOPTS in the
GRAPHBAR style element.
See
For a table of style elements and the style attributes that are valid in
each one, see “Style Elements Affecting Template-Based Graphics” on
page 841 and “Style Elements Affecting Device-Based Graphics” on
page 849.
FILLRULEWIDTH=dimension
places a rule of the specified width into the space around the text (or entire cell if
there is no text) in a table where white space would otherwise appear.
Restriction
The FILLRULEWIDTH= attribute is valid only in printer family
destinations.
Tip
If no text is specified, then FILLRULEWIDTH= fills the space around
the text with hyphen marks. For example: --this-- or this ------.
See
dimension attribute value on page 519
FLYOVER="string"
specifies the text to show in a data tip for the table cell.
string
is the text of the data tip.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The FLYOVER= attribute is valid only in markup family destinations
and the PDF destination.
FONT=font-definition
specifies a font definition to use in tables, table cells, and graphs.
Restriction
The FONT= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Tips
For a table, the FONT= attribute affects only the text that is specified
with the PRETEXT=, POSTTEXT=, PREHTML=, and POSTHTML=
attributes. To alter the font for the text that appears in the table, set the
attribute for a table cell.
If the system does not recognize the font specified, then it refers to the
system's default font. This attribute does not accept concatenated fonts.
SAS Graph Styles can only specify one font.
See
font-definition attribute value on page 519
Example
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
Detailed Information for All Style Attributes
499
FONTFAMILY="string-1<…, string-n>"
specifies the font to use in table cells and graphs. If you supply multiple fonts, then
the destination device uses the first one that is installed on the system.
string
is the name of the font.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Alias
FONT_FACE=
Restriction
The FONTFAMILY= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tips
For a table, the FONTFAMILY= attribute affects only the text that is
specified with the PRETEXT=, POSTTEXT=, PREHTML=, and
POSTHTML= attributes. To alter the font for the text that appears in
the table, set the attribute for a table cell.
You cannot be sure what fonts are available to someone who is viewing
the output in a browser or printing it on a high-resolution printer. Most
devices support the following fonts: Times, Courier, Arial, Helvetica.
Example
“Example 1: Creating a Stand-Alone Style” on page 521
FONTSIZE=dimension | size
specifies the size of the font for tables, table cells, and graphs.
dimension
is a nonnegative number.
Alias
FONT_SIZE=
Restriction
If you specify a dimension, then specify a unit of measure. Without
a unit of measure, the number becomes a relative size.
See
dimension attribute value on page 519
size
The value of size is relative to all other font sizes in the HTML document.
Range
1 to 7
Restriction
The FONTSIZE= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Tip
For a table, the FONTSIZE= attribute affects only the text that is
specified with the PRETEXT=, POSTTEXT=, PREHTML=, and
POSTHTML= attributes. To alter the font for the text that appears in
the table, set the attribute for a table cell.
Example
“Example 1: Creating a Stand-Alone Style” on page 521
FONTSTYLE=ITALIC | ROMAN | SLANT
specifies the style of the font for tables, table cells, and graphs. In many cases, italic
and slant map to the same font.
500
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Alias
FONT_STYLE=
Restriction
The FONTSTYLE= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
For a table, the FONTSTYLE= attribute affects only the text that is
specified with the PRETEXT=, POSTTEXT=, PREHTML=, and
POSTHTML= attributes. To alter the font for the text that appears in
the table, set the attribute for a table cell.
Examples
“Example 1: Creating a Stand-Alone Style” on page 521
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
FONTWEIGHT=weight
specifies the font weight of tables, table cells, and graphs. weight is any of the
following:
•
MEDIUM
•
BOLD
•
DEMI_BOLD
•
EXTRA_BOLD
•
LIGHT
•
DEMI_LIGHT
•
EXTRA_LIGHT.
Alias
FONT_WEIGHT=
Restrictions
You cannot be sure what font weights are available to someone who is
viewing the output in a browser or printing it on a high-resolution
printer. Most devices support only MEDIUM and BOLD, and
possibly LIGHT.
The FONTWEIGHT= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
For a table, the FONTWEIGHT= attribute affects only the text that is
specified with the PRETEXT=, POSTTEXT=, PREHTML=, and
POSTHTML= attributes. To alter the font for the text that appears in
the table, set the attribute for a table cell.
Examples
“Example 1: Creating a Stand-Alone Style” on page 521
“Example 1: Creating a Stand-Alone Style” on page 521
FONTWIDTH=relative-width
specifies the font width of tables, table cells, and graphs compared to the width of the
usual design of the table, table cell, or graph. relative-width is any of the following:
•
NORMAL
•
COMPRESSED
•
EXTRA_COMPRESSED
Detailed Information for All Style Attributes
•
NARROW
•
WIDE
•
EXPANDED
Alias
FONT_WIDTH=
Restrictions
Few fonts honor these values.
501
The FONTWIDTH= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
For a table, the FONTWIDTH= attribute affects only the text that is
specified with the PRETEXT=, POSTTEXT=, PREHTML=, and
POSTHTML= attributes. To alter the font for the text that appears in
the table, set the attribute for a table cell.
Example
“Example 1: Creating a Stand-Alone Style” on page 521
FRAME=frame-type
specifies the type of frame to use on a table. This table shows the possible values for
frame-type and their meanings:
Table 15.6
Frame-type Values
Value for frame-type
Frame Type
ABOVE
A border at the top
BELOW
A border at the bottom
BOX
Borders at the top, bottom, and both sides
HSIDES
Borders at the top and bottom
LHS
A border at the left side
RHS
A border at the right side
VOID
No borders
VSIDES
Borders at the left and right sides
Restriction
The FRAME= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Example
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
FRAMEBORDER=ON | OFF
specifies whether to put a border around the frame for an HTML file that uses
frames.
ON
places a border around the frame for an HTML file that uses frames.
502
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
OFF
specifies not to put a border around the frame for an HTML file that uses frames.
Restriction
The FRAMEBORDER= attribute is valid only in markup family
destinations.
FRAMEBORDERWIDTH=dimension
specifies the width of the border around the frames for an HTML file that uses
frames.
Restriction
The FRAMEBORDERWIDTH= attribute is valid only in markup
family destinations.
See
dimension attribute value on page 519
FRAMESPACING=dimension
specifies the width of the space between frames for HTML that uses frames.
Restriction
The FRAMESPACING= attribute is valid only in markup family
destinations.
See
dimension attribute value on page 519
GRADIENT_DIRECTION="YAXIS" | "XAXIS "
specifies the direction of the gradient.
"YAXIS"
specifies a vertical gradient.
"XAXIS"
specifies a horizontal gradient.
HEIGHT=dimension
specifies the height of a table cell, graph, or graphics in an HTML document.
dimension
is a nonnegative number.
See
dimension attribute value on page 519
Aliases
CELLHEIGHT=
OUTPUTHEIGHT=
Restrictions
The HEIGHT= option does not apply to output generated as a result of
GRSEG (graph segment) output.
The HEIGHT= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Interaction
The YPIXELS= option in the SAS/GRAPH GOPTIONS statement
overrides the HEIGHT= attribute.
Tip
HTML automatically sets cell height appropriately. You will seldom
need to specify this attribute in the HTML destination.
HREFTARGET="target"
specifies the window or frame in which to open the target of the link. target is one of
these values:
Detailed Information for All Style Attributes
503
_blank
opens the target in a new, blank window. The window has no name.
Use lowercase letters to specify values for HREFTARGET.
Restriction
_parent
opens the target in the window from which the current window was opened.
Use lowercase letters to specify values for HREFTARGET.
Restriction
_search
opens the target in the browser's search pane.
Only available in Internet Explorer 5.0 or later.
Restrictions
Use lowercase letters to specify values for HREFTARGET.
_self
opens the target in the current window.
Use lowercase letters to specify values for HREFTARGET.
Restriction
_top
opens the target in the topmost window.
Use lowercase letters to specify values for HREFTARGET.
Restriction
"name"
opens the target in the specified window or the frame.
Default
_self
Restrictions
The HREFTARGET= attribute is valid only in markup family
destinations.
Use lowercase letters to specify values for HREFTARGET.
Requirement
target must be enclosed in quotation marks.
HTMLID="string"
specifies an ID for the table or table cell. The ID is for use by a Java Script.
string
is the ID text.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The HTMLID= attribute is valid only in markup family destinations.
HTMLSTYLE="string"
specifies individual attributes and values for a table or table cell in an HTML
document.
string
is the name of an attribute or value.
504
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The HTMLSTYLE= attribute is valid only in markup family
destinations.
IMAGE="string"
specifies the image to appear in a graph. This image is positioned or tiled.
string
is the name of the image.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The IMAGE= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Interaction
The BACK= and IMAGESTYLE=TILE options in the SAS/GRAPH
GOPTIONS statement override the IMAGE= attribute.
KPISKIN=BASIC | MODERN | NONE | ONYX | SATIN
specifies the type of skin to apply to KPI charts to give them a raised, 3-D
appearance.
LINESTYLE=pattern-number
specifies the pattern of a line. Valid pattern numbers range from 1 to 46. Not all
pattern numbers have names. You must specify the line pattern by its number.
pattern-number can be one of the following:
Figure 15.8
Table of Line Patterns
LINETHICKNESS=dimension
specifies the thickness of a line.
See
dimension attribute value on page 519
LINKCOLOR=color
specifies the color for the links in an HTML document that have not yet been visited.
Detailed Information for All Style Attributes
Restriction
The LINKCOLOR= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
color style attribute value on page 517
505
LISTENTRYANCHOR=ON | OFF
in an HTML document, the LISTENTRYANCHOR= attribute specifies whether to
make the entry in the table of contents a link to the body file.
ON
specifies to make this entry in the table of contents a link to the body file.
OFF
specifies not to make this entry in the table of contents a link to the body file.
Restriction
The LISTENTRYANCHOR= attribute is valid only in markup family
destinations.
LISTSTYLETYPE=bullet-type
specifies the type of bullet to use for lists and the contents file. ODS uses bullets in
the contents file.
bullet-type
is one of the following:
Alias
BULLET
See
string attribute value on page 521
506
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
The LISTSTYLETYPE= attribute is valid only in markup family
destinations.
MARGINBOTTOM=dimension
specifies the bottom margin for the HTML document.
Alias
BOTTOMMARGIN=
Restriction
The MARGINBOTTOM= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
If the orientation of a PDF document is changed after the PDF
destination is opened and before the PDF destination is closed, any
setting for margins is taken from the OPTIONS statement in place
before the ODS PDF FILE= statement. If no OPTIONS statement is
used to explicitly set the margins, the margin settings are retrieved from
the SAS registry.
See
dimension attribute value on page 519
MARGINLEFT=dimension
specifies the left margin for the HTML document.
Alias
LEFTMARGIN=
Restriction
The MARGINLEFT= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
If the orientation of a PDF document is changed after the PDF
destination is opened and before the PDF destination is closed, any
setting for margins is taken from the OPTIONS statement in place
before the ODS PDF FILE= statement. If no OPTIONS statement is
used to explicitly set the margins, the margin settings are retrieved from
the SAS registry.
See
dimension attribute value on page 519
MARGINRIGHT=dimension
specifies the right margin for the HTML document.
Alias
RIGHTMARGIN=
Restriction
The MARGINRIGHT= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
If the orientation of a PDF document is changed after the PDF
destination is opened and before the PDF destination is closed, any
setting for margins is taken from the OPTIONS statement in place
before the ODS PDF FILE= statement. If no OPTIONS statement is
used to explicitly set the margins, the margin settings are retrieved from
the SAS registry.
See
dimension attribute value on page 519
MARGINTOP=dimension
specifies the top margin for the HTML document.
Detailed Information for All Style Attributes
507
Alias
TOPMARGIN=
Restriction
The MARGINTOP= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tip
If the orientation of a PDF document is changed after the PDF
destination is opened and before the PDF destination is closed, any
setting for margins is taken from the OPTIONS statement in place
before the ODS PDF FILE= statement. If no OPTIONS statement is
used to explicitly set the margins, the margin settings are retrieved from
the SAS registry.
See
dimension attribute value on page 519
MARKERSIZE=dimension
specifies the marker size (both width and height).
See
dimension attribute value on page 519
MARKERSYMBOL=marker-symbol
specifies a marker symbol. marker-symbol can be one of the following:
Figure 15.9
Table of Marker Symbols
NEUTRALCOLOR=color
specifies the middle color in a three-color ramp.
See
color style attribute value on page 517
NOBREAKSPACE=ON | OFF
specifies how to handle space characters in table cells.
ON
does not let SAS break a line at a space character.
OFF
lets SAS break a line at a space character if appropriate.
Restriction
The NOBREAKSPACE= attribute is valid in markup family
destinations, printer family destinations, and the RTF destination.
OUTPUTHEIGHT=dimension
specifies the height of a graph.
508
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
See
dimension attribute value on page 519
OUTPUTWIDTH=dimension
specifies the width of a graph.
See
dimension attribute value on page 519
OVERHANGFACTOR=nonnegative-number
specifies an upper limit for extending the width of the column in an HTML
document.
Restriction
The OVERHANGFACTOR= attribute is valid only in markup family
and printer family destinations.
Tips
Typically, an overhang factor between 1 and 2 works well.
The HTML that is generated by ODS tries to ensure that the text in a
column wraps when it reaches the requested column width. When the
overhang factor greater than 1, the text can extend beyond the specified
width.
PADDING=dimension | dimension%
specifies the amount of white space between the content of the table cell and the
border. The value of PADDING= applies to all four sides.
To change the padding of each side, use one or more of the following attributes:
•
PADDINGBOTTOM= on page 508
•
PADDINGLEFT= on page 508
•
PADDINGRIGHT= on page 509
•
PADDINGTOP= on page 509
Restriction
The PADDING= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
See
dimension attribute value on page 519
PADDINGBOTTOM=dimension | dimension%
specifies the amount of white space on the bottom of the content of the table cell.
Default
0
Restriction
The PADDINGBOTTOM= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
dimension attribute value on page 519
PADDINGLEFT=dimension | dimension%
specifies the amount of white space on the left side of the content of the table cell.
Default
0
Restriction
The PADDINGLEFT= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
dimension attribute value on page 519
Detailed Information for All Style Attributes
509
PADDINGRIGHT=dimension | dimension%
specifies the amount of white space on the right side of the content of the table cell.
Default
0
Restriction
The PADDINGRIGHT= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
dimension attribute value on page 519
PADDINGTOP=dimension | dimension%
specifies the amount of white space on the top of the content of the table cell.
Default
0
Restriction
The PADDINGTOP= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
See
dimension attribute value on page 519
PAGEBREAKHTML="string"
specifies HTML to place at page breaks in an HTML document.
string
is the HTML code used to place at page breaks.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The PAGEBREAKHTML= attribute is valid only in markup family
destinations.
POSTHTML="string"
specifies the HTML code to place after the table or table cell.
string
is the HTML code to place after a table or table cell.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
Restriction
The POSTHTML= attribute is valid only in markup family
destinations.
Example
“Example 3: Modifying the Default Style with the CLASS Statement”
on page 537
POSTIMAGE="string" | fileref
specifies an image to place after the table or table cell.
string
names a GIF or JPEG file. Use a simple filename, a complete path, or a URL.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
510
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
fileref
is a reference that has been assigned to an external file. Use the FILENAME
statement to assign a fileref.
See
"Statements" in SAS Statements: Reference for information about the
FILENAME statement.
Restriction
The POSTIMAGE= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
POSTTEXT="string"
specifies text to place after the table cell or table.
Restriction
The POSTTEXT= attribute is valid only for markup family
destinations, printer family destinations, and the RTF destination.
Requirement
string must be enclosed in quotation marks.
See
string attribute value on page 521
PREHTML="string"
specifies the HTML code to place before the table or table cell.
Restriction
The PREHTML= attribute is valid only for markup family destinations.
See
string attribute value on page 521
PREIMAGE="string" | fileref
specifies an image to place before the table or table cell.
string
names a GIF or JPEG file. Use a simple filename, a complete path, or a URL.
Restriction
When using the PREIMAGE= style attribute with the PRINTER
destination, you must specify STARTPAGE=NO on the
PRINTER family statement to display page numbers, times,
dates, and titles. Without the STARTPAGE=NO option,
preimages are treated like graphs and have no page numbers,
times, dates, or titles displayed.
Requirement
Enclose string in quotation marks.
See
string attribute value on page 521
fileref
is a reference that has been assigned to an external file. Use the FILENAME
statement to assign a fileref. (For information about the FILENAME statement,
see "Statements" in SAS Statements: Reference.)
Restriction
The PREIMAGE= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
PRETEXT="string"
specifies text to place before the table cell or table.
string
text that is placed before the table cell or table.
Detailed Information for All Style Attributes
Requirement
Enclose string in quotation marks.
See
string attribute value on page 521
Example
“Customizing the Table of Contents” in SAS Output Delivery
System: User's Guide
Restriction
511
The PRETEXT= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
PROTECTSPECIALCHARS=ON | OFF | AUTO
specifies how less-than signs (<), greater-than signs (>), and ampersands (&) are
interpreted in table cells. In HTML and other markup languages, these characters
indicate the beginning of a markup tag, the end of a markup tag, and the beginning of
the name of a file or character entity.
ON
interprets special characters as the characters themselves. That is, when ON is in
effect the characters are protected before they are passed to the HTML or other
markup language destination so that the characters are not interpreted as part of
the markup language. Using ON enables you to show markup language tags in
the HTML document.
OFF
interprets special characters as markup language tags. That is, when OFF is in
effect, the characters are passed to the HTML or other markup language
destination without any protection so that the special characters are interpreted as
part of the markup language.
AUTO
interprets any string that starts with a < and ends with a > as a markup language
tag (ignoring spaces that immediately precede the <, spaces that immediately
follow the >, and spaces at the beginning and end of the string). In any other
string, AUTO protects the special characters from their markup language
meaning.
Restriction
The PROTECTSPECIALCHARS= attribute is valid only in markup
family destinations, printer family destinations, and the RTF
destination.
RULES=rule-type
specifies the types of rules to use in tables. This table shows the possible values for
the RULES= attribute and their meanings:
Table 15.7
RULES= Attribute Values
Value of RULES= Attribute
Locations of Rules
ALL
Between all rows and columns
COLS
Between all columns
GROUPS
Between the table header and the table and
between the table and the table footer, if
there is one
NONE
No rules anywhere
512
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Value of RULES= Attribute
Locations of Rules
ROWS
Between all rows
Restriction
The RULES= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Example
“Example 4: Defining a Table and Graph Style” on page 543
STARTCOLOR=color
specifies the start fill color for a graph. It is used to create a gradient effect.
Note: You can have either a start and end gradient effect or no gradient effect. If you
specify a TRANSPARENCY level and you only specify the STARTCOLOR,
then the end color is completely transparent gradationally to the specified start
color.
Restriction
The STARTCOLOR= attribute is valid only for the HTML destination.
See
color style attribute value on page 517
TAGATTR="string"
specifies text to insert into HTML.
string
is the text that is inserted into HTML tags.
Requirements
string must be enclosed in quotation marks.
string must be valid HTML for the context in which the style
element is created.
Tip
Many style elements are created between <TD> and </TD> tags.
To determine how a style element is created, look at the source
for the output.
See
string attribute value on page 521
The TAGATTR= attribute is valid only in markup family destinations.
Restriction
TEXTALIGN=alignment
specifies justification in tables, table cells, and graphs. In graphs, this option
specifies the justification of the image specified with the IMAGE= statement. For
example, this statement would produce a page number that is centered at the bottom
of the page: style PageNo from TitleAndFooters / textalign=c
verticalalign=b; This statement would produce a date in the body file that is
left-justified at the top of the page: style BodyDate from Date /
textalign=l;alignment can be one of the following:
CENTER
specifies center justification.
Alias
C
DEC
specifies aligning the values by the decimal point.
Detailed Information for All Style Attributes
Alias
D
Restriction
Decimal alignment is supported for the printer family and RTF
destinations only.
513
LEFT
specifies left justification.
Alias
L
RIGHT
specifies right justification.
Alias
R
Restriction
Not all contexts support RIGHT. If RIGHT is not supported, it is
interpreted as CENTER.
Alias
JUST=
Restriction
The TEXTALIGN= attribute is valid in markup family destinations
other than HTML5, printer family destinations, and the RTF
destination. For the HTML5 destination, you might be able to use
MARGINRIGHT=0 instead.
Tips
For the printer family destinations and the MARKUP destination, use
the style attribute TEXTALIGN= with the style attribute
VERTICALALIGN= in the style element PAGENO to control the
placement of page numbers.
For printer family destinations and the MARKUP destination, control
the placement of dates by using the style attribute TEXTALIGN= with
the style attribute VERTICALALIGN= in the BODYDATE or DATE.
style element.
TEXTDECORATION=presentation–options
changes the visual presentation of the text. presentation–options can be one of the
following:
BLINK
specifies that the text's visual presentation alternates rapidly between visible and
invisible.
Restriction
TEXTDECORATION=BLINK is valid only in the HTML and RTF
destinations.
LINE_THROUGH
specifies that a line is drawn through the text.
Restriction
TEXTDECORATION=LINE_THROUGH is valid only in the
HTML destination, the printer family, the measured RTF
destination, and the RTF destination.
OVERLINE
specifies that a line is drawn above the text.
514
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Restriction
TEXTDECORATION=OVERLINE is valid only in the HTML
destination and the printer family destinations.
UNDERLINE
specifies that a line is drawn below the text.
Restriction
TEXTDECORATION=UNDERLINE is valid only in the HTML
destination, the printer family destinations, the measured RTF
destination, and the RTF destination.
Tip
TEXTDECORATION= can be used with inline formatting and the ODS
PDF statement to enhance PDF files.
Example
“Formatting Cells Using the Textdecoration Style Attribute ” in SAS
Output Delivery System: Advanced Topics
TEXTINDENT=n
specifies the number of spaces that the first line of output is indented.
n
specifies the number of spaces to indent the output.
Alias
INDENT=
Default
The default value for XML is 2. For all other ODS destinations, the
default value is 0.
Restriction
The TEXTINDENT= attribute is valid only in the markup family
destinations, the printer family destinations, and the RTF destination.
TICKDISPLAY="INSIDE" | "OUTSIDE" | "ACROSS"
specifies the placement of all major and minor axis tick marks.
TEXTJUSTIFY=INTER_WORD | INTER_CHARACTER
specifies how to evenly distribute text.
INTER_WORD
specifies that the words are evenly distributed across the page.
INTER_CHARACTER
specifies that all characters are evenly distributed across a page.
Tip
Use the TEXTJUSTIFY= style attribute with the TEXTALIGN=J (alias
JUST=) style attribute.
TRANSPARENCY=dimension
specifies a transparency level for graphs. The values are 0.0 (opaque) to 1.0
(transparent).
Restriction
The TRANSPARENCY= attribute is valid only in the HTML
destination.
See
dimension attribute value on page 519
URL="uniform-resource-locator"
specifies a URL to link to from the current cell.
Detailed Information for All Style Attributes
Restriction
The URL= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Requirement
uniform-resource-locator must be enclosed in quotation marks.
515
VERTICALALIGN=BOTTOM | MIDDLE | TOP
specifies vertical justification for graphs and cells. In graphs, this option specifies the
vertical justification of the image specified with IMAGE=. For example, this
statement produces a page number that is centered at the bottom of the page: style
PageNo from TitleAndFooters / textalign=c verticalalign=b;
This statement produces a date in the body file that is left-justified at the top of the
page: style BodyDate from Date / textalign=l verticalalign=t;
BOTTOM
specifies bottom justification.
Alias
B
MIDDLE
specifies center justification.
Alias
M
TOP
specifies top justification.
Alias
T
Alias
VJUST=
Restriction
The VERTICALALIGN= attribute is valid only in markup family
destinations, printer family destinations, and the RTF destination.
Tips
For printer and markup family destinations, use the style attribute
VERTICALALIGN= with the style attribute TEXTALIGN= in the
style element PAGENO to control the placement of page numbers.
For printer and markup family destinations, control the placement of
dates by using the style attribute VERTICALALIGN= with the style
attribute TEXTALIGN= in the BODYDATE or DATE style element.
VISITEDLINKCOLOR=color
specifies the color for links that have been visited in an HTML document.
Restriction
The VISITEDLINKCOLOR= attribute is valid only in markup family
destinations.
See
color style attribute value on page 517
WATERMARK=ON | OFF
specifies whether to make the image that is specified by BACKGROUNDIMAGE=
into a watermark. A watermark appears in a fixed position as the window is scrolled.
ON
specifies to make the image that is specified by BACKGROUNDIMAGE= into a
watermark.
516
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
OFF
specifies not to make the image that is specified by BACKGROUNDIMAGE=
into a watermark.
Restriction
The WATERMARK= attribute is valid only in markup family
destinations.
Tip
You can apply a watermark to output generated using the ODS
TAGSETS.RTF destination by specifying a background image file.
Note that the image is applied to the RTF document and not to a table
or a table cell.
See
“BACKGROUNDIMAGE="string"” on page 485
WHITESPACE=options
specifies how the browser handles multiple whitespace characters and line breaks.
options can be one of the following:
NORMAL
specifies that white spaces are compressed and text wraps
normally.
NOWRAP
specifies that white spaces are compressed and that text does not
have line breaks.
PRE
specifies that white spaces are left intact and that text does not
have line breaks.
PRE_LINE
specifies that white spaces are compressed, keeps line breaks
that are in the text, and adds line breaks as needed.
PRE_WRAP
specifies that white spaces are left intact and allows line
breaking.
Default
NORMAL
WIDTH=dimension
specifies the width of a table cell, table, line, or a graph.
When used with graphs, the WIDTH= option must be specified as a pixel or
percentage value. If a unit of measure is not specified with the dimension, then the
value will be in pixels. If a unit of measure other than pixels or percentage is
specified with the dimension, then the HEIGHT=dimension is not applied to the
graph.
dimension
is a nonnegative number.
See
dimension attribute value on page 519
Aliases
CELLWIDTH=
OUTPUTWIDTH=
Restrictions
The WIDTH= option does not apply to output generated as a result of
GRSEG (graph segment) output.
The WIDTH= attribute is valid only in markup family destinations,
printer family destinations, and the RTF destination.
Style Attribute Values
517
Interaction
The XPIXELS= option in the SAS/GRAPH GOPTIONS statement
overrides the WIDTH= attribute.
Tips
A column of cells has the width of the widest cell in the column.
Use WIDTH=100% to make the table or graph as wide as the window
that it is open in.
Style Attribute Values
color
is a string that identifies a color. A color is defined in the following ways:
•
most of the color names that are supported by SAS/GRAPH. These names
include the following:
•
a predefined SAS color (for example, blue or VIYG)
•
a red/green/blue (RGB) value (for example, CX0023FF)
•
a hue/light/saturation (HLS) value (for example, H14E162D)
•
a gray-scale value (for example, GRAYBB).
•
a red/green/blue transparency (RGBA) value (for example, a98FB9880)
•
a cyan/magenta/yellow/black (CMYK) value (for example, FFFFFF00)
Note: RGBA color mode is not supported by Java devices. RGBA color mode is
supported by ActiveX devices when the output is used in Microsoft
applications.
•
an RGB value with a leading number sign (#) rather than CX (for example,
#0023FF).
•
one of the colors that exist in the SAS session when the style is used:
•
DMSBLUE
•
DMSRED
•
DMSPINK
•
DMSGREEN
•
DMSCYAN
•
DMSYELLOW
•
DMSWHITE
•
DMSORANGE
•
DMSBLACK
•
DMSMAGENTA
•
DMSGRAY
•
DMSBROWN
•
SYSBACK
•
SYSSECB
518
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
•
SYSFORE
Note: Use these colors only when running SAS in the windowing environment.
•
an English description of an HLS. Such descriptions use a combination of words
to describe the lightness, the saturation, and the hue (in that order). Use the Color
Naming System to form a color in the following ways:
•
combining a chromatic hue with a lightness, a saturation, or both
•
combining the achromatic hue gray with a lightness
•
combining the achromatic hue black or white without qualifiers
Use the words in the following table:
Table 15.8
Hue/Light/Saturation (HLS) Values
Lightness
Saturation
Chromatic Hue
Achromatic Hue
Blue
Black*
Very dark
Grayish
Purple
Dark
Moderate
Red
Medium
Strong
Orange | brown
Light
Vivid
Yellow
Very light
Gray**
Green
White*
* Black and white cannot be combined with a lightness value or a saturation value.
** Gray cannot be combined with a saturation value.
Combine these words to form a wide variety of colors. Here are examples:
•
light vivid green
•
dark vivid orange
•
light yellow
Note: The Output Delivery System first tries to match a color with a
SAS/GRAPH color. Thus, although brown and orange are interchangeable in
the table, if you use them as unmodified hues, then they are different. The
reason for this is that ODS interprets them as SAS colors, which are mapped
to different colors.
You can also specify hues that are intermediate between two neighboring colors.
To do so, combine one of these adjectives with one of its neighboring colors:
•
reddish
•
orangish
•
brownish
•
yellowish
•
greenish
Style Attribute Values
•
bluish
•
purplish
•
bluish purple
•
reddish orange
•
yellowish green
Tips
519
For a list of some valid colors, see Link to Valid Colors to use with cascading
style sheets
To see how color names map to hexadecimal values, submit the following
REGISTRY procedure code:
proc registry list startat="COLORNAMES";
run;
See
RBG Color Codes, HLS Color Codes, and Gray-Scale Color codes in
SAS/GRAPH: Reference for information about SAS/GRAPH colors.
dimension
is a whole number, a percentage, or a nonnegative number followed by one of these
units of measure:
Table 15.9
Units of Measure for Dimension
cm
Centimeters
em
Standard typesetting measurement unit for width
ex
Standard typesetting measurement unit for height
in
Inches
mm
Millimeters
pt
A printer's point
Default
For the PRINTER destination, units of 1/150 of an inch
font-definition
is the name of a font, the font size, and font keywords. A font definition has this
general format:
("font-face-1 <… , font-face-n>", font-size, keyword-list)
"font-face"
specifies the name of the font.
ODS styles can now use new TrueType fonts. All Universal Printers and many
SAS/GRAPH devices use the FreeType library to render TrueType fonts for
output in all of the operating environments that SAS software supports. In
addition, by default, many SAS/GRAPH device drivers and all Universal Printers
generate output using ODS styles, and these ODS styles use TrueType fonts. In
addition to SAS Monospace and SAS Monospace Bold, 21 new TrueType fonts
are made available when you install SAS:
520
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
•
five Latin fonts compatible with Microsoft
•
eight multilingual Unicode fonts
•
eight monolingual Asian fonts
For more information about the TrueType fonts, see the section "Printing with
SAS" in SAS Language Reference: Concepts.
Restriction
You must enclose multiple font-face in quotation marks. If you
specify only one font and if its name does not include a space
character, then omit the quotation marks.
Tip
If you specify more than one font, then the destination device uses
the first one that is installed on the system.
font-size
specifies the size of the font. font-size is a dimension or a number without units
of measure. If you specify a dimension, then specify a unit of measure. Without a
unit of measure the number becomes a size that is relative to all other font sizes
in the HTML document. For more information, see dimension attribute value on
page 519.
keyword-list
specifies the font weight, font style, and font width. Include one value for each,
in any order. This table shows the keywords to use:
Table 15.10
Font Keywords
Keywords for Font
Weight
Keywords for Font Style
Keywords for Font Width
MEDIUM
ITALIC
NORMAL*
BOLD
ROMAN
COMPRESSED*
DEMI_BOLD*
SLANT
EXTRA_COMPRESSED*
EXTRA_BOLD*
NARROW*
LIGHT
WIDE*
DEMI_LIGHT*
EXPANDED*
EXTRA_LIGHT*
* Few fonts honor these values.
Example
“Example 2: Using User-Defined Attributes” on page 528
format
is a SAS format or a user-defined format.
integer | integer-list | integer-column-list
specifies a column variable that contains integer values, or a dynamic variable that
refers to such a column variable.
Example 1: Creating a Stand-Alone Style
521
integer
specifies a single integer.
integer-list
specifies a sequence of integer values, or a column variable that contains integer
values, or a dynamic variable that refers to such a column variable or to a string.
integer-column-list
specifies a sequence of column variables, or a column variable that contains
column variables, or a dynamic variable that refers to such a column variable, or
a dynamic variable that refers to a string containing a list of column variables.
Values within the columns must be integers.
style-reference
is a reference to an attribute that is defined in the current style or in the parent style
(or beyond). The value used is the name of the style element followed by the name of
an attribute, in parentheses, within that element. Style references have the following
form:
style-attribute=target-style-element("target-style-attribute")
style-attribute
specifies the name of the style attribute.
target-style-element
specifies the name of the style element that contains the style attribute that you
want to reference.
target-style-attribute
specifies the style attribute with the value that you want to use.
Requirement
You must enclose target-style-attribute in quotation marks if it is a
user-supplied style attribute.
See
“Understanding Style References ” on page 455
Example
“Example 2: Using User-Defined Attributes” on page 528
"string"
is a quoted character string.
user-defined-format
specifies a format created with the FORMAT procedure.
Restriction
user-defined-format can only be specified for data cells.
Examples: TEMPLATE Procedure: Creating a
Style Template
Example 1: Creating a Stand-Alone Style
Features:
BACKGROUNDCOLOR= in the STYLE statement
BORDERWIDTH= in the STYLE statement
522
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
BORDERSPACING= in the STYLE statement
FONTFAMILY= in the STYLE statement
FONTSIZE= in the STYLE statement
FONTSTYLE= in the STYLE statement
FONTWEIGHT= in the STYLE statement
COLOR= in the STYLE statement
CLASSLEVELS= table attribute in the DEFINE TABLE statement
DYNAMIC statement in the DEFINE TABLE statement
MVAR statement in the DEFINE TABLE statement
BLANK_DUPS= in the DEFINE COLUMN statement
GENERIC= in the DEFINE COLUMN statement
HEADER= in the DEFINE COLUMN statement
STYLE= in the DEFINE COLUMN statement
TEXT statement in the DEFINE FOOTER statement
Other features:
Data set:
Format:
Other ODS features
ODS HTML statement
FILE statement with ODS= option
PUT statement with _ODS_ argument
Grain_Production
$CNTRY.
Details
This example creates a style that is not based on any other style. When you create a
style, you will usually base it on one of the styles that SAS provides (see “Example 3:
Modifying the Default Style with the CLASS Statement” on page 537). However, this
example is provided to show you some of the basic ways to create a style.
It is important to understand that by default, certain table elements are created with
certain style elements. For example, unless you specify a different style element with the
STYLE= attribute, ODS produces SAS titles with the SystemTitle style element.
Similarly, unless you specify otherwise, ODS produces headers with the Header style
element. (For information about each style element, see Chapter 21, “Style Elements,”
on page 831.
Program
proc template;
define style newstyle;
style cellcontents /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white;
style header /
backgroundcolor=very light blue
fontfamily="arial, helvetica"
fontweight=medium
Example 1: Creating a Stand-Alone Style
fontstyle=roman
fontsize=5
color=white;
style systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=white
fontstyle=italic
fontsize=6
color=red;
style footer from systemtitle /
fontsize=3;
style table /
borderspacing=5
borderwidth=10;
end;
run;
proc template;
define table table1;
mvar sysdate9;
dynamic colhd;
classlevels=on;
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end;
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end;
define footer table_footer;
text "Prepared on " sysdate9;
end;
end;
run;
filename odsout ".";
ods html close;
ods html path=odsout file="newstyle-body.htm" style=newstyle;
title "Leading Grain Producers";
title2 "in 1996";
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
file print ods=(
523
524
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
template="table1"
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
);
put _ods_;
run;
ods html close;
ods html;
Program Description
Create a new style named NewStyle with the style element CellContents. The PROC
TEMPLATE statement starts the TEMPLATE procedure. The DEFINE STYLE
statement creates a new style called NewStyle. This STYLE statement defines the style
element CellContents. This style element consists of the style attributes that appear in
the STYLE statement. The FONTFAMILY= attribute tells the browser to use the Arial
font if it is available, and to look for the Helvetica font if Arial is not available.
proc template;
define style newstyle;
style cellcontents /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white;
Create the style element Header. This STYLE statement creates the style element
Header. By default, ODS uses Header to produce both spanning headers and column
headings. This style element uses a different background color from CellContents. It
uses the same font (Arial or Helvetica), the same font style (roman), the same font color
(white), and the same font size (5) as CellContents.
style header /
backgroundcolor=very light blue
fontfamily="arial, helvetica"
fontweight=medium
fontstyle=roman
fontsize=5
color=white;
Create the style element SystemTitle. This STYLE statement creates the style element
SystemTitle. By default, ODS uses SystemTitle to produce SAS titles. This style element
uses a color scheme of a red foreground on a white background. It uses the same font
and font weight as Header and CellContents, but it adds an italic font style and uses a
larger font size.
style systemtitle /
fontfamily="arial, helvetica"
Example 1: Creating a Stand-Alone Style
525
fontweight=medium
backgroundcolor=white
fontstyle=italic
fontsize=6
color=red;
Create the style element Footer. This STYLE statement creates the style element
Footer. This style element inherits all the attributes of SystemTitle. However, the font
size that it inherits is overwritten by the FONTSIZE= attribute in its template.
style footer from systemtitle /
fontsize=3;
Create the style element Table. This STYLE statement creates the style element Table.
By default, ODS uses this style element to display tables.
style table /
borderspacing=5
borderwidth=10;
End the style. The END statement ends the style template. The RUN statement executes
the TEMPLATE procedure.
end;
run;
Create the table template Table1. The PROC TEMPLATE statement starts the
TEMPLATE procedure. The DEFINE TABLE statement creates a new table template
called Table1.
proc template;
define table table1;
Specify the symbol that references one macro variable. The MVAR statement
defines a symbol, SysDate9, that references a macro variable. ODS will use the value of
this macro variable as a string. References to the macro variable are resolved when ODS
binds the table template to the data component to produce an output object. SYSDATE9
is an automatic macro variable whose value is always available.
mvar sysdate9;
Specify the symbol that references a value to be supplied by the data component.
The DYNAMIC statement defines a symbol, Colhd, that references a value that the data
component supplies when ODS binds the template and the data component to produce an
output object. The values for Colhd are provided in the FILE statement in the DATA step
that appears later in the program. Using dynamic column headings gives you more
flexibility than does hardcoding the headers in the table template.
dynamic colhd;
Control the repetition of values that do not change from one row to the next row.
The CLASSLEVELS= attribute suppresses the display of the value in a column that is
marked with BLANK_DUPS=ON if the value changes in a previous column that is also
marked with BLANK_DUPS=ON. Because BLANK_DUPS= is set in a generic column,
set this attribute as well.
classlevels=on;
526
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Create the column Char_Var. This DEFINE statement and its attributes create the
column template Char_Var. GENERIC= specifies that multiple variables can use the
same column template. BLANK_DUPS= suppresses the display of the value in the
column if it does not change from one row to the next (and, because
CLASSLEVELS=ON for the table, if no values in preceding columns that are marked
with BLANK_DUPS=ON changes). HEADER= specifies that the header for the column
will be the text of the dynamic variable Colhd, whose value will be set by the data
component. The STYLE= attribute specifies that the style element for this column
template is CellContents.The END statement ends the template.
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end;
Create the column template Num_Var. This DEFINE statement and its attributes create
the column template Num_Var. GENERIC= specifies that multiple variables can use the
same column template. HEADER= specifies that the header for the column will be the
text of the dynamic variable Colhd, whose value will be set by the data component. The
STYLE= attribute specifies that the style element for this column template is
CellContents.The END statement ends the template.
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end;
Create the footer element Table_Footer. The DEFINE statement and its substatement
define the table element Table_Footer. The FOOTER argument declares Table_Footer as
a footer. The TEXT statement specifies the text of the footer. When ODS binds the data
component to the table template (in the DATA step that follows), it will resolve the value
of the macro variable SYSDATE9.
define footer table_footer;
text "Prepared on " sysdate9;
end;
End the table template. This END statement ends the table template. The RUN
statement executes the PROC TEMPLATE step.
end;
run;
Create a file reference for the output. The current working directory is specified in this
example.
filename odsout ".";
ods html close;
Create HTML output and specify the location for storing the HTML output. Specify
the style to use for the output. The HTML destination is open by default. However, to
specify a style, you must use the ODS HTML statement with the STYLE= open
specified.. The STYLE= option tells ODS to use NewStyle as the style when it formats
the output.
Example 1: Creating a Stand-Alone Style
527
ods html path=odsout file="newstyle-body.htm" style=newstyle;
Specify the titles for the report. The TITLE statements provide two titles for the
output.
title "Leading Grain Producers";
title2 "in 1996";
Create the data component. This DATA step does not create a data set. Instead, it
creates a data component and, eventually, an output object. The SET statement reads the
data set Grain_Production. The WHERE statement subsets the data set so that the output
object contains information only for rice and corn production in 1996.
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
Route the DATA step results to ODS and use the Table1 table template. The
combination of the fileref PRINT and the ODS option in the FILE statement routes the
results of the DATA step to ODS. The TEMPLATE= suboption tells ODS to use the
table template named Table1, which was previously created with PROC TEMPLATE.
For more information about using the DATA step with ODS, see “Using ODS with the
DATA Step” in SAS Output Delivery System: User's Guide.
file print ods=(
template="table1"
Specify the column template to use for each variable. The COLUMNS= suboption
places DATA step variables into columns that are defined in the table template. For
example, the first column-specification specifies that the first column of the output
object contains the values of the variable COUNTRY and that it uses the column
template named Char_Var. GENERIC= must be set to ON in both the table template and
each column assignment in order for multiple variables to use the same column template.
The FORMAT= suboption specifies a format for the column. The DYNAMIC=
suboption provides the value of the dynamic variable Colhd for the current column.
Notice that for the first column the column header is Country, and for the second
column, which uses the same column template, the column header is Year.
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
);
Write the data values to the data component. The _ODS_ option and the PUT
statement write the data values for all columns to the data component. The RUN
statement executes the DATA step.
put _ods_;
run;
Stop the creation of the HTML output The ODS HTML statement closes the HTML
destination and all the files that are associated with it. Close the destination so that you
can view the output with a browser. The ODS HTML statement opens the HTML
destination to return ODS to its default setup.
528
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
ods html close;
ods html;
HTML Output: Specifying Colors and Fonts with User-Defined Attributes
Use the fonts to confirm that SAS titles use the SystemTitle style element, that column
headings use the Header style element, that the footer uses the Table-Footer style
element, and that the contents of both character and numeric cells use the CellContents
style element. Use the width of the table border and the spacing between cells to confirm
that the table itself is produced with the Table style element.
Output 15.1 HTML Output
Example 2: Using User-Defined Attributes
Features:
DEFINE STYLE statement:
STYLE statement with user-defined attributes
DEFINE TABLE statement
CLASSLEVELS= table attribute
DYNAMIC statement
MVAR statement
DEFINE COLUMN statement
Example 2: Using User-Defined Attributes
529
BLANK_DUPS=
GENERIC=
HEADER=
STYLE=
DEFINE FOOTER statement:
TEXT statement
Other features:
Data set:
Format:
Other ODS features:
ODS HTML statement
FILE statement with ODS= option
PUT statement with _ODS_ argument
Grain_Production
$CNTRY.
Program 1: Details
This example creates a style that is equivalent to the style that “Example 1: Creating a
Stand-Alone Style” on page 521 creates. However, this style uses user-defined attributes
to specify colors and fonts. This technique makes it possible to easily make changes in
multiple places in the output.
Program 1: Creating a Custom Style with User-Defined Style Attributes
proc template;
define style newstyle2;
style fonts /
"cellfont"=("arial, helvetica", 4, medium roman)
"headingfont"=("arial, helvetica", 5, bold roman)
"titlefont"=("arial, helvetica", 6, bold italic);
style colors /
"light"=white
"medium"=cxaaaaff
"dark"=cx0000ff
"bright"=red;
style cellcontents /
backgroundcolor=colors("dark")
color=colors("light")
font=fonts("cellfont");
style header /
backgroundcolor=colors("medium")
color=colors("dark")
font=fonts("headingfont");
style systemtitle /
backgroundcolor=colors("light")
color=colors("bright")
font=fonts("titlefont");
style footer from systemtitle /
fontsize=3;
style table /
borderspacing=5
borderwidth=10;
end;
run;
530
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
proc template;
define table table1;
mvar sysdate9;
dynamic colhd;
classlevels=on;
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end;
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end;
define footer table_footer;
text "Prepared on" sysdate9;
end;
end;
run;
ods html body="newstyle2-body.htm"
style=newstyle2;
title "Leading Grain Producers";
title2 "in 1996";
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
file print ods=(
template="table1"
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
);
put _ods_;
run;
ods html close;
ods html;
Program Description
Create the style NewStyle2. The PROC TEMPLATE statement starts the TEMPLATE
procedure. The DEFINE STYLE statement creates a new style called NewStyle2. This
STYLE statement defines the style element Fonts. This style element consists of three
Example 2: Using User-Defined Attributes
531
user-defined attributes: CellFont, HeadingFont, and TitleFont. Each of these attributes
describes a font. This style specifies the fontfamily, fontsize, fontweight, and the
fontstyle for each of the three attributes. The font and fontwidth attributes are still
defined by the default style.
proc template;
define style newstyle2;
style fonts /
"cellfont"=("arial, helvetica", 4, medium roman)
"headingfont"=("arial, helvetica", 5, bold roman)
"titlefont"=("arial, helvetica", 6, bold italic);
Create the style element Colors. This STYLE statement defines the style element
Colors. This style element consists of four user-defined attributes: light, medium, dark,
and bright. The values for medium and dark are RGB values equivalent to very light
blue and blue.
style colors /
"light"=white
"medium"=cxaaaaff
"dark"=cx0000ff
"bright"=red;
Create the three style elements CellContents, Header, and SystemTitle. Create the
style element Footer using inheritance. The style attributes are defined in terms of the
user-defined attributes that were created earlier in the style. For example, the foreground
color in CellContents is set to colors("light"). Looking at the template of Colors, you can
see that this is white. However, by setting the colors up in a style element with userdefined attributes, you can change the color of everything that uses a particular color by
changing a single value in the style element Colors.
style cellcontents /
backgroundcolor=colors("dark")
color=colors("light")
font=fonts("cellfont");
style header /
backgroundcolor=colors("medium")
color=colors("dark")
font=fonts("headingfont");
style systemtitle /
backgroundcolor=colors("light")
color=colors("bright")
font=fonts("titlefont");
style footer from systemtitle /
fontsize=3;
style table /
borderspacing=5
borderwidth=10;
End the style. The END statement ends the style. The RUN statement executes PROC
TEMPLATE.
end;
run;
Create the table template Table1. The PROC TEMPLATE statement starts the
TEMPLATE procedure. The DEFINE TABLE statement creates a new table template
called Table1.
532
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
proc template;
define table table1;
Specify the symbol that references one macro variable. The MVAR statement
defines a symbol, Sysdate9, that references a macro variable. ODS will use the value of
this macro variable as a string. References to the macro variable are resolved when ODS
binds the table template to the data component to produce an output object. SYSDATE9
is an automatic macro variable whose value is always available.
mvar sysdate9;
Specify the symbol that references a value to be supplied by the data component.
The DYNAMIC statement defines a symbol, Colhd, that references a value that the data
component supplies when ODS binds the template and the data component to produce an
output object. The values for Colhd are provided in the FILE statement in the DATA step
that appears later in the program. Using dynamic column headings gives you more
flexibility than hardcoding the headers in the table template does.
dynamic colhd;
Control the repetition of values that do not change from one row to the next row.
The CLASSLEVELS= attribute suppresses the display of the value in a column that is
marked with BLANK_DUPS=ON if the value changes in a previous column that is also
marked with BLANK_DUPS=ON. Because BLANK_DUPS= is set in a generic column,
set this attribute as well.
classlevels=on;
Create the column Char_Var. This DEFINE statement and its attributes create the
column template Char_Var. GENERIC= specifies that multiple variables can use the
same column template. BLANK_DUPS= suppresses the display of the value in the
column if it does not change from one row to the next (and, because
CLASSLEVELS=ON for the table, if no values in preceding columns that are marked
with BLANK_DUPS=ON changes). HEADER= specifies that the header for the column
will be the text of the dynamic variable Colhd, whose value will be set by the data
component. The STYLE= attribute specifies that the style element for this column
template is CellContents.The END statement ends the template.
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end;
Create the column Num_Var. This DEFINE statement and its attributes create the
column template Num_Var. GENERIC= specifies that multiple variables can use the
same column template. HEADER= specifies that the header for the column will be the
text of the dynamic variable Colhd, whose value will be set by the data component. The
STYLE= attribute specifies that the style element for this column template is
CellContents.The END statement ends the template.
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end;
Example 2: Using User-Defined Attributes
533
Create the footer element Table_Footer. The DEFINE statement and its substatement
define the table element Table_Footer. The FOOTER argument declares Table_Footer as
a footer. The TEXT statement specifies the text of the footer. When ODS binds the data
component to the table template (in the DATA step that follows), it will resolve the value
of the macro variable SYSDATE9.
define footer table_footer;
text "Prepared on" sysdate9;
end;
End the table template. This END statement ends the table template. The RUN
statement executes the PROC TEMPLATE step.
end;
run;
Create HTML output and specify the location for storing the HTML output. Specify
the style to use for the output. The HTML destination is open by default. However, to
specify a style, you must use the ODS HTML statement with the STYLE= open
specified. The STYLE= option tells ODS to use NewStyle2 as the style when it formats
the output.
ods html body="newstyle2-body.htm"
style=newstyle2;
Specify the titles for the report. The TITLE statements provide two titles for the
output.
title "Leading Grain Producers";
title2 "in 1996";
Create the data component. This DATA step does not create a data set. Instead, it
creates a data component and, eventually, an output object. The SET statement reads the
data set Grain_Production. The WHERE statement subsets the data set so that the output
object contains information only for rice and corn production in 1996.
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
Route the DATA step results to ODS and use the Table1 table template. The
combination of the fileref PRINT and the ODS option in the FILE statement routes the
results of the DATA step to ODS. The TEMPLATE= suboption tells ODS to use the
table template named Table1, which was previously created with PROC TEMPLATE.
For more information about using the DATA step with ODS, see “Using ODS with the
DATA Step” in SAS Output Delivery System: User's Guide.
file print ods=(
template="table1"
Specify the column template to use for each variable. The COLUMNS= suboption
places DATA step variables into columns that are defined in the table template. For
example, the first column-specification specifies that the first column of the output
object contains the values of the variable COUNTRY and that it uses the column
template named Char_Var. GENERIC= must be set to ON in both the table template and
each column assignment in order for multiple variables to use the same column template.
The FORMAT= suboption specifies a format for the column. The DYNAMIC=
534
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
suboption provides the value of the dynamic variable Colhd for the current column.
Notice that for the first column the column header is Country, and for the second
column, which uses the same column template, the column header is Year.
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
);
Write the data values to the data component. The _ODS_ option and the PUT
statement write the data values for all columns to the data component. The RUN
statement executes the DATA step.
put _ods_;
run;
Close the HTML destination. The ODS HTML statement closes the HTML destination
and all the files that are associated with it. The ODS HTML statement opens the HTML
destination to return ODS to its default setup.
ods html close;
ods html;
HTML Output
This HTML output is identical to the output in the section “HTML Output: Specifying
Colors and Fonts with User-Defined Attributes” on page 528, which was produced with
a style that used predefined style attributes. You can use the fonts to confirm that SAS
titles use the SystemTitle style element, that column headings use the Header style
element, that the footer uses the Table-Footer style element, and that the contents of both
character and numeric cells use the CellContents style element. Use the width of the
table border and the spacing between cells to confirm that the table produced with the
Table style element.
Example 2: Using User-Defined Attributes
535
Output 15.2 HTML Output
Program 2: Details
In the program “Example 1: Creating a Stand-Alone Style” on page 521, to change the
color scheme so that the blues are replaced by pink and red, change each occurrence of
"blue" and "very light blue." In this program, because colors are defined as user-defined
attributes, make the change only once.
To make the color scheme change, change only this section of code:
The following is the original portion on code from “Program 1: Creating a Custom Style
with User-Defined Style Attributes” on page 529.
style colors /
"light"=white
"medium"=cxaaaaff
"dark"=cx0000ff
"bright"=red;
Change the attributes as follows:
style colors /
"light"=white
"medium"=pink
536
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
"dark"=red
"bright"=red;
Similarly, to change the font in any style element that uses CellFont, change this
section of code:
"cellfont"=("arial, helvetica", 4, medium roman)
Here is one example of how to change the code:
"cellfont"=("courier, arial, helvetica", 4, medium roman)
HTML Output: Changing Colors and Fonts of User-Defined Attributes
This HTML output shows the results of running the same program with these changes.
The font in the cells is now Courier. This change occurs in multiple places even though
you made only one change to the code for the font.
Output 15.3
HTML Output with Changed Colors and Fonts
Example 3: Modifying the Default Style with the CLASS Statement
537
Example 3: Modifying the Default Style with the CLASS Statement
Features:
DEFINE STYLE statement
User-defined attributes
BACKGROUNDCOLOR= style attribute
BORDERWIDTH= style attribute
CELLPADDING= style attribute
BORDERSPACING= style attribute
COLOR= style attribute
FONT= style attribute
FONTSTYLE= style attribute
FRAME= style attribute
POSTHTML= style attribute
RULES= style attribute
VISITEDLINKCOLOR= style attribute
CLASS statement
PARENT= statement
Other features:
Data set:
Format:
Other ODS features
ODS HTML statement: STYLE= option
ODS PATH statement
Energy
DIVFMT. and USETYPE.
Details
When you are working with styles, you are more likely to modify a SAS style than to
write a completely new style. This example makes changes to the default style for the
HTML destination. The new style affects both the contents file and the body file in the
HTML output. In the contents file, the modified style makes changes to the following:
•
the text of the header and the text that identifies the procedure that produced the
output
•
the colors for some parts of the text
•
the font size of some parts of the text
•
the spacing in the list of entries in the table of contents
In the body file, the modified style makes changes to the following:
•
two of the colors in the color list. Style1 of these colors is the foreground color for
the table of contents, the BY line, and column headings. The other is the foreground
of many parts of the body file, including SAS titles and footnotes.
•
the font size for titles and footnotes.
•
the font style for headers.
•
the presentation of the data in the table by changing attributes such as border
spacing, rules, and border width.
When you modify a style element in a new style that has a like-named style element in
the parent style, you must use the CLASS statement or the STYLE statement with the
538
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
FROM option specified. This example uses the CLASS statement to produce a shorter,
easier to read program.
Program
proc template;
define style customdefault;
parent=styles.htmlblue;
class contents /
background=cxffffcc;
class contenttitle /
background=cxffffcc;
class
data /
background=cxcccccc;
style IndexProcName from Index /
backgroundcolor = cxffffcc;
class colors /
'link2' = cx0000FF
'link1' = cx800080
'docbg' = cx99ccff
'contentbg' = cxFAFBFE
'systitlebg' = cx99ccff
'titlebg' = cxFAFBFE
'proctitlebg' = cxFAFBFE
'headerbg' = cxEDF2F9
'captionbg' = cxFAFBFE
'captionfg' = cx112277
'bylinebg' = cx99ccff
'notebg' = cxFAFBFE
'tablebg' = cxFAFBFE
'batchbg' = cxFAFBFE
'systitlefg' = cx112277
'titlefg' = cx112277
'proctitlefg' = cx112277
'bylinefg' = cx112277
'notefg' = cx112277;
class Header
/
bordercolor = cxEDF2F9
backgroundcolor = cxEDF2F9
color = cx112277;
class text /
"prefix1" = "PROC "
"suffix1" = ":"
"Content Title" = "Contents"
"Pages Title" = "Pages"
;
end;
run;
filename odsout ".";
Example 3: Modifying the Default Style with the CLASS Statement
539
ods html close;
ods html path=odsout body="customdefaultstyle-body.htm"
contents="customdefaultstyle-content.htm"
frame="customdefaultstyle-frame.htm"
style=customdefault;
title "MSRP by Make and Model";
title2 "(6 Cylinders Only)";
proc print data=sashelp.cars noobs;
var make model cylinders MSRP;
format MSRP dollar10.2;
by make;
where cylinders=6;
run;
ods html close;
ods html;
Program Description
Create the style CustomDefault. The PROC TEMPLATE statement starts the
TEMPLATE procedure. The DEFINE STYLE statement creates a new style called
CustomDefault.
proc template;
define style customdefault;
Specify the parent style from which the CustomDefault style inherits its attributes.
The PARENT= attribute specifies Styles.HTMLBlue as the style from which the current
style inherits. All the style elements, attributes, and statements that are specified in the
parent's style template are used in the child style template unless the child style template
overrides them.
parent=styles.htmlblue;
Customize the contents style elements and the data cells. By changing the
BACKGROUND= style attribute in the style elements Contents, ContentTitle, and
IndexProcName, the background of the contents becomes yellow.
class contents /
background=cxffffcc;
class contenttitle /
background=cxffffcc;
class
data /
background=cxcccccc;
style IndexProcName from Index /
backgroundcolor = cxffffcc;
Change the attributes of the style element Colors This CLASS statement adds to the
child style the style element Colors, which also exists in the parent style (HTMLBlue).
The CLASS statement adds all of the style attributes that are in the original instance of
the Colorsstyle element to the new instance of Colors, except for those that are
overridden by the new instance of Colors. By using the CLASS statement, you do not
540
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
need to specify the FROM option. If you did not use the CLASS statement or the FROM
option, then the attributes from the original instance of Colors would not be added to the
new instance of Colors. The Colors style element in CustomDefault would contain only
the style statements that it specifically specifies. All style elements that use the userdefined attributes that Colors defines (fgB2, fgB1, and so on) use the style attributes that
are specified in Custom.Default, not the ones that are specified in Styles.HTMLBlue.
Therefore, if you change a color here, then you change every occurrence of the color in
the HTML output. This CLASS statement changes the values of three of the user-defined
style attributes: Docbg=, Systitlebg=, and Bylinebg=.
class colors /
'link2' = cx0000FF
'link1' = cx800080
'docbg' = cx99ccff
'contentbg' = cxFAFBFE
'systitlebg' = cx99ccff
'titlebg' = cxFAFBFE
'proctitlebg' = cxFAFBFE
'headerbg' = cxEDF2F9
'captionbg' = cxFAFBFE
'captionfg' = cx112277
'bylinebg' = cx99ccff
'notebg' = cxFAFBFE
'tablebg' = cxFAFBFE
'batchbg' = cxFAFBFE
'systitlefg' = cx112277
'titlefg' = cx112277
'proctitlefg' = cx112277
'bylinefg' = cx112277
'notefg' = cx112277;
Change the style attributes in the style element Header. This STYLE statement adds
the italic font style to the attributes that Header inherits from the Header style element
that is defined in the parent style. You could have also specified the STYLE statement
with the FROM option specified. Because this change occurs after the initial merge of
the two styles, the change will effect HeaderFixed and the other style elements that
inherit from Header in the parent style.
In the default style, the background color for the BY line differs from the background
color for the document, so it appears as a gray stripe in the default output. In this
customized style, the stripe disappears because the background color for the BY line and
the document are the same.
class Header
/
bordercolor = cxEDF2F9
backgroundcolor = cxEDF2F9
color = cx112277;
Customize the text used in parts of the output. In the customized style, the text that
identifies the output reads "1. PROC PRINT". The heading that appears at the top of the
contents file has been changed from "Table of Contents" to "Contents", and the heading
at the top of the table of pages has been changed from "Table of Pages" to "Pages". The
banners have been changed to use mixed case. (Note that neither these banners nor the
table of pages is visible in the HTML output from this example, but the attributes are
included so that you can use the style in a variety of circumstances.)
This CLASS statement alters the text that is used in parts of the HTML output. In the
contents file, the default style uses "The" as the value of prefix1 and "Procedure" as the
Example 3: Modifying the Default Style with the CLASS Statement
541
value of suffix1. Thus, in HTML output that uses the default style, the output from
PROC PRINT is identified by "1. The PRINT Procedure".
class text /
"prefix1" = "PROC "
"suffix1" = ":"
"Content Title" = "Contents"
"Pages Title" = "Pages"
;
Stop the creation of the customized style. The END statement ends the style. The
RUN statement executes the PROC TEMPLATE step.
end;
run;
Create a file reference for the output. The current working directory is specified in this
example.
filename odsout ".";
ods html close;
Create the HTML output and specify the style to use for the output. The ODS HTML
statement opens the HTML destination and creates HTML output. The output from
PROC PRINT is sent to the body file. FRAME= and CONTENTS= create a frame that
includes a table of contents that links to the contents of the body file. The body file also
appears in the frame. The STYLE= option tells ODS to use CustomDefault as the style
when it formats the output.
ods html path=odsout body="customdefaultstyle-body.htm"
contents="customdefaultstyle-content.htm"
frame="customdefaultstyle-frame.htm"
style=customdefault;
Specify the titles and footnote for the report. The TITLE and FOOTNOTE statements
provide two titles and a footnote for the output.
title "MSRP by Make and Model";
title2 "(6 Cylinders Only)";
Create the PRINT procedure output. This PROC PRINT step is the same one that was
used with the default style in the previous program.
proc print data=sashelp.cars noobs;
var make model cylinders MSRP;
format MSRP dollar10.2;
by make;
where cylinders=6;
run;
Close the HTML destination. The ODS HTML statement closes the HTML destination
and all the files that are associated with it. The ODS HTML statement opens the HTML
destination to return ODS to its default setup.
ods html close;
ods html;
542
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
HTML Output
Output 15.4
HTML Output from PROC PRINT Using the Default Style
Example 4: Defining a Table and Graph Style
Output 15.5 HTML Output from PROC PRINT with the Customized Style
Example 4: Defining a Table and Graph Style
Features:
DEFINE STYLE statement style attributes:
User-defined attributes
Style attribute: BACKGROUNDCOLOR=
Style attribute: BORDERCOLORDARK=
Style attribute: BORDERCOLORLIGHT=
Style attribute: BORDERWIDTH=
Style attribute: CELLPADDING=
Style attribute: BORDERSPACING=
Style attribute: DROPSHADOW=
Style attribute: ENDCOLOR=
Style attribute: FONT=
Style attribute: COLOR=
Style attribute: FRAME=
Style attribute: GRADIENTDIRECTION=
Style attribute: IMAGE=
Style attribute: TEXTALIGN=
Style attribute: style attribute:WIDTH=
Style attribute: RULES=
Style attribute: TRANSPARENCY=
Style attribute: VERTICALALIGN=
DEFINE STYLE statement style elements:
Style element: GraphAxisLines
Style element: GraphBackground
Style element: GraphBorderLines
543
544
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Style element: GraphCharts
Style element: GraphLabelText
Style element: GraphWalls
PARENT= statement
STYLE statement
Details
When you are working with styles, you are more likely to modify a SAS style than to
write a completely new style. This example shows you how the SAS defined graph style,
Science, was created.
Note: Remember that when a STYLE statement creates a style element in the new style,
only style elements that explicitly inherit from that style element in the new style
inherit the change. When a STYLE statement creates a style element in the new
style, all style elements that inherit from that element inherit the definition that is in
the new style, so the change appears in all children of the element.
Program
filename odsout ".";
ods html close;
options nodate;
proc template;
define style Styles.Science;
parent = styles.default;
style fonts /
"TitleFont2" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"TitleFont" = ("Verdana, Verdana, Helvetica, sans-serif",18pt,Bold)
"StrongFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"EmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",10pt,
Italic)
"FixedEmphasisFont" = ("Courier New", Courier, monospace",10pt,
Italic)
"FixedStrongFont" = ("Courier New", Courier, monospace",10pt,Bold)
"FixedHeadingFont" = ("Courier New", Courier, monospace",10pt)
"BatchFixedFont" = ("Courier New", Courier, monospace",10pt)
"FixedFont" = ("Courier New", Courier, monospace",10pt)
"headingEmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",14
pt,Bold Italic)
"headingFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"docFont" = ("Verdana, Verdana, Helvetica, sans-serif",8pt,Bold);
style GraphFonts from _self_/
"GraphValueFont" = ("Verdana",10pt)
"GraphLabelFont" = ("Verdana",14pt,Bold);
style colors /
"headerfgemph" = cx31035E
"headerbgemph" = cxFFFFFF
"headerfgstrong" = cx31035E
"headerbgstrong" = cxFFFFFF
"headerfg" = cx31035E
"headerbg" = cxFFFFFF
Example 4: Defining a Table and Graph Style
"datafgemph" = cx31035E
"databgemph" = cxDFECE1
"datafgstrong" = cx31035E
"databgstrong" = cxDFECE1
"datafg" = cx31035E
"databg" = cxDFECE1
"batchfg" = cx31035E
"batchbg" = cxDFECE1
"tablebg" = cx31035E
"tableborderdark" = cx909090
"tableborderlight" = cxFFFFFF
"tableborder" = cxFFFFFF
"notefg" = cx31035E
"notebg" = cxDFECE1
"bylinefg" = cx31035E
"bylinebg" = cxDFECE1
"captionfg" = cx31035E
"captionbg" = cxDFECE1
"proctitlefg" = cx31035E
"proctitlebg" = cxDFECE1
"titlefg" = cx31035E
"titlebg" = cxDFECE1
"systitlefg" = cx31035E
"systitlebg" = cxDFECE1
"Conentryfg" = cx31035E
"Confolderfg" = cx31035E
"Contitlefg" = cx31035E
"link2" = cx800080
"link1" = cx0000FF
"contentfg" = cx31035E
"contentbg" = cxDFECE1
"docfg" = cx31035E
"docbg" = cxDFECE1;
style GraphColors /
"gconramp3cend" = cxDD6060
"gconramp3cneutral" = cxFFFFFF
"gconramp3cstart" = cx6497EB
"gramp3cend" = cxBED8D3
"gramp3cneutral" = cxFFFFFF
"gramp3cstart" = cxAAB6DF
"gconramp2cend" = cx6497EB
"gconramp2cstart" = cxFFFFFF
"gramp2cend" = cx548287
"gramp2cstart" = cxFFFFFF
"gtext" = CX31035E
"glabel" = CX31035E
"gborderlines" = CX31035E
"goutlines" = CX31035E
"ggrid" = CX31035E
"gaxis" = CX31035E
"gshadow" = CX707671
"glegend" = CXFFFFFF
"gfloor" = CXDFECE1
"gwalls" = CXFFFFFF
"gcdata12" = cxFF667F
545
546
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
"gcdata11" = cx5050CC
"gcdata10" = cxE100BF
"gcdata9" = cx007F00
"gcdata8" = cxB99600
"gcdata7" = cx7F7F7F
"gcdata6" = cx984EA3
"gcdata5" = cx4DAF4A
"gcdata4" = cxA65628
"gcdata3" = cxFF7F00
"gcdata2" = cx377DB8
"gcdata1" = cxE31A1C
"gdata12" = CX4A5573
"gdata11" = CXCFB1E2
"gdata10" = CX8E829D
"gdata9" = CX2952B1
"gdata8" = CXAAB6DF
"gdata7" = CX6771C2
"gdata6" = CXBED8D3
"gdata5" = CX8B65A3
"gdata4" = CXBCD3AB
"gdata3" = CX548287
"gdata2" = CX7DC1C9
"gdata1" = CX9580D5;
style Table from Output /
cellpadding = 5
borderspacing = 2
bordercolordark = colors("tableborderdark")
bordercolorlight = colors("tableborderlight")
borderwidth = 2;
style GraphLabelText from GraphLabelText
"Label attributes" /
dropshadow = on;
style GraphBackground
"Graph backgroundcolor attributes" /
backgroundcolor = colors("docbg")
image = "!sasroot\common\textures\Science.gif"
textalign = L
verticalalign = B;
style GraphAxisLines from GraphAxisLines
"Axis line attributes" /
width = 2;
style GraphBorderLines from GraphBorderLines
"Border attributes" /
width = 2
color=colors("gaxis");
style GraphCharts from GraphCharts
"Chart Attributes" /
transparency = 0.25;
style GraphWalls from GraphWalls
"Wall Attributes" /
gradientdirection = "Xaxis"
endcolor = colors("gwalls")
Example 4: Defining a Table and Graph Style
547
transparency = 1.0;
end;
run;
Program Description
Create a file reference for the output and set the SAS system options. The current
working directory is specified in this example.
filename odsout ".";
ods html close;
options nodate;
Create the style Science. The PROC TEMPLATE statement starts the TEMPLATE
procedure. The DEFINE STYLE statement creates a new style in the Styles item store
called Science.
proc template;
define style Styles.Science;
Specify the parent style from which the Science style inherits its attributes. The
PARENT= attribute specifies Styles.Default as the style that the current style inherits
from. All the style elements that are specified in the parent's style are used in the current
style unless the current style overrides them.
parent = styles.default;
Change the style attributes of the Fonts style element in the parent style by
replacing Fonts in the child style Science. The STYLE statement adds to the child
style the style element Fonts, which also exists in the parent style. All style elements that
use the user-defined attributes that Fonts defines use the attributes that are specified in
the STYLE statement, not the ones that are specified in the Styles.Default style. Because
no FROM option is specified, the instance of Fonts in the Science style completely
replaces the instance from the Styles.Default style. No style element inheritance occurs.
style fonts /
"TitleFont2" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"TitleFont" = ("Verdana, Verdana, Helvetica, sans-serif",18pt,Bold)
"StrongFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"EmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",10pt,
Italic)
"FixedEmphasisFont" = ("Courier New", Courier, monospace",10pt,
Italic)
"FixedStrongFont" = ("Courier New", Courier, monospace",10pt,Bold)
"FixedHeadingFont" = ("Courier New", Courier, monospace",10pt)
"BatchFixedFont" = ("Courier New", Courier, monospace",10pt)
"FixedFont" = ("Courier New", Courier, monospace",10pt)
"headingEmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",14
pt,Bold Italic)
"headingFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
"docFont" = ("Verdana, Verdana, Helvetica, sans-serif",8pt,Bold);
Change the attributes for graph style specific fonts. The STYLE statement adds to
the child styles the style element GraphFonts, which also exists in the parent style. All
the style elements that use the user-defined attributes that GraphFonts defines use the
attributes specified in the STYLE statement, not those specified in the Styles.Default
548
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
style. Because the FROM option is specified, GraphFonts in the Science style will
inherit all of the style attributes from GraphFonts in Styles.Default, except those that are
specifically specified in Science.
Instead of the one that is used in this program, you could have used the following
STYLE statement : style graphfaonts from graphfonts;
style GraphFonts from _self_/
"GraphValueFont" = ("Verdana",10pt)
"GraphLabelFont" = ("Verdana",14pt,Bold);
Change the style attributes of the Colors style element in the parent style by
replacing Colors in the style Science. The STYLE statement adds to the child styles
the style element Colors, which also exists in the parent style. All style elements that use
the user-defined attributes that Colors defines use the attributes that are specified in the
STYLE statement, not the ones that are specified in the Styles.Default style. Because no
FROM option is specified, the instance of Colors in the Science style completely
replaces the instance from the Styles.Default style. No style element inheritance occurs.
style colors /
"headerfgemph" = cx31035E
"headerbgemph" = cxFFFFFF
"headerfgstrong" = cx31035E
"headerbgstrong" = cxFFFFFF
"headerfg" = cx31035E
"headerbg" = cxFFFFFF
"datafgemph" = cx31035E
"databgemph" = cxDFECE1
"datafgstrong" = cx31035E
"databgstrong" = cxDFECE1
"datafg" = cx31035E
"databg" = cxDFECE1
"batchfg" = cx31035E
"batchbg" = cxDFECE1
"tablebg" = cx31035E
"tableborderdark" = cx909090
"tableborderlight" = cxFFFFFF
"tableborder" = cxFFFFFF
"notefg" = cx31035E
"notebg" = cxDFECE1
"bylinefg" = cx31035E
"bylinebg" = cxDFECE1
"captionfg" = cx31035E
"captionbg" = cxDFECE1
"proctitlefg" = cx31035E
"proctitlebg" = cxDFECE1
"titlefg" = cx31035E
"titlebg" = cxDFECE1
"systitlefg" = cx31035E
"systitlebg" = cxDFECE1
"Conentryfg" = cx31035E
"Confolderfg" = cx31035E
"Contitlefg" = cx31035E
"link2" = cx800080
"link1" = cx0000FF
"contentfg" = cx31035E
"contentbg" = cxDFECE1
Example 4: Defining a Table and Graph Style
549
"docfg" = cx31035E
"docbg" = cxDFECE1;
Change the style attributes for the GraphColors style element. The STYLE
statement adds to the child styles the style element GraphColors, which also exists in the
parent style. All of the style elements that use the user-defined attributes that
GraphColors define use the attributes that are specified in the Science style, not the
attributes that are specified in the Styles.Default style. Because no FROM option is
specified, the instance of GraphColors in the Science style completely replaces the
instance from the Styles.Default style. No style element inheritance occurs.
style GraphColors /
"gconramp3cend" = cxDD6060
"gconramp3cneutral" = cxFFFFFF
"gconramp3cstart" = cx6497EB
"gramp3cend" = cxBED8D3
"gramp3cneutral" = cxFFFFFF
"gramp3cstart" = cxAAB6DF
"gconramp2cend" = cx6497EB
"gconramp2cstart" = cxFFFFFF
"gramp2cend" = cx548287
"gramp2cstart" = cxFFFFFF
"gtext" = CX31035E
"glabel" = CX31035E
"gborderlines" = CX31035E
"goutlines" = CX31035E
"ggrid" = CX31035E
"gaxis" = CX31035E
"gshadow" = CX707671
"glegend" = CXFFFFFF
"gfloor" = CXDFECE1
"gwalls" = CXFFFFFF
"gcdata12" = cxFF667F
"gcdata11" = cx5050CC
"gcdata10" = cxE100BF
"gcdata9" = cx007F00
"gcdata8" = cxB99600
"gcdata7" = cx7F7F7F
"gcdata6" = cx984EA3
"gcdata5" = cx4DAF4A
"gcdata4" = cxA65628
"gcdata3" = cxFF7F00
"gcdata2" = cx377DB8
"gcdata1" = cxE31A1C
"gdata12" = CX4A5573
"gdata11" = CXCFB1E2
"gdata10" = CX8E829D
"gdata9" = CX2952B1
"gdata8" = CXAAB6DF
"gdata7" = CX6771C2
"gdata6" = CXBED8D3
"gdata5" = CX8B65A3
"gdata4" = CXBCD3AB
"gdata3" = CX548287
"gdata2" = CX7DC1C9
"gdata1" = CX9580D5;
550
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Specify attributes for the table. This STYLE statement is applied to tables. Although
these specific attributes are set with this STYLE statement, all other table attributes are
inherited from the style elements that are defined in the parent styles.
style Table from Output /
cellpadding = 5
borderspacing = 2
bordercolordark = colors("tableborderdark")
bordercolorlight = colors("tableborderlight")
borderwidth = 2;
Specify attributes for the GraphLabelText element. This STYLE statement is applied
to the graph's label text. A DROPSHADOW attribute is applied.
style GraphLabelText from GraphLabelText
"Label attributes" /
dropshadow = on;
Replace the background for the Graph. This STYLE statement is applied to the
graph's background. DOCBG is specified as the background colors, with SCIENCE.GIF
justified to the left and bottom as the background image.
style GraphBackground
"Graph backgroundcolor attributes" /
backgroundcolor = colors("docbg")
image = "!sasroot\common\textures\Science.gif"
textalign = L
verticalalign = B;
Specify attributes for the GraphAxisLines element. This STYLE statement is applied
to the graph's axis line. The WIDTH is 2.
style GraphAxisLines from GraphAxisLines
"Axis line attributes" /
width = 2;
Specify attributes for the GraphBorderLines element. This STYLE statement is
applied to the border lines in the graph. The width is 2 and the foreground color defined
in Gaxis, which is CX31035E, is used.
style GraphBorderLines from GraphBorderLines
"Border attributes" /
width = 2
color=colors("gaxis");
Specify attributes for the GraphCharts element. This STYLE statement is applied to
the graph's chart. The data elements of the graph have a TRANSPARENCY of 25%.
style GraphCharts from GraphCharts
"Chart Attributes" /
transparency = 0.25;
Specify attributes for the GraphWalls element. This STYLE statement is applied to
the walls inside the graph's axes. The GRADIENTDIRECTION is set to Xaxis, meaning
that the gradient is going left to right. The ENDCOLOR (CXFFFFFF) is defined in
Gwalls and is the final color used with the gradient. The data elements of the graph have
a TRANSPARENCY of 100%. Because a STARTCOLOR is not specified, the beginning
of the gradient is completely transparent.
Example 5: Defining Multiple Style Elements in One STYLE Statement
551
style GraphWalls from GraphWalls
"Wall Attributes" /
gradientdirection = "Xaxis"
endcolor = colors("gwalls")
transparency = 1.0;
Add the style to the specified catalog. The END statement ends the style. The RUN
statement executes the PROC TEMPLATE step.
end;
run;
Example 5: Defining Multiple Style Elements in One STYLE Statement
Features:
DEFINE STYLE statement
FROM option
Style attribute: BACKGROUNDCOLOR=
Style attribute: BORDERWIDTH=
Style attribute: BORDERSPACING=
Style attribute: FONTFAMILY=
Style attribute: FONTSIZE=
Style attribute: FONTSTYLE=
Style attribute: FONTWEIGHT=
Style attribute: COLOR=
CLASS statement
Other features:
Data set:
Format:
Other ODS features
ODS HTML statement
FILE statement with ODS= option
PUT statement with _ODS_ argument
Grain_Production
$CNTRY.
Details
This example creates a style that defines multiple style elements concurrently. When
style element names are specified multiple times, all of the attributes from all instances
of that name are collected to create the final set of style attributes. Defining multiple
style elements in one STYLE statement makes it possible to create shorter, easier to read
programs and to make changes to style attributes in a single STYLE statement rather
than in many STYLE statements.
For example, if you wanted to add the style element BorderColor=black to the style
elements CellContents, Header, and SystemTitle in the program below, you could add it
once, to the first STYLE statement, instead of adding it three times, to each individual
STYLE statement.
Program
filename odsout ".";
ods html close;
options nodate;
proc template;
552
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
define style Styles.NewStyle;
style cellcontents, header, systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white;
class header /
backgroundcolor=very light blue;
class systemtitle /
backgroundcolor=white
color=red
fontstyle=italic
fontsize=6;
style footer from systemtitle /
fontsize=3;
class table /
borderspacing=5
borderwidth=10;
end;
run;
ods html path=odsout file="newstyle-body.htm"
style=newstyle;
title "Leading Grain Producers";
title2 "in 1996";
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
file print ods=(
template="table1"
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
);
put _ods_;
run;
ods html close;
ods html;
proc template;
delete Styles.NewStyle;
run;
Example 5: Defining Multiple Style Elements in One STYLE Statement
553
Program Description
Create a file reference for the output and set the SAS system options. The current
working directory is specified in this example.
filename odsout ".";
ods html close;
options nodate;
Create a new style Styles.NewStyle. The PROC TEMPLATE statement starts the
TEMPLATE procedure. The DEFINE STYLE statement creates a new style called
Styles.NewStyle.
proc template;
define style Styles.NewStyle;
Create the CellContents, Header, and SystemTitle style elements. This STYLE
statement defines three style elements: CellContents, Header, and SystemTitle. They are
all composed of the style attributes that appear in the STYLE statement. The
FONTFAMILY= attribute tells the browser to use the Arial font if it is available, and to
look for the Helvetica font if Arial is not available. These three style elements use a
color scheme of a white foreground on a blue background, and the font for all three is
medium roman with a size of five.
style cellcontents, header, systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white;
Modify the Header style element. The STYLE statement with the FROM option
specified creates the new instance of Header from the previous instance of Header, but
changes the background color from white to very light blue. By default, ODS uses
Header to produce both spanning headers and column headings.
class header /
backgroundcolor=very light blue;
Modify the SystemTitle style element. By default, ODS uses SystemTitle to produce
SAS titles.
class systemtitle /
backgroundcolor=white
color=red
fontstyle=italic
fontsize=6;
Create the style element Footer. This STYLE statement creates the style element
Footer. This style element inherits all the attributes of SystemTitle. However, the font
size that it inherits is overwritten by the FONTSIZE= attribute in its template.
style footer from systemtitle /
fontsize=3;
Create the style element Table. This STYLE statement creates the style element Table.
By default, ODS uses this style element to display tables.
554
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
class table /
borderspacing=5
borderwidth=10;
end;
run;
Create HTML output and specify the location for storing the HTML output. Specify
the style to use for the output. The ODS HTML statement opens the HTML
destination and creates HTML output. It sends all output objects to the external file
NewStyle-Body in the current directory. The STYLE= option tells ODS to use
Styles.NewStyle as the style when it formats the output.
ods html path=odsout file="newstyle-body.htm"
style=newstyle;
Specify the titles for the report. The TITLE statements provide two titles for the
output.
title "Leading Grain Producers";
title2 "in 1996";
Create the data component. This DATA step does not create a data set. Instead, it
creates a data component and, eventually, an output object. The SET statement reads the
data set Grain_Production. The WHERE statement subsets the data set so that the output
object contains information only for rice and corn production in 1996.
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996;
Route the DATA step results to ODS and use the Table1 table template. The
combination of the fileref PRINT and the ODS option in the FILE statement routes the
results of the DATA step to ODS. The TEMPLATE= suboption tells ODS to use the
table template named Table1, which was previously created with PROC TEMPLATE.
For more information about using the DATA step with ODS, see “Using ODS with the
DATA Step” in SAS Output Delivery System: User's Guide. For the program that creates
the table template Table1, see “Creating the Table1 Table Template” in SAS Output
Delivery System: User's Guide.
file print ods=(
template="table1"
Specify the column template to use for each variable. The COLUMNS= suboption
places DATA step variables into columns that are defined in the table template. For
example, the first column-specification specifies that the first column of the output
object contains the values of the variable COUNTRY and that it uses the column
template named Char_Var. GENERIC= must be set to ON in both the table template and
each column assignment in order for multiple variables to use the same column template.
The FORMAT= suboption specifies a format for the column. The DYNAMIC=
suboption provides the value of the dynamic variable Colhd for the current column.
Notice that for the first column the column header is Country, and for the second
column, which uses the same column template, the column header is Year.
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
Example 5: Defining Multiple Style Elements in One STYLE Statement
555
dynamic=(colhd="Kilotons"))
)
);
Write the data values to the data component. The _ODS_ option and the PUT
statement write the data values for all columns to the data component. The RUN
statement executes the DATA step.
put _ods_;
run;
Close the HTML destination. The ODS HTML statement closes the HTML destination
and all the files that are associated with it. Specify the ODS HTML statement again to
return ODS to its default setup.
ods html close;
ods html;
Once you have created your output, you can delete the custom styles.
proc template;
delete Styles.NewStyle;
run;
HTML Output: Specifying Colors and Fonts
You can use the fonts to confirm that SAS titles use the SystemTitle style element, that
column headings use the Header style element, that the footer uses the Table-Footer style
element, and that the contents of both character and numeric cells use the CellContents
556
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
style element. Use the width of the table border and the spacing between cells to confirm
that the table itself is produced with the Table style element.
Output 15.6 HTML Output
Example 6: Importing a CSS File
Features:
Other features:
DEFINE STYLE statement
CLASS statement
IMPORT statement: media-type
PARENT= statement
Other ODS features
ODS HTML statement
ODS PDF statement
ODS _ALL_ CLOSE statement
Details
The following program imports the external CSS file StyleSheet.css and converts the
CSS code into style elements and style attributes. These style elements and attributes
then become part of the style.
Example 6: Importing a CSS File
557
Your CSS file can contain media blocks that correspond to the type of media that your
output will be rendered on. The IMPORT statement enables you to specify one or more
media blocks to be imported along with the rest of the CSS code. In this example, the
Print media block is included in the style that is applied to the PDF output.
The following code is an example of the external CSS file StyleSheet.css. There are two
media type blocks specified in this program, Print and Screen. Copy and paste this code
into a text editor and save it as StyleSheet.css.
.body {
background-color: white;
color: black;
font-family: times, serif;
}
.header, .rowheader, .footer, .rowfooter, .data {
border: 1px black solid;
color: black;
padding: 5px;
font-family: times, serif;
}
.header, .rowheader, .footer, .rowfooter {
background-color: #a0a0a0;
}
.table {
background-color: #dddddd;
border-spacing: 0;
border: 1px black solid;
}
.proctitle {
font-family: helvetica, sans-serif;
font-size: x-large;
font-weight: normal;
}
@media screen {
.header, .rowheader, .footer, .rowfooter,{
color: white;
background-color: green;}
.table {
background-color: yellow;
border-spacing: 0;
font-size: small
border: 1px black solid;
}
}@media print {
.header, .rowheader, .footer, .rowfooter,{
color: white;
background-color: Blue;
padding: 5px;
}
.data {
font-size: small;
}
}
558
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Program
filename odsout ".";
ods html close;
options nodate;
proc template;
define style styles.mycssstyle;
import "StyleSheet.css";
class data /
color = red;
end;
define style styles.mycssstyleprinter;
parent=styles.mycssstyle;
import "StyleSheet.css" print;
end;
run;
ods html path=odsout file="css.html" style=styles.mycssstyle;
ods pdf file="your-file-path/css.pdf" style=styles.mycssstyleprinter;
proc contents data=sashelp.class;
run;
ods _all_ close;
ods html;
Program Description
Create a file reference for the output and set the SAS system options. The current
working directory is specified in this example.
filename odsout ".";
ods html close;
options nodate;
Define a style that imports a CSS file and defines style elements as well. The PROC
TEMPLATE statement starts the TEMPLATE procedure. The DEFINE STYLE
statement creates a new style called MyCssStyle. The IMPORT statement imports the
CSS file StyleSheet.css, and converts the CSS code into ODS style elements and style
attributes. Because no media-type option is specified, the Screen media block is
imported along with the CSS code that is not in any media blocks. The Print media block
is not imported. The CLASS statement specifies a red font color in the Data style
element.
Specifying class data / color=red; is the same as specifying style data
from data / color=red;.
proc template;
define style styles.mycssstyle;
import "StyleSheet.css";
class data /
color = red;
end;
Define a style that imports a CSS file that includes a specific media type templates.
The DEFINE STYLE statement creates a new style called MyCssStylePrinter. The
IMPORT statement imports the CSS file StyleSheet.css, and converts the CSS code into
Example 6: Importing a CSS File
559
ODS style elements and style attributes. The Print option specifies that the Print media
block be imported along with the CSS code that is not in any media blocks. The code in
the Screen media block is not imported.
define style styles.mycssstyleprinter;
parent=styles.mycssstyle;
import "StyleSheet.css" print;
end;
run;
Create HTML and PDF output and view the contents of the SAS data set. The ODS
HTML and ODS PDF statements specify the destination to write to, the filename of the
output, and the style to use. The CONTENTS procedure shows the contents of the SAS
data set Sashelp.Class.
ods html path=odsout file="css.html" style=styles.mycssstyle;
ods pdf file="your-file-path/css.pdf" style=styles.mycssstyleprinter;
proc contents data=sashelp.class;
run;
Close the open destinations. The ODS _ALL_ CLOSE statement closes all open
destinations and the files that are associated with them. If you do not close the
destinations, then you will not be able to view the files. Specify the ODS HTML
statement to return ODS to its default setup.
ods _all_ close;
ods html;
560
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Output
Output 15.7 MyCssStyle Style
The yellow and green background colors, the white font color, the font size and border
information all come from the Screen media block. The red font color comes from the
Example 6: Importing a CSS File
561
CLASS statement. All other style information comes from the code outside of the media
blocks. No information from the Print media block is used.
Output 15.8
MyCssStyle Style Applied to HTML Output
562
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Output 15.9
MyCssStylePrinter Style
Example 7: Table Header and Footer Border Formatting
563
The white font, small font size, cell padding, and the blue background color all come
from the Print media block. All other style information comes from the code outside of
the media blocks. No information from the Screen media block is used.
Output 15.10
MyCssStylePrinter Style Applied to PDF Output
Example 7: Table Header and Footer Border Formatting
Features:
Border control style attributes
BORDERBOTTOMCOLOR=
BORDERBOTTOMSTYLE=
BORDERBOTTOMWIDTH=
BORDERTOPCOLOR=
BORDERTOPSTYLE=
BORDERTOPWIDTH=
DEFINE statement
DEFINE STYLE statement
EDIT statement
FOOTER statement
HEADER statement
PARENT= statement
PREFORMATTED= header attribute
564
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
STYLE statement
WIDTH= header attribute
Other features:
Data set:
Other ODS features:
ODS RTF statement
ODS SELECT statement
Stats and Stats2
Details
You can use the TableHeaderContainer and TableFooterContainer style elements along
with the border control style attributes to change the borders of the regions surrounding
the table header and footer.
Note: The TableHeaderContainer and TableFooterContainer style elements are valid
only in the RTF destination.
Program
ods html close;
options nodate;
title
"TableHeaderContainer, TableFooterContainer, and Border Control Style
Attributes";
title2 "Allows Control of Borders Between the Header, Body, and Footer of a
Table";
proc template;
define style HeadersFootersBorders;
parent=styles.rtf;
style TableHeaderContainer from TableHeaderContainer /
borderbottomwidth=12
borderbottomcolor=blue
borderbottomstyle=dotted;
style TableFooterContainer from TableFooterContainer /
bordertopwidth=6
bordertopcolor=red
bordertopstyle=double;
style table from table /
borderspacing=0 rules=groups frame=void;
end;
run;
proc template;
edit Base.Datasets.Members;
header hd1;
footer ft1;
define hd1;
preformatted=on;
just=l;
text"
Table Header with Leading and Trailing Blanks
end;
define ft1;
preformatted=on;
just=l;
";
565
Example 7: Table Header and Footer Border Formatting
text"
Table Footer with Leading and Trailing Blanks
end;
edit name;
define header myheader;
just=l;
preformatted=on;
text "
My new header";
end;
header=myheader;
width=memname_width width_max=memname_width_max;
preformatted=on;
end;
end;
run;
";
ods rtf file="your-file-path/headerfooters.rtf" style=HeadersFootersBorders;
ods select members;
proc datasets lib=work;
run;
quit;
ods rtf close;
ods html;
proc template;
delete HeadersFootersBorders;
delete Base.Datasets.Members;
run;
Program Description
Close the HTML destination so that no HTML output is produced. The HTML
destination is open by default. The ODS HTML CLOSE statement closes the HTML
destination to conserve resources. If the destination were left open, then ODS would
produce both HTML and PDF output.
ods html close;
options nodate;
Specify titles. The TITLE statements specify titles for the output.
title "TableHeaderContainer, TableFooterContainer, and Border Control Style
Attributes";
title2 "Allows Control of Borders Between the Header, Body, and Footer of a
Table";
Create the new style HeadersFootersBorders. The PROC TEMPLATE statement
starts the TEMPLATE procedure. The DEFINE STYLE statement creates a new style
HeadersFootersBorders. The PARENT= statement specifies that the new style inherits
all of its style elements and style attributes from the Styles.RTF style.
proc template;
define style HeadersFootersBorders;
parent=styles.rtf;
Modify the TableHeaderContainer style element. The STYLE statement with the
FROM option specified creates the style element TableHeaderContainer which inherits
all of its style elements and style attributes from the instance of TableHeaderContainer in
566
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
the Styles.RTF style. The BORDERBOTTOMWIDTH=, BORDERBOTTOMCOLOR=,
and BORDERBOTTOMSTYLE= style attributes specify the width, color, and line style
of the bottom border of the table header.
style TableHeaderContainer from TableHeaderContainer /
borderbottomwidth=12
borderbottomcolor=blue
borderbottomstyle=dotted;
Modify the TableFooterContainer style element. The STYLE statement with the
FROM option specified creates the style element TableFooterContainer which inherits
all of its style elements and style attributes from the instance of TableFooterContainer in
the Styles.RTF style. The BORDERTOPWIDTH=, BORDERTOPCOLOR=, and
BORDERTOPSTYLE= style attributes specify the width, color, and line style of the top
border of the table footer.
style TableFooterContainer from TableFooterContainer /
bordertopwidth=6
bordertopcolor=red
bordertopstyle=double;
Modify the Table style element. The STYLE statement with the FROM option
specified creates the style element Table which inherits all of its style elements and style
attributes from the instance of Table in the Styles.RTF style. The BORDERSPACING=,
RULES=, and FRAME= attributes modify the border spacing, rules, and frame of the
table.
style table from table /
borderspacing=0 rules=groups frame=void;
end;
run;
Edit the Base.Datasets.Members table template. The EDIT statement, along with the
table template DEFINE statements and attributes, modifies the Base.Datasets.Members
table template.
For more information about creating and modifying table templates, see Chapter 16,
“TEMPLATE Procedure: Creating Tabular Templates,” on page 578.
proc template;
edit Base.Datasets.Members;
header hd1;
footer ft1;
define hd1;
preformatted=on;
just=l;
text"
Table Header with Leading and Trailing Blanks
end;
define ft1;
preformatted=on;
just=l;
text"
Table Footer with Leading and Trailing Blanks
end;
edit name;
define header myheader;
just=l;
preformatted=on;
text "
My new header";
";
";
Example 7: Table Header and Footer Border Formatting
567
end;
header=myheader;
width=memname_width width_max=memname_width_max;
preformatted=on;
end;
end;
run;
Create the RTF file, select the output object and run PROC DATASETS. The ODS
RTF statement specifies the file that will contain the RTF output. The STYLE= option
specifies the style to apply to the output. The ODS SELECT statement selects the output
object Members to be sent to the open destinations.
ods rtf file="your-file-path/headerfooters.rtf" style=HeadersFootersBorders;
ods select members;
proc datasets lib=work;
run;
quit;
Close the RTF destination and open the HTML destination. The ODS RTF CLOSE
statement closes the RTF destination and the files that are associated with it. If you do
not close the destination, then you will not be able to view the files. Specify the ODS
HTML statement to return ODS to its default setup.
ods rtf close;
ods html;
Once you have created your output, you can delete the custom styles.
proc template;
delete HeadersFootersBorders;
delete Base.Datasets.Members;
run;
RTF Output
Output 15.11
RTF Output with Custom Headers and Footers
568
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
Example 8: Enhancing Titles and Footnotes in PDF Output
Features:
CLASS statement features
COLOR= style attribute
FONT_WEIGHT= style attribute
SystemFooter style element
User-defined style element FONTS
User-defined style attributes
DEFINE STYLE statement
PARENT= statement
Other features:
OPTIONS statement
ODS PDF statement
PROC PRINT
PROC TEMPLATE DELETE statement
Details
The text of titles and footnotes created by tabular (non-graphical) output is controlled
using the user-defined style attribute TitleFont in the style element Fonts. In Styles.Pearl
(the default style for PDF output), the source code shows that for TitleFont, the font
family is "<MTsans-serif>, Albany", the font size is 11pt, and the font weight is bold:
source styles.pearl;
define style Styles.Pearl;
parent = styles.printer;
class fonts /
'TitleFont2' = ("<MTsans-serif>, Albany",10pt,bold)
'TitleFont' = ("<MTsans-serif>, Albany",11pt,bold)
'StrongFont' = ("<MTsans-serif>, Albany",8pt,bold)
'EmphasisFont' = ("<MTsans-serif>, Albany",8pt,italic)
'FixedEmphasisFont' = ("<MTmonospace>, Courier",7pt)
'FixedStrongFont' = ("<MTmonospace>, Courier",7pt,bold)
'FixedHeadingFont' = ("<MTmonospace>, Courier",7pt,bold)
'BatchFixedFont' = ("SAS Monospace, <MTmonospace>, Courier",6pt)
'FixedFont' = ("<MTmonospace>, Courier",7pt)
'headingEmphasisFont' = ("<MTsans-serif>, Albany",9pt,bold italic)
'headingFont' = ("<MTsans-serif>, Albany",8pt,bold)
'docFont' = ("<MTsans-serif>, Albany",8pt);
The following example uses PROC TEMPLATE to edit the style attribute TitleFont to
make the following changes:
•
font size 14pt
•
font weight medium
•
font style italic
For separate control of the footnotes, the style element SystemFooter can be modified
using PROC TEMPLATE to make the footnotes green and medium weight.
Program
ods html close;
Example 8: Enhancing Titles and Footnotes in PDF Output
569
proc template;
define style styles.MyPDFstyle;
parent=styles.pearl;
class fonts /
'TitleFont2' = ("<MTsans-serif>, Albany",10pt,bold)
'TitleFont' = ("<MTsans-serif>, Albany",14pt, medium italic)
'StrongFont' = ("<MTsans-serif>, Albany",8pt,bold)
'EmphasisFont' = ("<MTsans-serif>, Albany",8pt,italic)
'FixedEmphasisFont' = ("<MTmonospace>, Courier",7pt)
'FixedStrongFont' = ("<MTmonospace>, Courier",7pt,bold)
'FixedHeadingFont' = ("<MTmonospace>, Courier",7pt,bold)
'BatchFixedFont' = ("SAS Monospace, <MTmonospace>, Courier",6pt)
'FixedFont' = ("<MTmonospace>, Courier",7pt)
'headingEmphasisFont' = ("<MTsans-serif>, Albany",9pt,bold italic)
'headingFont' = ("<MTsans-serif>, Albany",8pt,bold)
'docFont' = ("<MTsans-serif>, Albany",8pt);
class SystemFooter /
color = green
font_weight=medium;
end;
run;
options nodate number;
ods pdf file="file.pdf" style=styles.MyPDFstyle;
proc print data=sashelp.cars(obs=5);
title "First 5 observations from SASHELP.CARS";
footnote "Created by SAS &sysver";
run;
ods pdf close;
ods html;
proc template;
delete Styles.MyPDFstyle;
end;
title;
Program Description
Close the HTML destination so that no HTML output is produced. The HTML
destination is open by default. The ODS HTML CLOSE statement closes the HTML
destination to conserve resources. If the destination were left open, then ODS would
produce both HTML and PDF output.
ods html close;
Create a new style named Styles.MyPDFstyle that inherits from Styles.Pearl. The
PROC TEMPLATE statement starts the TEMPLATE procedure. The DEFINE STYLE
statement creates a new style called Styles.MyPDFstyle. The PARENT= attribute
specifies Styles.Pearl. as the style from which Styles.MyPDFstyle inherits. All the style
elements, attributes, and statements that are specified in the parent's style template
(Pearl) are used in the child style template (MyPDFstyle) unless the child style template
overrides them.
570
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
proc template;
define style styles.MyPDFstyle;
parent=styles.pearl;
Customize the title font by changing the attributes of the style element Fonts. The
style element Fonts contains the style attribute that controls the appearance of titles. This
CLASS statement adds the style element Fonts to the custom style Styles.MyPDFstyle.
The Fonts style element also exists in the parent style (Styles.Pearl). The CLASS
statement also changes the values of the user-defined style attribute TitleFont2. The
change is that the title font will now be 14pt, medium weight, and italic.
class fonts /
'TitleFont2' = ("<MTsans-serif>, Albany",10pt,bold)
'TitleFont' = ("<MTsans-serif>, Albany",14pt, medium italic)
'StrongFont' = ("<MTsans-serif>, Albany",8pt,bold)
'EmphasisFont' = ("<MTsans-serif>, Albany",8pt,italic)
'FixedEmphasisFont' = ("<MTmonospace>, Courier",7pt)
'FixedStrongFont' = ("<MTmonospace>, Courier",7pt,bold)
'FixedHeadingFont' = ("<MTmonospace>, Courier",7pt,bold)
'BatchFixedFont' = ("SAS Monospace, <MTmonospace>, Courier",6pt)
'FixedFont' = ("<MTmonospace>, Courier",7pt)
'headingEmphasisFont' = ("<MTsans-serif>, Albany",9pt,bold italic)
'headingFont' = ("<MTsans-serif>, Albany",8pt,bold)
'docFont' = ("<MTsans-serif>, Albany",8pt);
Customize the footer by adding the SystemFooter style element. The SystemFooter
style element controls the appearance of footers. It is not a default style element that is
present in the parent style (Styles.Pearl). The CLASS statement adds SystemFooter,
which contains the style attributes COLOR= and FONT_WEIGHT=, to
Styles.MyPDFstyle. This statement results in the font of the footnote being changed to a
medium, green font.
class SystemFooter /
color = green
font_weight=medium;
end;
run;
Set the SAS system options.
options nodate number;
Create the PDF file and specify the custom style. The ODS PDF statement creates the
PDF file. The STYLE= option specifies that the custom style template
Styles.MyPDFstyle is applied to the PDF output.
ods pdf file="file.pdf" style=styles.MyPDFstyle;
Create the PRINT procedure output and specify a title and footnote. The appearance
of the title and footnote reflects the changes made in the style MyPDFstyle.
proc print data=sashelp.cars(obs=5);
title "First 5 observations from SASHELP.CARS";
footnote "Created by SAS &sysver";
run;
Close the PDF destination and open the HTML destination. The ODS PDF CLOSE
statement closes the PDF destination and all of the files that are associated with it. You
Example 9: Customizing Graphic and Tabular Titles in PDF Output
571
must close the destinations before you can view the output with a browser or before you
can send the output to a physical printer. The ODS HTML statement opens the HTML
destination and returns ODS to its default setting.
ods pdf close;
ods html;
Remove the customized style template. The DELETE statement removes the
customized style that was created in this example. When you use the DELETE
statement, ODS looks for the Styles.MyPDF style in Sasuser.Templat first. If it is there,
it deletes it. If not, it searches Sashelp.Tmplmst.
proc template;
delete Styles.MyPDFstyle;
end;
title;
PDF Output
Output 15.12 PDF Output with Custom Title and Footnote
Example 9: Customizing Graphic and Tabular Titles in PDF Output
Features:
STYLE statement features
COLOR= style attribute
FROM option
SystemTitle style element
SystemTitle2 style element
SystemTitle3 style element
TitlesandFooters style element
DEFINE STYLE statement
PARENT= statement
Other features:
OPTIONS statement
572
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
ODS PDF statement options
NOGTITLE
NOTOC
PROC PRINT
PROC SGPANEL
TITLE statement
Details
The style elements and attributes that control the appearance of titles in tabular output
are in the Base.Template.Style template. In the BASE.TEMPLATE.STYLE definition,
there is an inheritance defined for each title (and footnote) as shown by this code
snippet:
style SystemTitle from TitlesAndFooters
"Controls system title text.";
style SystemTitle2 from SystemTitle
"Controls system title2 text";
style SystemTitle3 from SystemTitle2
"Controls system title3 text";
When you use a style template to customize titles in PDF output, you must be careful if
you have graphical output in your PDF file. By default, titles and footnotes are
embedded in graphical output created by ODS graphics and SAS/Graph. The style
definitions contain separate definitions for the titles and footnotes for these procedures.
The fonts controlling graphicical output are defined under the Graphfonts collection in
the default PDF style Styles.Pearl, as shown in this code snippet:
..more style information...
class GraphFonts /
'GraphAnnoFont' = ("<MTsans-serif>, Albany",10pt)
'GraphTitle1Font' = ("<MTsans-serif>, Albany",14pt,bold)
'GraphTitleFont' = ("<MTsans-serif>, Albany",11pt,bold)
'GraphFootnoteFont' = ("<MTsans-serif>, Albany",10pt)
'GraphLabelFont' = ("<MTsans-serif>, Albany",10pt)
'GraphLabel2Font' = ("<MTsans-serif>, Albany",10pt)
'GraphValueFont' = ("<MTsans-serif>, Albany",9pt)
'GraphUnicodeFont' = ("<MTsans-serif-unicode>",9pt)
'GraphDataFont' = ("<MTsans-serif>, Albany",7pt);
. .more style information...
This example illustrates the following points
•
You can use the ODS PDF option NOGTITLE to specify that the titles for any
graphical output are not embedded in the resulting image. This enables the titles to
be under the control of Systemtitle and Systemtitlen, which are the style elements
that control titles in tabular output. This is also true for footnotes in PDF output.
•
Most SAS styles are written with a large degree of inheritance. There are very few
stand-alone styles. After all of your output titles are controlled by Systemtitle and
Systemtitln, you can use inheritance to create a custom style that customizes the
titles for your PDF output.
Program
ods html close;
Example 9: Customizing Graphic and Tabular Titles in PDF Output
573
proc template;
define style Styles.CustomTitles;
parent=styles.pearl;
style SystemTitle from TitlesAndFooters
"Controls system title text." / color=blue;
style SystemTitle2 from SystemTitle
"Controls system title2 text" / color=orange;
style SystemTitle3 from SystemTitle2
"Controls system title3 text" / color=purple;
end;
run;
ods pdf file="PDFStyle.pdf" notoc style=Styles.CustomTitles nogtitle;
title "Predicted and Actual Sales";
title2 "For Sofas";
title3 "By Region";
options nodate nonumber obs=50000;
proc sort data=sashelp.prdsale out=prdsale;
by Country;
run;
proc sgpanel data=prdsale;
where quarter=1;
panelby product / novarname;
vbar region / response=predict;
vline region / response=actual lineattrs=GraphFit;
colaxis fitpolicy=thin;
rowaxis label='Sales';
run;
options nodate nonumber obs=8;
proc print data=prdsale;
var product region actual predict;
run;
ods pdf close;
ods html;
Program Description
Close the HTML destination so that no HTML output is produced. The HTML
destination is open by default. The ODS HTML CLOSE statement closes the HTML
destination to conserve resources. If the destination were left open, then ODS would
produce both HTML and PDF output.
ods html close;
Create a custom style template that modifies the appearance of titles. This PROC
TEMPLATE step creates a new style named Styles.CustomTitles that inherits all of its
style elements and attributes from Styles.Pearl. The STYLE statements use the COLOR=
style attribute to change the color of the system options in tabular output.
proc template;
define style Styles.CustomTitles;
parent=styles.pearl;
574
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
style SystemTitle from TitlesAndFooters
"Controls system title text." / color=blue;
style SystemTitle2 from SystemTitle
"Controls system title2 text" / color=orange;
style SystemTitle3 from SystemTitle2
"Controls system title3 text" / color=purple;
end;
run;
Open the PDF destination and specify the ODS PDF statement options. The
NOTOC option specifies that no table of contents is created. The NOGTITLE option
specifies that titles are not embedded in graphical output. This enables the titles to be
controlled by the style elements specified in the previous STYLE statements.
ods pdf file="PDFStyle.pdf" notoc style=Styles.CustomTitles nogtitle;
Specify the titles.
title "Predicted and Actual Sales";
title2 "For Sofas";
title3 "By Region";
Create the procedure output.
options nodate nonumber obs=50000;
proc sort data=sashelp.prdsale out=prdsale;
by Country;
run;
proc sgpanel data=prdsale;
where quarter=1;
panelby product / novarname;
vbar region / response=predict;
vline region / response=actual lineattrs=GraphFit;
colaxis fitpolicy=thin;
rowaxis label='Sales';
run;
options nodate nonumber obs=8;
proc print data=prdsale;
var product region actual predict;
run;
Close the PDF destination and open the HTML destination. The ODS PDF CLOSE
statement closes the PDF destination and all of the files that are associated with it. You
must close the destinations before you can view the output with a browser or before you
can send the output to a physical printer. The ODS HTML statement opens the HTML
destination and returns ODS to its default setting.
ods pdf close;
ods html;
Example 9: Customizing Graphic and Tabular Titles in PDF Output
PDF Output
The following output shows that the custom style is applied to all of our output.
Output 15.13 PDF with Customized Titles for Tabular and Graphical Output
575
576
Chapter 15
•
TEMPLATE Procedure: Creating a Style Template
If you omit the NOGTITLE option from the ODS PDF statement, then the titles are
embedded within the graph and the custom style is not applied to them.
Output 15.14
Custom Style not Applied to Graphical Output
577
Chapter 16
TEMPLATE Procedure: Creating
Tabular Templates
Overview: ODS Tabular Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Using the TEMPLATE Procedure to Create or Customize Tabular Output . . . . . . 578
What You Can Do with Table Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Comparing the Edit of an Existing Table Template with
Creating a New Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Viewing the Contents of a Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
Syntax: TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . . . . . 583
CELLSTYLE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
COLUMN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
COMPUTE AS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
DEFINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
DEFINE COLUMN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
DEFINE FOOTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
DEFINE HEADER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
DEFINE TABLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
DYNAMIC Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
EDIT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
END Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
FOOTER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
HEADER Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600
MVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
NMVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
NOTES Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
TEXT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
TEXT2 Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
TEXT3 Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
TRANSLATE INTO Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Using the TEMPLATE Procedure to Create Tabular Output . . . . . . . . . . . . . . . .
Values in Table Columns and How They Are Justified . . . . . . . . . . . . . . . . . . . . .
Formatting Values in Table Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stacking Values for Two or More Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
610
610
611
612
Examples: TEMPLATE Procedure: Creating Tabular Templates . . . . . . . . . . . .
Example 1: Editing a Table Template That a SAS Procedure Uses . . . . . . . . . . . .
Example 2: Comparing the EDIT Statement to the DEFINE TABLE Statement .
Example 3: Creating a New Table Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 4: Setting the Style Element for Cells Based on Their Values . . . . . . . .
Example 5: Setting the Style Element for a Specific Column, Row, and Cell . . . .
Example 6: Creating Master Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example 7: Table Header and Footer Border Formatting . . . . . . . . . . . . . . . . . . .
613
613
618
624
632
637
644
647
578
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Overview: ODS Tabular Templates
Using the TEMPLATE Procedure to Create or Customize Tabular
Output
The TEMPLATE procedure enables you to customize the tabular appearance of your
SAS output.
Tabular templates describe how tables should be constructed. This includes the content
and placement of headers and footers, the content and placement of columns, and style
overrides. All SAS procedures, except PROC PRINT, PROC REPORT, and PROC
TABULATE, use tabular templates to describe how their tabular output should look.
This means that you can change the structure of tables that are generated by SAS
procedures by using tabular templates.
With the TEMPLATE procedure, you can create and modify tabular templates. Tabular
templates include the following types:
•
column templates
•
header templates
•
footer templates
•
table templates
The Output Delivery System then uses these templates to produce customized tabular
output for better data presentations and reports than what you get with the default SAS
output. You can also create your own master tables using templates.
By default, ODS output is formatted according to the various definitions or templates
that the procedure or DATA step specify. However, you can customize existing tabular
output templates, or create your own new tabular output templates, by using the
TEMPLATE procedure with these statements.
Table 16.1
PROC TEMPLATE Statements
Customization
Element Modified
Statement
Column presentation
Column template
“DEFINE COLUMN Statement” on
page 592
Table footer
Footer template
“DEFINE FOOTER Statement” on
page 593
Table header
Header template
“DEFINE HEADER Statement” on
page 594
Single output object
Table template
“DEFINE TABLE Statement” on page
596
An existing template for a table,
column, header, or footer
Table, column, header, footer
“EDIT Statement” on page 598
Overview: ODS Tabular Templates
579
You can find additional tips and tricks in the SAS press book excerpt, ODS Techniques:
Tips for Enhancing Your SAS Output, by Kevin Smith. This SAS press book is a
cookbook-style collection of Kevin’s top ODS tips and techniques to teach you how to
bring your reports to a new level and inspire you to see ODS in a new light.
What You Can Do with Table Templates
Default Listing and RTF Display of an Output Object
By default, ODS uses the table template specified by the procedure or DATA step to
create ODS output. For example, the following display shows the default LISTING
output of the Moments output object created by PROC UNIVARIATE. The second
display shows the default RTF output of the same output object.
Figure 16.1 LISTING Output from PROC UNIVARIATE (Default Moments Table)
580
Chapter 16
Figure 16.2
•
TEMPLATE Procedure: Creating Tabular Templates
RTF Output of Sales Statistics from PROC UNIVARIATE (Default Moments Table)
Customized Version of the Listing and RTF Display of an Output
Object
With PROC TEMPLATE, you can change many of the table elements and obtain a
customized format for the output objects. Here are some of the elements that you can
change:
•
the color and the font of the text of the first table header
•
the justification of the first table header
•
the setting of the table attributes UNDERLINE and OVERLINE
•
the line spacing between the rows
Note: Not all table template changes affect all destinations. For example, font changes
are ignored in the LISTING destination.
The following displays show the results of using a customized table template that
changes the first table header attributes, sets underlining and overlining in the table, and
changes the amount of spacing between rows.
Comparing the Edit of an Existing Table Template with Creating a New Table Template
581
Figure 16.3
LISTING Output from PROC UNIVARIATE (Customized Moments Table)
Figure 16.4
RTF Output of Sales Statistics from PROC UNIVARIATE (Customized Moments Table)
Comparing the Edit of an Existing Table Template
with Creating a New Table Template
To change a table template without completely redefining it, use an EDIT statement.
Using the EDIT statement keeps all of the templates and attributes that already exist in
the table template, and changes only the templates or attributes specified in the EDIT
statement. By default, the modified table template is stored in Sasuser.Templat with the
same name as the table template specified in the EDIT statement.
To create a new table template, use the DEFINE TABLE statement. A table template
cannot be a parent to itself because creating a table through inheritance causes an error,
582
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
and then the template must be deleted. When you create a new table template, only the
columns, headers, footers, and table attributes that you define exist in the new table
template.
Note: If you edit an existing table or define a new table with the same name as an
existing table, then the table template is stored in the Sasuser.Templat item store.
This table template is used, by default, unless you specify that the Sashelp.Tmplmst
path is searched first. However, you can use the ODS PATH statement to store the
template elsewhere and access it differently. See the “ODS PATH Statement” in SAS
Output Delivery System: User's Guide for more information.
Viewing the Contents of a Table Template
To view the contents of a table template, use the SAS windowing environment, the
command line, or the TEMPLATE procedure.
•
Using the SAS Windowing Environment
1. From the menu, select View ð Results.
2. In the Results window, select the Results folder. Right-click and select
Templates to open the Templates window.
3. Double-click Sashelp.Tmplmst to view the contents of that item store or
directory.
4. Double-click a directory to view the list of subdirectories and table templates that
you want to view. For example, the Base SAS table template Summary is the
default template store for the summary tables created in the MEANS and
SUMMARY procedures. Double-click the Base directory, and then double-click
the Summary table.
•
Using the Command Line
1. To view the Templates window, submit this command: odstemplates
The Templates window contains the item stores Sasuser.Templat and
Sashelp.Tmplmst.
2. When you double-click an item store, such as Sashelp.Tmplmst, that item store
expands to list the directories where ODS templates are stored. The templates
that SAS provides are in the item store Sashelp.Tmplmst.
3. To view the table templates that SAS provides, double-click the item store that
contains a table template, such as Base.
4. Right-click the table template, such as Summary, and select Open. The table
template is displayed in the Template Browser window.
•
Using the TEMPLATE Procedure. The SOURCE statement writes the source code
for the specified template to the SAS log. For example, if to view the source code for
all the objects in Base SAS, submit this code.
proc template;
source base;
run;
Syntax: TEMPLATE Procedure: Creating Tabular Templates
583
Syntax: TEMPLATE Procedure: Creating Tabular
Templates
PROC TEMPLATE;
EDIT template-path-1 <AS template-path-2> < / STORE=libref.template-store > ;
statements-and-attributes
END;
DEFINE COLUMN column-path | Base.Template.Column
< / STORE=libref.template-store>;
statements-and-attributes
END;
DEFINE FOOTER footer-path | Base.Template.Footer
< / STORE=libref.template-store>;
statements-and-attributes
END;
DEFINE HEADER template-name | Base.Template.Header;
statements-and-attributes
END;
DEFINE TABLE table-path | Base.Template.Table
</ STORE=libref.template-store>;
statements-and-attributes
END;
Statement
Task
Example
CELLSTYLE AS
Set the style element of the cells in the table or column
according to the values of the variables
Ex. 5, Ex. 6
COLUMN
Declare a symbol as a column in the table and specify the
order of the columns
Ex. 2
COMPUTE AS
Compute values for a column that is not in the data
component, or modify the values of a column that is in the
data component
DEFINE
Create a template inside a table template
Ex. 2, Ex. 3,
Ex. 7
DEFINE
COLUMN
Create a template for a column
Ex. 4, Ex. 5,
Ex. 6
DEFINE
FOOTER
Create a template for a table footer
Ex. 3
DEFINE
HEADER
Create a template for a table header or a header inside a
column template
Ex. 5, Ex. 6
584
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Statement
Task
Example
DEFINE TABLE
Create a table template
Ex. 4, Ex. 5,
Ex. 6
DYNAMIC
Define a symbol that references a value that the data
component supplies from the procedure or DATA step
Ex. 2
EDIT
Edit an existing template for a table, column, header, or
footer
Ex. 1, Ex. 2,
Ex. 7
END
End the table template, header template, column template,
or footer template
FOOTER
Declare a symbol as a footer in the table and specify the
order of the footers
Ex. 7
HEADER
Declare a symbol as a header in the table and specify the
order of the headers
Ex. 3, Ex. 7
MVAR
Define a symbol that references a macro variable, the
value of which is treated as a string
Ex. 3
NMVAR
Define a symbol that references a macro variable, the
value of which is treated as a number
NOTES
Provide information about the table, header, column, or
footer
Ex. 2
TEXT
Specify the text of a header, footer, or the label of a
variable in an output data set
Ex. 5
TEXT2
Provide an alternative header or footer to use in the
LISTING output if the header or footer that is provided by
the TEXT statement is too long
TEXT3
Provide an alternative header or footer to use in the
LISTING output if the header or footer that is provided by
the TEXT2 statement is too long
TRANSLATE
INTO
Translate the specified numeric values to other values
CELLSTYLE AS Statement
For tables, sets the style element of the cells in the table or column according to the values of the
variables. For text, sets the style attributes of the list items or paragraphs. Use this statement to set the
presentation characteristics (such as foreground color and font face) of individual cells or text.
Restriction:
Examples:
The CELLSTYLE AS statement can be used only within a column template, an ODS
list, an ODS textblock, or a table template.
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
“Example 1: Using Item Statements” on page 235
CELLSTYLE AS Statement
585
Syntax
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)]>
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
Required Arguments
expression
is an expression that is evaluated for each list item, paragraph, or table cell.
If expression resolves to TRUE (a nonzero value), the style element that is specified
is used for the current cell. If expression is FALSE (zero), the next expression in the
statement is evaluated. Thus, you can string multiple expressions together to format
cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a string, a comparison, logical
operation, or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in table or column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
Example
The following CELLSTYLE AS statement specifies that
numeric column variables have a red font color and character
column variables have a blue font color:
cellstyle
_LABEL_
is a column label.
_datatype_ = "num" as {color=red},
_datatype_ = "char" as {color=blue};
586
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style element name.
See
For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 16.2
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Tip
Using an expression of 1 as the last expression in the CELLSTYLE AS
statement sets the style element for any cells that did not meet an earlier
condition. For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
CELLSTYLE AS Statement
587
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general
form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a table template, see
“Style Attributes Overview” on page 473.
Optional Argument
style-element-name
is the name of a style element that is part of a style that is registered with the Output
Delivery System. SAS provides some styles. You can create customized styles and
style elements with PROC TEMPLATE by using the “DEFINE STYLE Statement”
on page 462. For a table of style element names, see Chapter 21, “Style Elements,”
on page 831.
The following style elements are most likely to be used with the CELLSTYLE AS
statement:
•
Data
•
DataFixed
•
DataEmpty
•
DataEmphasis
•
DataEmphasisFixed
•
DataStrong
•
DataStrongFixed
•
ListItem
•
ListItem2
•
Paragraph
The style element provides the basis for displaying the cell. Additional style
attributes modify the display.
Default
Data
See
Chapter 15, “TEMPLATE Procedure: Creating a Style Template,” on page
442
For a table of style element names, see Chapter 21, “Style Elements,” on
page 831.
588
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
COLUMN Statement
Declares a symbol as a column in the table and specifies the order of the columns.
Restriction:
Examples:
The COLUMN statement can be used only within a table template.
“Example 3: Creating a New Table Template ” on page 624
“Example 2: Defining Variables with the COLUMN Statement” on page 291
Syntax
COLUMN column(s);
Required Argument
column
is one or more columns. If the column is defined outside the current table template,
reference it by its path in the template store. Columns in the template are laid out
from left to right in the same order that they are specified in the COLUMN
statement.
Defaults
If you omit a COLUMN statement, ODS makes a column for each
column template (DEFINE COLUMN statement), and places the
columns in the same order that the column templates have in the table
template.
If you use a COLUMN statement but omit a DEFINE COLUMN
statement for any of the columns, ODS uses a default column template
that is based on the type of data in the column.
Interaction
If you specify the column attribute PRINT=OFF, then the value of a
column is turned off if the column is part of a stacked column. If all
columns in a stacked column have PRINT=OFF set, then the entire
column is removed from the table.
Tip
Use a list of variable names, such as DAY1–DAY10, to specify
multiple variables.
See
“Stacking Values for Two or More Variables ” on page 612
COMPUTE AS Statement
Computes values for a column that is not in the data component, or modifies the values of a column that is
in the data component.
Restriction:
The COMPUTE AS statement can be used only within a column template.
Syntax
COMPUTE AS expression;
COMPUTE AS Statement 589
Required Argument
expression
is an expression that assigns a value to each table cell in the column.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical sequence of operators and operands. An operator is a
symbol that requests a comparison, a logical operation, or an arithmetic
calculation. An operand is one of the following:
constant
is a fixed value, such as the name of a column, or symbols that are declared
in a DYNAMIC, MVAR, or NMVAR statement in the current template.
To reference another column in a COMPUTE AS statement, use the name of
the column. In addition, if the column has values in the data component, you
can reference the column itself in the expression.
For example, this DEFINE COLUMN block defines a column that contains
the square root of the value in the column called Source:
define column sqroot;
compute as sqrt(source);
header="Square Root";
format=6.4;
end;
function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data-column name.
_LABEL_
is a column label.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
590
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
_STYLE_
is a style-element name.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or another variable.
Table 16.3
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Tip
The COMPUTE AS statement can alter values in an output object. None
of the templates that SAS provides modifies any values. To determine
whether a template was provided by SAS, use the “ODS VERIFY
Statement” in SAS Output Delivery System: User's Guide. If the template
is not from SAS, the ODS VERIFY statement returns a warning when it
runs the SAS program that uses the template. If you receive such a
warning, use the SOURCE statement to look at the template and
determine whether the COMPUTE AS statement alters values. (See
“SOURCE Statement” on page 361.)
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data Set
Options: Reference and the section on WHERE-Expression Processing in
SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row, and
Cell” on page 637
DEFINE Statement
591
DEFINE Statement
Creates a template inside a table template.
Restriction:
See:
The DEFINE statement can be used only inside a table template.
“DEFINE COLUMN Statement” on page 592
“DEFINE FOOTER Statement” on page 593
“DEFINE HEADER Statement” on page 594
Example:
“Example 2: Defining Variables with the COLUMN Statement” on page 291
Syntax
DEFINE <template-type> template-name </ option(s)>;
statements-and-attributes;
END;
Required Argument
template-name
specifies the name of the new object.
Restriction
template-name must be a single-level name.
Tip
To reference the template that you are creating from another template,
create it outside the table template.
Optional Arguments
template-type
specifies the type of template to create, where template-type is one of the following:
•
COLUMN
•
FOOTER
•
HEADER
The template-type determines what other statements and what attributes can go in the
template. For details, see the documentation for the corresponding DEFINE
statement.
template-type is optional if you specify the COLUMN name before the definition.
The same is true for headers and footers.
NOLIST
preserves the template-type when inheriting it from another table template.
Tip
If you specify an existing template-name without using the NOLIST option,
then the template is overwritten.
592
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
DEFINE COLUMN Statement
Creates a template for a column.
Requirement:
An END statement must be the last statement in the template.
Interaction:
A column template can include one or more header templates.
See:
Examples:
“DEFINE HEADER Statement” on page 594
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
“Example 5: Setting the Style Element for a Specific Column, Row, and Cell” on page
637
“Example 6: Creating Master Templates” on page 644
Syntax
DEFINE COLUMN column-path | Base.Template.Column
< / STORE=libref.template-store>;
<column-attribute-1 < column-attribute-2>…>;
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
COMPUTE AS expression;
DEFINE HEADER | Base.Template.Header template-path;
statements-and-attributes
END;
DYNAMIC variable-1 <=default-variable-1>
<'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
MVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TRANSLATE expression-1 INTO expression-2
<, expression-n INTO expression-m>;
END;
Required Arguments
column-path
specifies where to store the column template. A column-path consists of one or more
names that are separated by periods. Each name represents a directory in a template
store, which is a type of SAS file. PROC TEMPLATE writes the template to the first
writable template store in the current path.
DEFINE FOOTER Statement 593
Restrictions
If the template is nested inside another template, template-path must
be a single-level name because the nested template is stored in the
same location as the original template.
To reference the template that you are creating from another template,
do not nest the template inside another one. For example, to reference
a column template from multiple tables, do not define the column
inside a table template.
Base.Template.Column
creates a master column template that is globally applied to all of your tabular
output. After you create this template, you do not need to specify it explicitly in your
SAS programs. It is automatically applied to all tabular output until you specifically
remove the template from the item store.
Interaction
The Base.Template.Column master template attributes are overridden
by other tabular templates.
Example
“Example 6: Creating Master Templates” on page 644
Optional Argument
STORE=libref.template-store
specifies the template store in which to store the template. If the template store does
not exist, it is created.
Restrictions
If the template is nested inside another template, do not use the
STORE= option for the nested template because it is stored in the
same location as the original template.
The STORE= option does not become part of the template.
DEFINE FOOTER Statement
Creates a template for a table footer.
Requirement:
See:
Examples:
An END statement must be the last statement in the template.
“DEFINE HEADER Statement” on page 594
“Example 3: Creating a New Table Template ” on page 624
“Example 1: Creating a Stand-Alone Style” on page 521
594
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Syntax
DEFINE FOOTER footer-path | Base.Template.Footer
< / STORE=libref.template-store>;
<header/footer-attribute-1 < header/footer-attribute-2>…>;
DYNAMIC variable-1 <=default-variable-1>
<'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
MVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TEXT footer-specification;
TEXT2 footer-specification;
TEXT3 footer-specification;
END;
Substatements and Attributes
The substatements in the DEFINE FOOTER statements and the footer attributes are the
same as the substatements in the “DEFINE HEADER Statement” on page 594 and the
“Header and Footer Attributes” on page 670.
DEFINE HEADER Statement
Creates a template for a table header or a header inside a column template.
Restriction:
Requirement:
See:
The DEFINE HEADER statement can be used only within a column template or a
table template.
An END statement must be the last statement in the template.
“Example 3: Creating a New Table Template ” on page 624
DEFINE HEADER Statement 595
Syntax
DEFINE HEADER header-path | Base.Template.Header
</ STORE=libref.template-store>;
<header/footer-attribute-1 < header/footer-attribute-2>…>;
DYNAMIC variable-1 <=default-variable-1>
<'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
MVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TEXT header-specification;
TEXT2 header-specification;
TEXT3 header-specification;
END;
Required Arguments
header-path
specifies where to store the header template. A header-path consists of one or more
names, separated by periods. Each name represents a directory in a template store.
(A template store is a type of SAS file.) PROC TEMPLATE writes the template to
the first writable template store in the current path.
Restrictions
If the template is nested inside of another template, header-path must
be a single-level name.
To reference the template that you are creating from another template,
do not nest the template inside another template. For example, to
reference a header template from multiple columns, do not define the
header inside a column template.
Base.Template.Header | Base.Template.Footer
creates a master header template that is globally applied to all of your tabular output.
After this template is created, you do not need to explicitly specify it in your SAS
programs. It is automatically applied to all tabular output until you specifically
remove it from the item store.
Interaction
The Base.Template.Header or Base.Template.Footer master template
attributes are overridden by other tabular templates.
Example
“Example 6: Creating Master Templates” on page 644
Optional Argument
STORE=libref.template-store
specifies the template store in which to store the template. If the template store does
not exist, it is created.
596
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Restrictions
If the template is nested inside another template, do not use the
STORE= option for the nested template because it is stored where the
original template is stored.
The STORE= option does not become part of the template.
DEFINE TABLE Statement
Creates a table template.
Requirement:
Interaction:
Examples:
An END statement must be the last statement in the template.
A table template can contain one or more column, header, or footer templates.
“Example 3: Creating a New Table Template ” on page 624
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
Syntax
DEFINE TABLE table-path | Base.Template.Table
</ STORE=libref.template-store>;
<table-attribute-1 < table-attribute-2>…>;
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
COLUMN column(s);
DEFINE template-type template-name </ option(s)>;
statements-and-attributes
END;
DYNAMIC variable-1 <=default-variable-1>
<'text-1'> <… variable-n <=default-variable-n><'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
MVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<… variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TRANSLATE expression-1 INTO expression-2 < , expression-n INTO expression-m;>
END;
Required Arguments
table-path
specifies where to store the table template. A table-path consists of one or more
names that are separated by periods. Each name represents a directory in a template
store, which is a type of SAS file. PROC TEMPLATE writes the template to the first
writable template store in the current path.
DYNAMIC Statement
597
Base.Template.Table
creates a master table template that is globally applied to all of your tabular output.
Once this template is created, you do not need to explicitly specify it in your SAS
programs. It is automatically applied to all tabular output until you specifically
remove it from the item store.
Interaction
The Base.Template.Table master template attributes are overridden by
other tabular templates.
Tip
The Base.Template.Table master template is most useful when used
with the CELLSTYLE AS statements to create alternating colors in
your tabular output.
Example
“Example 6: Creating Master Templates” on page 644
Optional Argument
STORE=libref.template-store
specifies the template store in which to store the template. If the template store does
not exist, it is created.
Restriction
The STORE= option does not become part of the template.
DYNAMIC Statement
Defines a symbol that references a value that the data component supplies from the procedure or DATA
step.
Restriction:
Examples:
The DYNAMIC statement can be used only in the template of an ODS textblock,
ODS list, table, column, header, or footer. A dynamic variable that is defined in a
template is available to that template and to all the templates that it contains.
“Example 1: Creating a Stand-Alone Style” on page 521
“Example 2: Using User-Defined Attributes” on page 528
Syntax
DYNAMIC variable-name-1 <=value–1<'text-1'>>
< variable-name-2 <=value-2><'text-2'…>>;
Required Argument
variable-name
names a variable that the data component supplies. ODS resolves the value of the
variable when it binds the template and the data component.
Tip
Dynamic variables are most useful to the authors of SAS procedures and to
DATA step programmers.
Optional Arguments
value
sets the value of the variable.
598
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
text
is text that is placed in the template to explain the dynamic variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
EDIT Statement
Edits an existing template. The EDIT statement replaces the DEFINE statement in a template block when
editing. You can use the EDIT statement in place of any DEFINE statement.
Restriction:
If you edit a template that is a link, the link is broken and a separate template is
created.
Requirement:
An END statement must follow the EDIT statement and all of the editing instructions.
Interaction:
In some cases, you can use an EDIT statement inside a set of editing instructions.
When you edit a table template, you can also edit one or more column, header, or
footer templates that are defined in the table. When you edit a column template, you
can also edit one or more header templates that are defined for that column.
Example:
“Example 1: Editing a Table Template That a SAS Procedure Uses” on page 613
Syntax
EDIT template-path-1 <AS template-path-2 > </ STORE=libref.template-store>;
template-statements;
END;
Required Argument
template-path-1
specifies a template to edit. template-path-1 consists of one or more names that are
separated by periods. Each name represents a directory in a template store, which is a
type of SAS file.
Interaction
The STORE= option specifies a particular template store to read from
and write to.
Tip
To determine the templates that a procedure or DATA step uses, submit
the ODS TRACE ON statement before you run the SAS program. (See
“ODS TRACE Statement” on page 68.)
Optional Arguments
AS template-path-2
specifies the location in which to store the edited template, where template-path-2
consists of one or more names that are separated by periods. Each name represents a
directory in a template store, which is a type of SAS file. By default, PROC
TEMPLATE writes the edited template to the first writable template store in the
current path.
Default
If you omit AS template-path-2, PROC TEMPLATE writes the edited
template to template-path-1 in the first writable template store.
FOOTER Statement
Restriction
599
If the current EDIT statement is inside a set of editing instructions, do
not use the AS template-path-2 option.
STORE=libref.template-store
specifies the template store from which to read template-path-1 and in which to store
template-path-2.
template-statements
template-statements are any statements or attributes that are valid between the
DEFINE statement and the END statement.
Editing an Existing Template
When you use the EDIT statement, the following occurs:
•
By default, PROC TEMPLATE looks for template-path-1 in the list of template
stores that is defined by the PATH statement. (See “PATH Statement” on page 359.)
It opens a copy of the first template path that it finds in a template store that has
Read access.
•
PROC TEMPLATE writes the modified template to the first template store in the
current path with Update access. If you omit a second template path to write to, then
PROC TEMPLATE uses template-path-1. Therefore, if the template store from
which template-path-1 is read has Update access, you are actually modifying the
original template. Otherwise, the modified file is written to a template store to which
you do have Update access.
If you do specify a second template path, then PROC TEMPLATE writes the edited
template to the specified path in the first template store to which you have Write
access.
END Statement
Ends the table template, header template, column template, or footer template.
Syntax
END;
FOOTER Statement
Declares a symbol as a footer in the table and specifies the order of the footers.
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
FOOTER footer-specification(s);
600
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Required Argument
footer-specification
is one or more footers. If the footer is defined outside the current table template,
reference it by its path in the template store. Footers in the template are laid out from
top to bottom in the same order that they are specified in the FOOTER statement.
Each footer-specification is one of the following:
"string"
specifies the text to use for the footer. If you specify a string, you do not need to
specify a DEFINE FOOTER statement. However, you cannot specify any footer
attributes except for a split character. If the SPLIT= attribute is not in effect and
if the first character of the footer that you specify is neither a blank character nor
an alphanumeric character, PROC TEMPLATE and PROC ODSTABLE treat it
as the split character.
See
“SPLIT= "character" | variable;” on page 678
footer-path
is the path of the footer template to use. A footer-path consists of one or more
names, separated by periods. Each name represents a directory in a template
store, which is a type of SAS file.
_LABEL_
uses the label of the output object as the footer. Each SAS procedure specifies a
label for each output object that it creates. The DATA step uses the value of the
OBJECTLABEL= option as the label of the output object. If OBJECTLABEL=
is not specified, it uses the text of the first TITLE statement as the label.
Default
If you omit a FOOTER statement, ODS makes a footer for each footer
template (DEFINE FOOTER statement), and places the footers in the same
order that the footer templates have in the table template.
HEADER Statement
Declares a symbol as a header in the table and specifies the order of the headers.
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
HEADER header-specification(s);
Required Argument
header-specification
is one or more headers. If the header is defined outside the current table template,
reference it by its path in the template store. Headers in the template are laid out
from top to bottom in the same order that they are specified in the HEADER
statement. Each header-specification is one of the following:
"string"
specifies the text to use for the header. If you specify a string, you do not need to
use a DEFINE HEADER statement. However, you cannot specify any header
MVAR Statement 601
attributes except for a split character. If the SPLIT= header attribute is not in
effect and if the first character of the header that you specify is neither a blank
character nor an alphanumeric character, PROC TEMPLATE and PROC
ODSTABLE treat it as the split character.
See
“SPLIT= "character" | variable;” on page 678
header-path
is the path of the header template to use. A header-path consists of one or more
names, separated by periods. Each name represents a directory in a template
store. (A template store is a type of SAS file.)
_LABEL_
uses the label of the output object as the header. Each SAS procedure specifies a
label for each output object that it creates. The DATA step uses the value of the
OBJECTLABEL= option as the label of the output object. If OBJECTLABEL=
is not specified, it uses the text of the first TITLE statement as the label.
Default
If you omit a HEADER statement, then ODS makes a header for each
header template (DEFINE HEADER statement), and places the headers
in the same order that the header templates have in the table template.
Example
“Example 3: Creating a New Table Template ” on page 624
MVAR Statement
Defines a symbol that references a macro variable. ODS uses the value of the variable as a string.
References to the macro variable are resolved when ODS binds the template and the data component to
produce an output object.
Restriction:
When replaying an ODS document with PROC DOCUMENT, values created by the
MVAR statement must be re-created in the same session that is replaying the
document.
Tip:
You can use the MVAR statement in the template of an ODS list, ODS textblock,
table, column, header, or footer. A macro variable that is defined in a template is
available to that template and to all the templates that it contains.
See:
“Example 3: Creating a New Table Template ” on page 624 and “Example 1:
Creating a Stand-Alone Style” on page 521
Syntax
MVAR variable-name-1 <='value-1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS uses the value of the
macro variable as a string. ODS does not resolve the value of the macro variable
until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use the
automatic macro variable SYSDATE9 in a template, declare it in an MVAR
602
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
statement and reference it as SYSDATE9, without an ampersand, in the PROC
TEMPLATE or PROC ODSTABLE step. If you use the ampersand, the macro
variable resolves when the template is compiled instead of when ODS binds the
template to the data component.
Optional Arguments
value
sets the default variable value.
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NMVAR Statement
Defines a symbol that references a macro variable. ODS converts the variable's value to a number (stored
as a double) before using it. References to the macro variable are resolved when ODS binds the template
and the data component to produce an output object.
Restriction:
See:
The NMVAR statement can be used only in the template of an ODS list, ODS
textblock, table, column, header, or footer. A macro variable that is defined in a
template is available to that template and to all the templates that it contains.
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
Syntax
NMVAR variable-name-1 <='value–1' <'text-1'>>
< variable-name-2 <='value-2'> <'text-2'…>>;
Required Argument
variable-name
names a macro variable to reference in the template. ODS converts the variable's
value to a number (stored as a double) before using it. ODS does not resolve the
macro variable until it binds the template and the data component.
Tip
Declare macro variables this way in a template. For example, to use a macro
variable as a number, declare it in an NMVAR statement and reference it
without an ampersand. If you use the ampersand, the macro variable resolves
when the template is compiled instead of when ODS binds the template to the
data component.
Optional Arguments
value
sets the value of the variable.
TEXT Statement
603
text
is text that is placed in the template to explain the macro variable's use. Text of this
type becomes part of the compiled template, which you can view with the SOURCE
statement, whereas SAS comments do not.
NOTES Statement
Provides information about the table, header, column, or footer.
Restriction:
The NOTES statement can be used only in the template of a table, column, header,
or footer.
Tip:
The NOTES statement becomes part of the compiled template, which you can view
with the SOURCE statement, whereas SAS comments do not.
See:
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
Example:
“Example 1: Creating a Customized Crosstabulation Table Template with No Legend”
on page 403
Syntax
NOTES 'text';
Required Argument
text
provides information about the table.
TEXT Statement
Specifies the text of a header, footer, or the label of a variable in an output data set.
Restriction:
See:
The TEXT statement can be used only within a header or footer template.
“Example 3: Creating a New Table Template ” on page 624
Syntax
TEXT header/footer-specification(s);
Required Argument
header/footer-specification(s)
specifies the text of the header or footer. Each header/footer-specification is one of
the following:
_LABEL_
uses the label of the object that the header applies to as the text of the header. For
example, if the header or footer is for a column, _LABEL_ specifies the label for
the variable that is associated with the column. If the header or footer is for a
table, _LABEL_ specifies the label for the data set that is associated with the
table.
604
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
text-specification(s)
specifies the text to use in the header or footer. Each text-specification is one of
the following:
•
a quoted string
•
a variable, followed by an optional format. The variable is any variable that is
declared in a DYNAMIC, MVAR, or NMVAR statement.
Note: If the first character in a quoted string is neither a blank character nor
an alphanumeric character, and SPLIT is not in effect, the TEXT
statement treats that character as the split character. See the discussion of
the SPLIT= option in the “DEFINE HEADER Statement” on page 594.
Default
If you omit a TEXT statement, the text of the header is the label of the
object that the header applies to.
Tip
If the quoted string is a blank and it is the only item in the header or
footer specification, the header or footers a blank line.
Example
“Example 3: Creating a New Table Template ” on page 624
TEXT2 Statement
Provides an alternative header or footer to use in the LISTING output if the header or footer that is
provided by the TEXT statement is too long.
Restriction:
See:
The TEXT2 statement can be used only within a header or footer template.
“TEXT Statement” on page 603
Syntax
TEXT2 header/footer-specification(s)
Required Argument
header/footer-specification(s)
specifies the text of the header or footer. Each header/footer-specification is one of
the following:
_LABEL_
uses the label of the object that the header applies to as the text of the header. For
example, if the header or footer is for a column, _LABEL_ specifies the label for
the variable that is associated with the column. If the header or footer is for a
table, _LABEL_ specifies the label for the data set that is associated with the
table.
text-specification(s)
specifies the text to use in the header or footer. Each text-specification is one of
the following:
•
a quoted string
•
a variable, followed by an optional format. The variable is any variable that is
declared in a DYNAMIC, MVAR, or NMVAR statement.
TRANSLATE INTO Statement 605
Note: If the first character in a quoted string is neither a blank character nor
an alphanumeric character, and SPLIT is not in effect, the TEXT
statement treats that character as the split character. See the discussion of
the SPLIT= option in the “DEFINE HEADER Statement” on page 594.
TEXT3 Statement
Provides an alternative header or footer to use in the LISTING output if the header or footer that is
provided by the TEXT2 statement is too long.
Restriction:
See:
The TEXT3 statement can be used only within a header or footer template.
“TEXT Statement” on page 603
Syntax
TEXT3 header/footer-specification(s)
Required Argument
header/footer-specification(s)
specifies the text of the header or footer. Each header/footer-specification is one of
the following:
_LABEL_
uses the label of the object that the header applies to as the text of the header. For
example, if the header or footer is for a column, _LABEL_ specifies the label for
the variable that is associated with the column. If the header or footer is for a
table, _LABEL_ specifies the label for the data set that is associated with the
table.
text-specification(s)
specifies the text to use in the header or footer. Each text-specification is one of
the following:
•
a quoted string
•
a variable, followed by an optional format. The variable is any variable that is
declared in a DYNAMIC, MVAR, or NMVAR statement.
Note: If the first character in a quoted string is neither a blank character nor
an alphanumeric character, and SPLIT is not in effect, the TEXT
statement treats that character as the split character. See the discussion of
the SPLIT= option in the “DEFINE HEADER Statement” on page 594.
TRANSLATE INTO Statement
Translates the specified numeric values to other values.
Restrictions:
The TRANSLATE INTO statement can be used only in a column template, an ODS
list, an ODS textblock, or a table template.
The TRANSLATE INTO statement in a table template applies only to numeric
variables. To translate the values of a character variable, use TRANSLATE INTO in
the template of that column.
606
Chapter 16
Example:
•
TEMPLATE Procedure: Creating Tabular Templates
“Example 4: Setting the Style Element for Cells Based on Their Values” on page
632
Syntax
TRANSLATE expression-1 INTO expression-2 <, expression-n INTO expression-m>;
Required Arguments
expression-1
is an expression that is evaluated for each list item, paragraph, table, or column cell
that contains a numeric variable.
If expression-1 resolves to TRUE (a nonzero value), the translation that is specified
is used for the current cell. If expression-1 is FALSE (zero), the next expression in
the statement is evaluated. Thus, you can string multiple expressions together to
format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common
values in table or column templates. Built-in variables are one or more of the
following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
_LABEL_
is a column label.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
TRANSLATE INTO Statement 607
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style element name.
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 16.4
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one or more from a list of
values
Restriction
You cannot reference the values of other columns in expression-1.
Tip
Using an expression of 1 as the last expression in the TRANSLATE–
INTO statement specifies a translation for any cells that did not meet an
earlier condition.
See
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
608
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
expression-2
is an expression that specifies the value to use in the list, paragraph, or cell in place
of the variable's actual value.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and
operands. An operator is a symbol that requests a comparison, logical operation,
or arithmetic calculation. An operand is one of the following:
constant
is a fixed value such as the name of a column or symbols that are declared in
a DYNAMIC, MVAR, or NMVAR statement in the current template.
SAS function
specifies a SAS function. For information about SAS functions, see SAS
Functions and CALL Routines: Reference.
Built-in variable
a special type of WHERE expression operand that helps you find common
values in table templates. Built-in variables are one or more of the following:
_COLUMN_
is a column number. Column numbering begins with 1.
Alias
_COL_
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_DATANAME_
is a data column name.
_DATATYPE_
is the data type of the column variable. The data type is either numeric
("num") or character ("char").
_LABEL_
is a column label
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_ROW_
is a row number. Row numbering begins with 1.
Example
“Example 5: Setting the Style Element for a Specific Column,
Row, and Cell” on page 637
_STYLE_
is a style element name.
See
For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
TRANSLATE INTO Statement 609
Example
“Example 6: Creating Master Templates” on page 644
_VAL_
is the data value of a cell.
Tip
Use _VAL_ to represent the value of the current column.
Example
“Example 6: Creating Master Templates” on page 644
comparison-operator
compares a variable with a value or with another variable. The following table
lists the comparison operators:
Table 16.5
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Restriction
expression-2 must resolve to a character value, not a numeric value.
Tip
When you translate a numeric value to a character value, the table
template or column template does not try to apply the numeric format
that is associated with the column. Instead, it simply writes the
character value into the formatted field, starting at the left. To rightjustify the value, use the JUSTIFY=ON attribute.
See
“JUSTIFY<=ON | OFF | variable>;” on page 663 column attribute
You can use any expression that can be used in the WHERE= data set
option. For information about expressions that you can use in the
WHERE data set option, see the WHERE data set option in SAS Data
Set Options: Reference and the section on WHERE-Expression
Processing in SAS Language Reference: Concepts.
Example
“Example 5: Setting the Style Element for a Specific Column, Row,
and Cell” on page 637
610
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Using the TEMPLATE Procedure to Create Tabular
Output
Values in Table Columns and How They Are Justified
The process of justifying the values in columns in a LISTING output is determined by
the format of the variable and the values of two attributes: JUST= and JUSTIFY=. It is a
three-step process:
1. ODS puts the value into the format for the column. Character variables are leftjustified within their format fields; numeric variables are right-justified.
2. ODS justifies the entire format field within the column width according to the value
of the JUST= attribute for the column, or, if that attribute is not set, JUST= for the
table. For example, if you right-justify the column, the format field is placed as far to
the right as possible. However, the placement of the individual numbers and
characters within the field does not change. Thus, decimal points remain aligned. If
the column and the format field have the same width, then JUST= has no apparent
effect because the format field occupies the entire column.
3. If you specify JUSTIFY=ON for the column or the table, ODS justifies the values
within the column without regard to the format field. By default, JUSTIFY=OFF.
For example, consider this set of values:
123.45
234.5
.
987.654
If the values are formatted with a 6.2 format and displayed in a column with a width of
6, they appear this way, regardless of the value of JUST= (asterisks indicate the width of
the column):
******
123.45
234.50
.
987.65
If the width of the column increases to 8, then the value of JUST= does affect the
placement of the values, because the format field has room to move within the column.
Notice that the decimal points remain aligned but that the numbers shift in relation to the
column width.
just=left
just=center
just=right
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
Now, if you add JUSTIFY=ON, then the values are formatted within the column without
regard to the format width. The results are as follows:
Using the TEMPLATE Procedure to Create Tabular Output
justify=on
just=left
justify=on
just=center
justify=on
just=right
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
********
123.45
234.50
.
987.65
611
All destinations except LISTING justify the values in columns as if JUSTIFY=ON.
Formatting Values in Table Columns
The process of formatting the values in columns in a LISTING output is determined by
the format of the variable and the values of three options: FORMAT=,
FORMAT_WIDTH=, and FORMAT_NDEC=. It is a four-step process:
1. If you omit a FORMAT= option, then the format that the data component provides is
used. If the data component does not provide a format, then ODS uses one of the
following:
•
best8. for integers
•
D12.3 for doubles
•
the length of the variable for character variables
2. If a format width is specified in the FORMAT= option, then it takes precedence over
the FORMAT_WIDTH= and FORMAT_NDEC= options.
3. If you specify a decimal width with the FORMAT= and FORMAT_NDEC= options,
then the format that is specified with the FORMAT= option is used.
4. If you specify a format width with the FORMAT= and FORMAT_WIDTH= options,
then the format that is specified with FORMAT= option is used.
The formatting attributes of a column are determined by the data component or the
column template. This table summarizes the behavior of the column formatting attributes
based on which attributes the column template provides.
Table 16.6
Summary of Column Formatting Attributes
Specifications Provided by the
Column Template
Result
Nothing
Format name, width, and number of decimal places are
determined by the data component.
Format name
Format name and width are determined by the column
template; number of decimal places is determined by the
data component.
Format name and width
Format name and width are determined by the column
template.
Format name, width, and number of
decimal places
All three are determined by the column template.
612
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Specifications Provided by the
Column Template
Result
Width
No name is specified; width is determined by the column
template; number of decimal places is determined by the
data component.
Number of decimal places
No name is specified; width is determined by the data
component; number of decimal places is determined by
the column template.
Stacking Values for Two or More Variables
To stack values for two or more variables in the same column, put parentheses around
the stacked variables. In such a case, the column header for the first column inside the
parentheses becomes the header for the column that contains all the variables inside
parentheses. For example, this COLUMN statement produces a template with the
following characteristics:
•
The value of NAME is in the first column by itself.
•
The values of CITY and STATE appear in the second column with CITY above
STATE. The header for this column is the header that is associated with CITY.
•
The values HOMEPHONE and WORKPHONE appear in the third column with
HOMEPHONE above WORKPHONE. The header for this column is the header that
is associated with HOMEPHONE.
column name (city state) (homephone workphone);
Use the asterisk (*) in the COLUMN statement to change the layout of stacking
variables. An asterisk between groups of variables in parentheses stacks the first item in
the first set of parentheses above the first item in the next set of parentheses, and so on,
until the last group of parentheses is reached. Then, the second item in the first group is
stacked above the second item in the second group, and so on. For example, this
COLUMN statement produces a report with the following characteristics:
•
The value of NAME is in the first column by itself.
•
The values of CITY and HOMEPHONE appear in the second column with CITY
above HOMEPHONE. The header for this column is the header that is associated
with CITY.
•
The values STATE and WORKPHONE appear in the third column with STATE
above WORKPHONE. The header for this column is the header that is associated
with STATE.
column name (city state) * (homephone workphone);
Example 1: Editing a Table Template That a SAS Procedure Uses
613
Examples: TEMPLATE Procedure: Creating
Tabular Templates
Example 1: Editing a Table Template That a SAS Procedure Uses
Features:
EDIT statement
Header attributes
JUST=
STYLE=
Table attributes
DOUBLE_SPACE=
OVERLINE=
UNDERLINE=
Other features:
Data set:
Other ODS features
ODS LISTING statement
ODS SELECT statement
DELETE statement
Exprev
Details
This example customizes the table template for the Moments output object from PROC
UNIVARIATE. The first program uses the table template that SAS supplies to generate
both LISTING output and HTML output of the Moments object.
Note: This example uses filenames that might not be valid in all operating
environments. To successfully run the example in your operating environment, you
might need to change the file specifications. See “ODS HTML Statements for
Running Examples in Different Operating Environments” in SAS Output Delivery
System: User's Guide.
The second program does the following:
•
creates and edits a copy of the default table template
•
edits a header within the table template
•
sets column attributes to enhance the appearance of both the HTML and the
LISTING output
Program 1: Using the Default Table Template That SAS Provides
options nodate pageno=1 pagesize=60 linesize=72;
ods listing;
ods select moments;
proc univariate data=exprev mu0=3.5;
var Quantity;
title "Default Moments Table";
614
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
run;
ods listing close;
Program Description
Set the SAS system options. The OPTIONS statement controls several aspects of the
LISTING output.
options nodate pageno=1 pagesize=60 linesize=72;
Create the LISTING output. The ODS LISTING statement opens the LISTING
destination and creates LISTING output.
ods listing;
Select the output objects for the report. The ODS SELECT statement sends one
output object, Moments, to the open ODS destinations. Both the LISTING and the
HTML destinations are open.
To learn the names of the output objects, run the procedure with the ODS TRACE ON
statement in effect. For more information see “ODS TRACE Statement” on page 68.
ods select moments;
Compute the descriptive statistics for one variable. PROC UNIVARIATE computes
the univariate statistics for one variable, Quantity. It uses the default table template,
Base.Univariate.Moments from the template store Sashelp.Tmplmst.
proc univariate data=exprev mu0=3.5;
var Quantity;
title "Default Moments Table";
run;
Stop the creation of the LISTING output. The ODS LISTING CLOSE statement closes
the LISTING destination and all the files that are associated with it. You must close the
destination before you can view the output.
ods listing close;
Output from Program 1
Output 16.1
LISTING Output from PROC UNIVARIATE (Default Moments Table)
Example 1: Editing a Table Template That a SAS Procedure Uses
Output 16.2
HTML Output from PROC UNIVARIATE (Default Moments Table)
Program 2: Using a Customized Table Template
ods path sasuser.templat(update) sashelp.tmplmst(read);
proc template;
edit base.univariate.moments;
double_space=on;
underline=on;
overline=on;
label="Custom Moments";
double_space=on;
style=data{color=orange fontstyle=italic};
edit head;
style=header{color=green fontstyle=italic};
just=left;
end;
end;
run;
ods listing;
ods select moments;
proc univariate data=exprev mu0=3.5;
var Quantity;
title "Custom Moments Table";
run;
ods listing close;
proc template;
delete base.univariate.moments;
end;
title;
615
616
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
Program Description
Specify the search path in order to locate the table template. The ODS PATH
statement specifies which locations to search for definitions or templates that were
created by PROC TEMPLATE, as well as the order in which to search for them. The
statement is included to ensure that the example works correctly. However, if you have
not changed the path, you do not need to include this statement because it specifies the
default path.
ods path sasuser.templat(update) sashelp.tmplmst(read);
Create a modified table template Base.Univariate.Moments. The EDIT statement
looks in the available template stores for a table template called
Base.Univariate.Moments. By default, it first looks in Sasuser.Templat, but it finds
nothing. Next, it looks in Sashelp.Tmplmst, which contains the table templates that SAS
provides. Because the EDIT statement can read this template, this is the one that it uses.
The program does not specify a destination for the edited template, so PROC
TEMPLATE writes to the first template store in the path that it can write to, which is
Sasuser.Templat. Therefore, it creates a table template of the same name as the original
one in Sasuser.Templat.
To learn the name of the table template that a procedure uses, run the procedure with the
ODS TRACE ON statement in effect.For more information see “ODS TRACE
Statement” on page 68.
proc template;
edit base.univariate.moments;
Specify changes to the Moments output object for the LISTING output. These three
table attributes affect the presentation of the Moments output object in the listing output.
They have no effect on its presentation in the HTML output. DOUBLE_SPACE= creates
double spaces between the rows of the output object. OVERLINE= and UNDERLINE=
draw a continuous line before the first row of the table and after the last row of the table.
double_space=on;
underline=on;
overline=on;
Specify changes to the Moments output object for the HTML destination. These
three table attributes affect the presentation of the Moments output object in the HTML
output. DOUBLE_SPACE=ON specifies to double space between the rows of the table.
The STYLE= statements specify a color and font style for the cell data. The LABEL=
attribute changes the label that appears in the Results window from "Moments" to
"Custom Moments".
label="Custom Moments";
double_space=on;
style=data{color=orange fontstyle=italic};
Modify a table element. The following EDIT statement edits the table element Head
within the table template.
edit head;
Modify the appearance of the header. The STYLE= attribute alters the style element
that produces the Head table element. The style element Header is defined in the default
style, Styles.HTMLBlue. Many procedures, including PROC UNIVARIATE, use this
style element to produce headers for tables and columns. In this case, the STYLE=
Example 1: Editing a Table Template That a SAS Procedure Uses
617
attribute specifies green for the foreground color and italic for the font style. All other
attributes that are included in Header remain in effect. The STYLE= attribute affects
only the HTML output.
For information about viewing a style, see “Style Templates” in SAS Output Delivery
System: User's Guide. For a table of style element names, see Chapter 21, “Style
Elements,” on page 831.
style=header{color=green fontstyle=italic};
Left-justify the header text. The JUST= attribute left-justifies the text of the header in
both the listing and the HTML output.
just=left;
Stop the editing of the table element and the table template. The first END statement
ends the editing of the table element Head. The second END statement ends the editing
of the table Base.Univariate.Moments.
end;
end;
run;
Create the LISTING output. The ODS LISTING statement opens the LISTING
destination and creates LISTING output.
ods listing;
Select the output objects for the report. The ODS SELECT statement sends one
output object, Moments, to the open ODS destinations. Both the LISTING and the
HTML destinations are open. To learn the names of the output objects, run the procedure
with the ODS TRACE ON statement in effect.
ods select moments;
Compute the descriptive statistics for one variable. PROC UNIVARIATE computes
the univariate statistics for one variable, Quantity. The actual results of the procedure
step are the same in this case, but they are presented differently because the procedure
uses the edited table template. It does so because when it looks for
Base.Univariate.Moments, it looks in the first template store in the path,
Sasuser.Templat. If you wanted to use the table template that is supplied by SAS, you
would have to change the path with the ODS PATH statement.
See also: “ODS PATH Statement” in SAS Output Delivery System: User's Guide .
proc univariate data=exprev mu0=3.5;
var Quantity;
title "Custom Moments Table";
run;
Stop the creation of the LISTING output. The ODS LISTING CLOSE statement closes
the LISTING destination and all the files that are associated with it. You must close the
destination before you can view the output.
ods listing close;
Remove the customized moments table template from Sasuser.Templat. The
DELETE statement removes the customized moments table that was created in this
example. When using the DELETE statement, ODS looks for
618
Chapter 16
•
TEMPLATE Procedure: Creating Tabular Templates
base.univariate.moments in Sasuser.Templat first. If it is there, it deletes it. If
not, it searchs Sashelp.Tmplmst.
proc template;
delete base.univariate.moments;
end;
title;
Output for Program 2
Output 16.3
LISTING Output (Customized Moments Table) from PROC UNIVARIATE
Output 16.4 Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with
Microsoft Internet Explorer)
Example 2: Comparing the EDIT Statement to the DEFINE TABLE
Statement
Features:
EDIT statement
COLUMN statement
DEFINE statement
STYLE= attribute
NOTES statement
DYNAMIC statement
Example 2: Comparing the EDIT Statement to the DEFINE TABLE Statement
Other features:
Data set:
619
Other ODS features
ODS PATH statement
ODS HTML statement
DELETE statement
Exprev
Details
This example compares the use of an EDIT statement with a DEFINE TABLE statement
for the same table template. The first program uses the EDIT statement to change the
Base.Summary table template. The foreground color of the NOBS column is changed to
orange. The other templates and attributes of the Base.Summary table template remain
the same. The second program uses the DEFINE TABLE statement to define a new table
using the same name, Base.Summary. The NOBS column is the only column defined in
the new table template. When the PROC SUMMARY step executes, only the NOBS
column is printed. The only style attribute