0% found this document useful (0 votes)
539 views1,608 pages

SAS Graph

SAS / GRAPH(r) 9. Reference, Volumes 1 and 2 Produced in the United States of America. No part of this publication may be reproduced without the prior written permission of the publisher. SAS and all other SAS Institute Inc. Product or trademarks are registered trademarks or trademarks of SAS Institute in the USA and other countries.

Uploaded by

api-3745663
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
539 views1,608 pages

SAS Graph

SAS / GRAPH(r) 9. Reference, Volumes 1 and 2 Produced in the United States of America. No part of this publication may be reproduced without the prior written permission of the publisher. SAS and all other SAS Institute Inc. Product or trademarks are registered trademarks or trademarks of SAS Institute in the USA and other countries.

Uploaded by

api-3745663
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SAS/GRAPH 9.

1 Reference
®

Volume 1
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2004. SAS/GRAPH® 9.1 Reference,
Volumes 1 and 2. Cary, NC: SAS Institute Inc.
SAS/Graph® 9.1 Reference, Volumes 1 and 2

Copyright © 2004, SAS Institute Inc., Cary, NC, USA


ISBN 1-59047-195-4
All rights reserved. Produced in the United States of America. 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.
U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related
documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in
FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987).

SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.

1st printing, January 2004

SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software
to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit
the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228.
®
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS
Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are trademarks of their respective companies.
Contents

What’s New xiii


Overview xiii
Details xiv

PART 1 SAS/GRAPH Concepts 1


Chapter 1 Introduction to SAS/GRAPH Software 3
Overview 4
Generating Graphs 4
About this Book 16
Conventions Used in This Book 16
Information You Should Know 20

Chapter 2 SAS/GRAPH Programs 25


Overview 25
Language Elements 26
SAS Data Sets 29
Using Engines with SAS/GRAPH Software 31
Running SAS/GRAPH Programs 31
Procedure Output and the Graphics Output Area 34

Chapter 3 Device Drivers 41


Overview 41
About Device Drivers 42
Selecting a Device Driver 43
Controlling Output with Device Drivers 45

Chapter 4 SAS/GRAPH Output 47


About SAS/GRAPH Output 48
Displaying Graphics Output on Monitors or Terminals 49
Printing Graphics Output 51
Storing Graphics Output in SAS Catalogs 53
Modifying SAS/GRAPH Output 55
Transporting and Converting Graphics Output 56
About Exporting SAS/GRAPH Output 59
Exporting SAS/GRAPH Output Interactively 62
Exporting SAS/GRAPH Output with Program Statements 62
Exporting SAS/GRAPH Output Using Modified Device Entries 72

Chapter 5 SAS/GRAPH Fonts 75


Overview 75
Specifying Fonts in SAS/GRAPH Programs 75
Using Hardware Fonts 78
iv

Specifying Special Characters 81


Using SAS/GRAPH Software Fonts 82

Chapter 6 SAS/GRAPH Colors and Images 91


Using SAS/GRAPH Colors and Images 92
Specifying Colors in SAS/GRAPH Programs 92
Specifying Images in SAS/GRAPH Programs 106

Chapter 7 SAS/GRAPH Statements 121


Overview 123
AXIS Statement 124
BY Statement 141
FOOTNOTE Statement 146
GOPTIONS Statement 146
LEGEND Statement 151
NOTE Statement 164
ODS HTML Statement 164
PATTERN Statement 169
SYMBOL Statement 183
TITLE, FOOTNOTE, and NOTE Statements 210
Example 1. Ordering Axis Tick Marks with SAS Datetime Values 226
Example 2. Specifying Logarithmic Axes 229
Example 3. Rotating Plot Symbols through the Colors List 231
Example 4. Creating and Modifying Box Plots 233
Example 5. Filling the Area between Plot Lines 236
Example 6. Enhancing Titles 238
Example 7. Using BY-group Processing to Generate a Series of Charts 240
Example 8. Creating a Simple Web Page with the ODS HTML Statement 245
Example 9. Combining Graphs and Reports in a Web Page 248
Example 10. Creating a Bar Chart with Drill-down for the Web 255
See Also 260

Chapter 8 Graphics Options and Device Parameters Dictionary 261


Introduction 261
Specifying Graphics Options and Device Parameters 261
Dictionary of Graphics Options and Device Parameters 262

PART 2 Bringing SAS/GRAPH Output to the Web 367


Chapter 9 Introducing SAS/GRAPH Output for the Web 369
Which Device Driver or Macro Do I Use? 369
Types of Web Presentations Available 370
Selecting a Type of Web Presentation 378
Generating Web Presentations 382
Changing the Location of Online Help for Java and ActiveX 385
v

Chapter 10 Creating Interactive Output for ActiveX 387


Overview 387
When to Use the ACTIVEX Device Driver 388
Installing the ActiveX Control 389
Generating Output for ActiveX 391
Configuring Drill-Down Links with ACTIVEX 392
ActiveX Examples 393
Creating Graphs Interactively 395

Chapter 11 Creating Interactive Output for Java 397


Overview 397
When to Use the JAVA Device Driver 398
Generating Output for Java 398
Configuring Drill-Down Links for Java and ActiveX 400
Examples of Interactive Java Output 415

Chapter 12 Attributes and Parameters for Java and ActiveX 421


Specifying Parameters and Attributes for Java and ActiveX 421
Parameter Reference for Java and ActiveX 424

Chapter 13 Generating Static Graphics 439


What is a Static Graphic? 439
Creating a Static Graphic with ODS 440
ACTXIMG and JAVAIMG Device Drivers Compared to GIF, JPEG, and PNG Device
Drivers 440
Developing Web Presentations with the JAVAIMG and ACTXIMG Device Drivers 442
Developing Web Presentations with the GIF, JPEG, and PNG Device Drivers 443
Naming Conventions Used for Image Output Files 445
Enhancing Web Presentations Generated with the GIF, JPEG, or PNG Device
Driver 446
Sample Programs for Static Images 447

Chapter 14 Generating Web Animation with GIFANIM 457


Developing Web Presentations with the GIFANIM Device Driver 457
When to Use the GIFANIM Device Driver 457
Creating an Animated Sequence 458
GOPTIONs for Configuring GIFANIM Presentations 459
Sample Programs: GIFANIM 459

Chapter 15 Generating Interactive Metagraphics Output 469


Developing Web Presentations for the Metaview Applet 469
Using ODS with JAVAMETA 470
Using the META2HTM Macro 471
Adding Run-Time Controls to a Presentation 471
Enhancing Web Presentations for the Metaview Applet 474
Specifying Non-English Resource Files and Fonts 474
Metaview Applet Parameters 475
vi

META2HTM Macro Arguments 478


Sample Programs: Metaview Applet 478

Chapter 16 Managing Web Output with ODS 487


Overview of ODS Enhancements for Web Output 487
Using ODS Styles 488
Managing ODS Destinations 489
ODS and Procedures that Support RUN-Group Processing 490
Specifying Body Files for Displaying Graphs 491
Controlling Titles and Footnotes with ODS Output 492
Adding Non-Graphics Output to a Web Page 494
Linking to Output through a Table of Contents 495
Linking to Output through a Table of Pages 496
Using Frames to Display ODS Output 497

Chapter 17 Generating Web Output with the Annotate Facility 499


Overview of Generating Web Output with the Annotate Facility 499
Generating Web Output with the Annotate Facility 499
Examples 501

Chapter 18 Creating Interactive Treeview Diagrams 503


Creating Treeview Diagrams 503
Enhancing Presentations for the Treeview Applet 506
DS2TREE Macro Arguments 507
Sample Programs: Treeview Macro 507

Chapter 19 Creating Interactive Constellation Diagrams 513


Creating Constellation Diagrams 513
Enhancing Presentations for the Constellation Applet 517
DS2CONST Macro Arguments 518
Sample Programs: Constellation Macro 518

Chapter 20 Creating Critical Success Factor Diagrams 527


Using the DS2CSF Macro 527
Enhancing Presentations for the Rangeview Applet 529
DS2CSF Macro Arguments 530
Sample Programs: DS2CSF Macro 530

Chapter 21 Macro Arguments for the DS2CONST, DS2TREE, DS2CSF, and META2HTM
Macros 535
Macro Arguments 535

Chapter 22 Enhancing Web Output 567


Enhancing Web Output 567
Adding Data Tips to Web Presentations 568
Adding Drill-Down Links to Web Presentations 571

Chapter 23 Troubleshooting Web Output 579


vii

Troubleshooting Web Output 579


Checking Browser Permissions 582
Using HTML Character Entities 582
Connecting to Web Servers that Require Authentication 583
Removing CLASSPATH Environment Variables 583
Correcting Text Fonts 583
Resolving Colors in Netscape 583
Resolving Differences Between Client and Server Graphs 584

PART 3 The Annotate Facility 585


Chapter 24 Using Annotate Data Sets 587
Overview 587
About the Annotate Data Set 589
About Annotate Graphics 595
Creating an Annotate Data Set 599
Producing Graphics Output from Annotate Data Sets 601
Annotate Processing Details 602
Examples 604

Chapter 25 Annotate Dictionary 613


Annotate Dictionary Overview 614
Annotate Functions 615
Annotate Variables 642
Annotate Internal Coordinates 678
Annotate Macros 679
Using Annotate Macros 697
Annotate Error Messages 699

PART 4 SAS/GRAPH Procedures 705


Chapter 26 The GANNO Procedure 707
Overview 707
Procedure Syntax 708
Examples 710

Chapter 27 The GAREABAR Procedure 725


Overview 725
Concepts 726
Procedure Syntax 727
Examples 729

Chapter 28 The GBARLINE Procedure 739


Overview 739
Concepts 741
Procedure Syntax 749
viii

Examples 768

Chapter 29 The GCHART Procedure 773


Overview 774
Concepts 778
Procedure Syntax 785
Examples 842
References 884

Chapter 30 The GCONTOUR Procedure 885


Overview 885
Concepts 885
Procedure Syntax 888
Examples 904
References 913

Chapter 31 The GDEVICE Procedure 915


Overview 916
Concepts 916
Procedure Syntax 920
Using the GDEVICE Procedure 928
Examples 936

Chapter 32 The GFONT Procedure 939


Overview 939
Concepts 940
Procedure Syntax 942
Creating a Font 951
Examples 962

Chapter 33 The GIMPORT Procedure 969


Overview 969
Concepts 970
Procedure Syntax 972
Examples 976
References 981

Chapter 34 The GKEYMAP Procedure 983


Overview 983
Concepts 983
Procedure Syntax 988
Examples 990

Chapter 35 The GMAP Procedure 995


Overview 996
Concepts 999
Procedure Syntax 1007
ix

Using FIPS Codes and Province Codes 1033


Using Formats for Maps 1035
SAS/GRAPH Map Data Sets Reference Information 1038
Examples 1045

Chapter 36 The GOPTIONS Procedure 1075


Overview 1075
Procedure Syntax 1076
Examples 1078

Chapter 37 The GPLOT Procedure 1081


Overview 1081
Concepts 1085
Procedure Syntax 1088
Examples 1120

Chapter 38 The GPRINT Procedure 1147


Overview 1147
Concepts 1148
Procedure Syntax 1148
Examples 1153

Chapter 39 The GPROJECT Procedure 1161


Overview 1161
Concepts 1163
Procedure Syntax 1167
Using the GPROJECT Procedure 1172
Examples 1173
References 1182

Chapter 40 The GRADAR Procedure 1183


Overview 1183
Procedure Syntax 1184
Examples 1196

Chapter 41 The GREDUCE Procedure 1213


Overview 1213
Concepts 1215
Procedure Syntax 1215
Using the GREDUCE Procedure 1218
Examples 1220
References 1222

Chapter 42 The GREMOVE Procedure 1223


Overview 1223
Concepts 1224
Procedure Syntax 1226
x

Examples 1228

Chapter 43 The GREPLAY Procedure 1237


Overview 1238
Concepts 1239
Procedure Syntax 1242
Using the GREPLAY Procedure 1264
Examples 1270

Chapter 44 The GSLIDE Procedure 1277


Overview 1277
Procedure Syntax 1278
Examples 1282

Chapter 45 The GTESTIT Procedure 1285


Overview 1285
Procedure Syntax 1290
Examples 1291

Chapter 46 The G3D Procedure 1295


Overview 1295
Concepts 1297
Procedure Syntax 1300
Examples 1314
References 1325

Chapter 47 The G3GRID Procedure 1327


Overview 1327
Concepts 1329
Procedure Syntax 1331
Examples 1336
References 1346

Chapter 48 The MAPIMPORT Procedure 1347


Overview 1347
Procedure Syntax 1348
Examples 1349

PART 5 The Data Step Graphics Interface 1351


Chapter 49 The DATA Step Graphics Interface 1353
Overview 1354
Applications of the DATA Step Graphics Interface 1356
Using the DATA Step Graphics Interface 1357
DSGI Graphics Summary 1360

Chapter 50 DATA Step Graphics Interface Dictionary 1401


xi

Overview 1401
GASK Routines 1404
GDRAW Functions 1446
GRAPH Functions 1457
GSET Functions 1462
Return Codes for DSGI Routines and Functions 1501
See Also 1502
References 1503

PART 6 Appendixes 1505


Appendix 1 Summary of ActiveX and Java Support 1507
Introduction 1508
Global Statements 1508
PROC GAREABAR 1518
PROC GBARLINE 1519
PROC GCHART 1521
PROC GCONTOUR 1526
PROC GMAP 1527
PROC GPLOT 1530
PROC GRADAR 1535
PROC G3D 1537
Annotate Functions 1539

Appendix 2 Recommended Reading 1547


Recommended Reading 1547

Glossary 1549

Index 1561
xii
xiii

What’s New

Overview
It’s easier than ever to produce enhanced and detailed, informative graphics for your
Web presentations. New features in SAS/GRAPH include:
3 three new procedures: GAREABAR, GBARLINE, and MAPIMPORT
3 new options in the GCHART procedure for producing standard pie or donut charts
with a detailed, inner pie overlay
3 new options in the GRADAR procedure for adjusting how a chart looks and for
specifying annotation
3 support for the new DOCUMENT procedure for the Output Delivery System (ODS)
3 the new SAS Maps Online application
3 server-side rendering using the ACTXIMG and JAVAIMG devices
3 client support for annotation
3 client support for ODS styles
3 ActiveX support for creating graphs interactively
3 ActiveX support for radar charts produced with the GRADAR procedure
3 the new Java Constellation Applet
3 user interface enhancements for the client graphs, such as redesigned dialogs.
Note:
3 This section describes the features of SAS/GRAPH that are new or enhanced since
SAS 8.2.
3 z/OS is the successor to the OS/390 operating system. SAS/GRAPH 9.1 is
supported on both OS/390 and z/OS operating systems and, throughout this
document, any reference to z/OS also applies to OS/390, unless otherwise stated.
4
xiv What’s New

Details

Procedures
The following procedures are new or enhanced:
3 The GAREABAR procedure generates bar graphs in which the width of the bars
are proportional to a characteristic of the data element that is represented by the
bars. Area bar charts are supported only when you specify device=activex or
device=actximg. For more information, see Chapter 27, “The GAREABAR
Procedure,” on page 725.
3 The new GBARLINE procedure enables you to create vertical bar charts that have
line plot overlays.
Note: The GBARLINE procedure is not supported for Java. 4
For more information, see Chapter 28, “The GBARLINE Procedure,” on page 739.
3 The new MAPIMPORT procedure enables you to import ESRI Shapefiles into SAS/
GRAPH map data sets. For more information, see Chapter 48, “The MAPIMPORT
Procedure,” on page 1347.
3 The new DOCUMENT procedure for ODS enables you to re-arrange or to
duplicate reports—including graphs—without having to rerun your analysis. You
can display output to any ODS output format without executing your SAS
programs again. For more information, see the DOCUMENT procedure in SAS
Output Delivery System: User’s Guide.
3 New options in the PIE statement in the GCHART procedure enable you to create
detail pie charts that have an inner pie overlay. The slices in the overlay align
with the slices in the outer pie and show detailed information about the major
components that comprise the outer slice. The new options are DETAIL=,
DETAIL_PERCENT=, DETAIL_RADIUS=, DETAIL_SLICE=,
DETAIL_THRESHOLD=, and DETAIL_VALUE=. For more information, see
Chapter 29, “The GCHART Procedure,” on page 773.
3 The GRADAR procedure has the following new options:
3 ANNOTATE= specifies an annotate data set.
3 INBORDER requests a border around plots.
3 INHEIGHT= specifies the height in percent screen units of text used inside
the frame of the chart.
3 LAST= specifies that the spoke that corresponds to the category is displayed
to the left of the start angle.
3 MAXNVERT= specifies the maximum number of vertices.
3 MISSING accepts a missing value as a valid midpoint for the chart variable.
3 NOFRAME suppresses the frame that is drawn around the chart by default.
3 NOZEROREF turns off the zero reference line when negative values are
plotted.
3 OTHER= specifies a new category that merges all categories that are not
selected because of the MAXNVERT= option.
3 ORDERACROSS= specifies the display order for the values of the ACROSS=
variable.
3 SPIDER draws lines on a radar chart that connect the spokes instead of the
default tick marks. The resulting lines look similar to a “spider web.”
What’s New xv

3 STARINRADIUS= and STAROUTRADIUS= determine the diameter of the


stars.
For more information, see Chapter 40, “The GRADAR Procedure,” on page 1183.
3 The LEVELS=ALL option in the GMAP procedure uses a color ramp to assign a
continuous color scheme to each response value. For more information, see
Chapter 35, “The GMAP Procedure,” on page 995.

SYMBOL Statement
The SINGULAR= option tunes the algorithm that is used to check for singularities.

Graphics Options
The following graphics options are new:
USERINPUT
determines whether user input is enabled for the device. For more information,
see “USERINPUT” on page 359.
SWFONTRENDER
specifies the method used to render software fonts. For more information, see
“SWFONTRENDER ”on page 353.

The Annotate Facility


The following macros are new:
%CENTROID
retrieves the centroids of polygons. For more information, see “%CENTROID
Macro” on page 680.
%MAPLABEL
creates an output data set that can be used with the ANNO= option in PROC
GMAP. For more information, see “%MAPLABEL Macro” on page 686.

SAS Maps Online Application


The new SAS Maps Online application enables you to download: data updates,
sample SAS/GRAPH programs that use the map data sets delivered with SAS/GRAPH,
and GIF images of maps. SAS Maps Online is located at support.sas.com/rnd/
datavisualization/mapsonline/html

Pop-up Data Tips for Web Graphics


Web graphics now support pop-up data tips . A pop-up data tip is text that is
displayed when a user moves the cursor over a portion of a Web graphic. You can add
custom data tips to the output of any SAS/GRAPH procedure that supports the HTML=
option. For more information, see “Adding Data Tips to Web Presentations” on page 568.

Server-Side Rendering
The ACTXIMG and JAVAIMG devices generate images on the server that match the
look of the client graphs. These devices are especially useful when you do not need the
xvi What’s New

interactivity that is provided by the client graphs. ACTXIMG is only available for
Windows. For more information, see “ACTXIMG and JAVAIMG Device Drivers
Compared to GIF, JPEG, and PNG Device Drivers” on page 440.

Client Support for Annotation


The Java and ActiveX clients now support annotation through the Output Delivery
System (ODS) for the G3D, GBARLINE, GCHART, GCONTOUR, GMAP, GPLOT, and
GRADAR procedures. You can specify the ANNOTATE= option in these procedures
when you are using the JAVA, JAVAIMG, ACTIVEX, and ACTXIMG device drivers. All
annotate functions are available with each device driver (except the FRAME and
IMAGE functions, which are available only with ACTIVEX and ACTXIMG). For more
information, see “Annotate Functions” on page 1539.

Client Support for ODS Styles


ODS styles now affect both table and client graph output. Sixteen new graph styles
provide a consistent look for your entire ODS output, which enhances readability and
usability. For more information, see “Using ODS Styles” on page 488.

ActiveX Control
The following are enhancements for the ActiveX Control:
3 The ActiveX control now supports creating graphs interactively. You can import
data from SAS data sets, Microsoft Excel files, or Microsoft Access files.
Note: To create graphs interactively, you must have Enterprise Guide 2.0 HotFix
11 or higher installed.
3 The ActiveX control now supports radar charts that are produced by using the
GRADAR procedure.
3 The ActiveX control menus now enable the following additional languages:
Chinese, Japanese, Korean, and Russian. (The following languages were also
available in SAS 8.2: French, German, Hebrew, Hungarian, Italian, Polish, and
Spanish.

Java Constellation Applet and DS2CONST Macro


The new Java Constellation Applet, which you can generate by using the DS2CONST
macro, enables you to see the relationships among node link data, such as Web click
data, network flow data, and simple affinity data. You can interactively select a set of
nodes to see the relationships among the nodes. You can see all of the links coming to
the set of nodes or going out of a set of nodes. For more information, see “Creating
Constellation Diagrams” on page 513.

Java Treeview Applet and DS2TREE Macro


The new Java Treeview applet, which you can generate by using the DS2TREE
macro, shows the parent-child relationships of elements in a hierarchical structure. It
provides an optional “fish-eye” distortion that highlights the central area of interest,
and enables you to search for, hide, and display element subtrees. A Treeview diagram
What’s New xvii

is ideal for displaying data such as organizational charts or the hierarchical


relationships of the pages of a Web site. For more information, see Chapter 18,
“Creating Interactive Treeview Diagrams,” on page 503.

Java Contour Applet


The following are enhancements for the Java Contour Applet:
3 a new plot style, Smooth, enables you to display flat (linearly interpolated) planes
with no outlines.
3 several new parameters. For a complete list, see “Parameter Reference for Java
and ActiveX” on page 424.

Java Graph Applet


The following are enhancements in the Java Graph Applet:
3 For bar charts, error bars and the CERROR= option (which sets their color) are
now enabled. Bars can be labeled by statistics by using the OUTSIDE= and
INSIDE= options. Patterns are enabled for 2-D bars, and improved support for the
VALUE= option in the AXIS statement is provided.
3 For pie charts with group variables, the OTHER=, HTML=, INVISIBLE, and
EXPLODE options are available. Data tips can now be displayed for groups. The
V=EMPTY option in a PATTERN statement creates hollow pie slices. The
LABEL= option enables you to specify font height and color for donut charts.
3 Scatter plots now enable the BOX, STD, and HILOC interpolations. For these
interpolations, you can use the SYMBOL statement to specify colors, font height
and width, line type, point labels, and box width.
3 The Graph applet menus now enable the following additional languages: Chinese,
Japanese, Korean, and Russian. (The following languages were also available in
SAS 8.2: French, German, Hebrew, Hungarian, Italian, Polish, and Spanish.)
3 The MENUREMOVE parameter can be used to disable menus and menu options
in the applet’s user interface.

User-Defined Formats
The Java and ActiveX devices now support user-defined formats, except for nested
user-defined formats. For information about defining formats, see the documentation
for the FORMAT procedure in the Base SAS Procedures Guide.

Colors
Color names can now be a maximum of 64 characters in length.

Fonts
The following fonts have been added:
3 Davidb (Hebraic)
3 Fsong (Chinese)
3 Hebrewb
xviii What’s New

3 Hei (Chinese)
3 Mincho (Japanese)

PAGEFIT Attribute for PostScript


The new PAGEFIT image attribute enables you to adjust how a PostScript image fits
on the page. The PAGEFIT attribute replaces the NOFIT attribute. For more
information, see “Image Formats for Writing” on page 110.

GTITLE and GFOOTNOTE Options for the ODS Statement


The behavior of the GTITLE and GFOOTNOTE options has been changed—when
you specify NOGTITLE or NOGFOOTNOTE, the space in the graphic that would have
been used for the title or footnote is allocated to the procedure output rather than being
left empty. You need to be aware of this change if you are using annotation or mapping
coordinates. For more information, see “Controlling Where Titles and Footnotes are
Rendered” on page 492.

Enhancements in SAS/GRAPH Documentation


In addition to information about new features, the SAS/GRAPH documentation now
includes information about the following:
3 COLORMAC and HLPCLR macros and expanded information about choosing color
schemes
3 DSGI routine GASK (’PATREP’), and the functions GSET(’PATREP’) and
GRAPH(’PLAY’)
3 map formats that are available with the GMAP procedure
3 HTML generators, which are macros that generate HTML files that run one of the
SAS/GRAPH applets: DS2CONST (Constellation Applet), DS2TREE (Treeview
Applet), and DS2CSF (Rangeview Applet).
3 attributes and parameters for Java and ActiveX, which were formerly documented
in the SAS Output Delivery System: User’s Guide.
Also, additional examples of Web-output programs have been added to the
documentation and the SAS/GRAPH sample library. Documentation for the JAVA2
device driver has been removed, because JAVA and JAVA2 are now functionally
equivalent.
1

1
P A R T

SAS/GRAPH Concepts

Chapter 1. . . . . . . . . .Introduction to SAS/GRAPH Software 3

Chapter 2. . . . . . . . . .SAS/GRAPH Programs 25

Chapter 3. . . . . . . . . .Device Drivers 41

Chapter 4. . . . . . . . . .SAS/GRAPH Output 47

Chapter 5. . . . . . . . . .SAS/GRAPH Fonts 75

Chapter 6. . . . . . . . . .SAS/GRAPH Colors and Images 91

Chapter 7. . . . . . . . . .SAS/GRAPH Statements 121

Chapter 8. . . . . . . . . .Graphics Options and Device Parameters Dictionary 261


2
3

CHAPTER

1
Introduction to SAS/GRAPH
Software

Overview 4
Generating Graphs 4
Charts 4
Block charts 4
Horizontal bar charts 5
Vertical bar charts 5
Pie charts, 3-D Pie charts, and Donut charts 6
Star charts 6
Two-Dimensional Plots 6
Two-dimensional scatter plots 7
Simple line plots 7
Regression plots 7
High-low plots 8
Bubble plots 8
Three-Dimensional Plots 9
Surface plots 9
Scatter plots 9
Contour plots 10
Maps 11
Block maps 11
Choropleth maps 11
Prism maps 11
Surface maps 12
Creating Text Slide and Presentation Graphics 12
Text Slides 13
Combining Output into One Slide 13
Enhancing Graphics Output (graphs and text slides) 14
SAS/GRAPH Statements 14
The Annotate Facility 14
Creating Custom Graphics 15
The DATA Step Graphics Interface 15
Graph-N-Go 15
About this Book 16
Audience 16
Prerequisites 16
Conventions Used in This Book 16
Syntax Conventions 17
Conventions for Examples and Output 19
Information You Should Know 20
Support Personnel 20
Sample Programs 21
4 Overview Chapter 1

Map Data Sets 23


Annotate Macros Data Set 23

Overview
SAS/GRAPH software is the data visualization and presentation (graphics)
component of the SAS System. As such, SAS/GRAPH software:
3 organizes the presentation of your data and visually represents the relationship
between data values as two- and three-dimensional graphs, including charts, plots,
and maps.
3 enhances the appearance of your output by allowing you to select text fonts, colors,
patterns, and line styles, and control the size and position of many graphics
elements.
3 creates presentation graphics. SAS/GRAPH software can create text slides, display
several graphs at one time, combine graphs and text in one display, and create
automated presentations.
3 generates a variety of graphics output that you can display on your screen or in a
Web browser, store in catalogs, review, or send to a hardcopy graphics output
device such as a laser printer, plotter, or slide camera.
3 provides utility procedures and statements to manage the output.
This chapter describes the graphs that are produced by SAS/GRAPH software and
explains some of the parts and features of SAS/GRAPH programs.

Generating Graphs
SAS/GRAPH software produces many kinds of charts, plots, and maps in both two-
and three-dimensional versions. In addition to helping you understand the variety of
graphs that are available to you, these descriptions will also help you choose the correct
type of graph for your data and point you to the appropriate chapter.

Charts
SAS/GRAPH software uses the GCHART procedure to produce charts that
graphically represent the value of a statistic for one or more variables in a SAS data
set. See Chapter 29, “The GCHART Procedure,” on page 773 for a complete description.

Block charts
Block charts use three-dimensional blocks to graphically represent values of
statistics. Block charts are useful for emphasizing relative magnitudes and differences
among data values.
Introduction to SAS/GRAPH Software Charts 5

Horizontal bar charts


Horizontal bar charts use horizontal bars to represent statistics based on the values
of one or more variables. Horizontal bar charts can generate a table of chart statistics
and are useful for displaying exact magnitudes and emphasizing differences.

Vertical bar charts


Vertical bar charts use vertical bars to represent statistics based on the values of one
or more variables. Vertical bar charts, which generate only one statistic, are useful for
displaying exact magnitudes and emphasizing differences.
6 Two-Dimensional Plots Chapter 1

Pie charts, 3-D Pie charts, and Donut charts


Pie charts, 3-D Pie charts, and Donut charts use the angle of pie slices to graphically
represent the value of a statistic for a data range. Pie charts are useful for examining
how the values of a variable contribute to the whole and for comparing the values of
several variables.

Star charts
Star charts use the length of spines to graphically represent the value of a statistic
for a data range. Star charts are useful for analyzing where data are out of balance.

Two-Dimensional Plots
SAS/GRAPH software uses the GPLOT procedure to produce two-dimensional
graphs that plot one or more dependent variables against an independent variable
within a set of coordinate axes. GPLOT can display the data points as individual
symbols (as in a scatter plot), or use interpolation methods specified by the SYMBOL
statement to join the points, request spline interpolation or regression analysis, produce
various high-low plots, or generate several other types of plots.
GPLOT can also display data as bubble plots in which circles of different sizes
represent the values of a third variable.
Plots are useful for demonstrating the relationship between two or more variables and
frequently compare trends or data values or depict movements of data values over time.
See Chapter 37, “The GPLOT Procedure,” on page 1081 for a complete description.
Introduction to SAS/GRAPH Software Two-Dimensional Plots 7

Two-dimensional scatter plots


Two-dimensional scatter plots show the relationship of one variable to another, often
revealing concentrations or trends in the data. Typically, each variable value on the
horizontal axis can have any number of corresponding values on the vertical axis.

Simple line plots


Simple line plots show the relationship of one variable to another, often as
movements or trends in the data over a period of time. Typically, each variable value on
the horizontal axis has only one corresponding value on the vertical axis. The line
connecting data points can be smoothed using a variety of interpolation methods,
including the Lagrange and the cubic spline interpolation methods.

Regression plots
Regression plots specify that the plot is a regression analysis. You can specify one of
three types of regression equation – linear, quadratic, or cubic – and optionally display
confidence limits for mean predicted values or individual predicted values.
8 Two-Dimensional Plots Chapter 1

High-low plots
High-low plots show how several values of one variable relate to one value of another
variable. Typically, each variable value on the horizontal axis has several corresponding
values on the vertical axis. High-low plots include box, needle, and stock market plots.

Bubble plots
Bubble plots show the relative magnitude of one variable in relation to two other
variables. The values of two variables determine the position of the bubble on the plot,
and the value of a third variable determines the size of the bubble.
Introduction to SAS/GRAPH Software Three-Dimensional Plots 9

Three-Dimensional Plots
SAS/GRAPH software uses the G3D procedure to produce three-dimensional surface
and scatter plots that examine the relationship among three variables. Variable values
are plotted on a set of three coordinate axes.
See Chapter 46, “The G3D Procedure,” on page 1295 for a complete description.

Surface plots
Surface plots are three-dimensional plots that display the relationship of three
variables as a continuous surface. Surface plots examine the three-dimensional shape
of data.

Scatter plots
Scatter plots enable you to examine three-dimensional data points instead of surfaces
and to classify your data using size, color, shape, or a combination of these features.
10 Three-Dimensional Plots Chapter 1

Contour plots
SAS/GRAPH software uses the GCONTOUR procedure to examine
three-dimensional data in two dimensions. Lines or areas in a contour plot represent
levels of magnitude (z) corresponding to a position on a plane (x,y).
See Chapter 30, “The GCONTOUR Procedure,” on page 885 for a complete
description.
Contour plots are two-dimensional plots that show three-dimensional relationships.
These plots use contour lines or patterns to represent levels of magnitude of a contour
variable plotted on the horizontal and vertical axes.

When you need to interpolate or smooth data values that are used by the G3D and
GCONTOUR procedures, use the G3GRID procedure. The G3GRID procedure does not
produce graphics output but processes existing data sets to create data sets that the
G3D or GCONTOUR procedure can use to produce three-dimensional surface or contour
plots. See Chapter 47, “The G3GRID Procedure,” on page 1327 for a complete
description.
Introduction to SAS/GRAPH Software Maps 11

Maps
SAS/GRAPH software uses the GMAP procedure to produce two- and
three-dimensional maps that can show an area or represent values of response
variables for subareas.
SAS/GRAPH software includes data sets to produce geographic maps. In addition,
you can create your own map data sets.
See Chapter 35, “The GMAP Procedure,” on page 995 for a complete description.

Block maps
Block maps are three-dimensional maps that represent data values as blocks of
varying height rising from the middle of the map areas.

Choropleth maps
Choropleth maps are two-dimensional maps that display data values by filling map
areas with combinations of patterns and color that represent the data values.

Prism maps
Prism maps are three-dimensional maps that display data by raising the map areas
and filling them with combinations of patterns and colors.
12 Creating Text Slide and Presentation Graphics Chapter 1

Surface maps
Surface maps are three-dimensional maps that represent data values as spikes of
varying heights.

SAS/GRAPH software also provides several utility procedures for handling map data.
The GPROJECT procedure lets you choose how geographic maps are projected. This
is particularly important for large areas because producing a map of any large area on
the Earth involves distorting some areas in the process of projecting the spherical
surface of the Earth onto a flat plane. You can use the procedure to select the projection
method that least distorts your map.
Map areas are constructed of joined data points. Each data point represents an
observation in a SAS data set. For large maps, the amount of data can be prohibitively
expensive (in terms of computing resources or time to process); the GREDUCE
procedure enables you to reduce the number of points in the data set. The GREMOVE
procedure enables you to remove boundary lines within a map.

Creating Text Slide and Presentation Graphics


You can use SAS/GRAPH software to create slide presentations of your graphs. With
SAS/GRAPH you can
3 create text slides with the GSLIDE and GPRINT procedures
3 combine several graphs into one output with the GREPLAY procedure
Introduction to SAS/GRAPH Software Creating Text Slide and Presentation Graphics 13

3 automatically or manually replay your graphs and text slides with the GREPLAY
procedure.

Text Slides
Use the GSLIDE procedure to create text slides in which you can specify a variety of
colors, fonts, sizes, angles, overlays, and other modifications as well as drawing lines
and boxes on the output.
See Chapter 44, “The GSLIDE Procedure,” on page 1277 for a complete description.
Text slides display text as graphics output. Text slides can be used as title slides for
presentations, or to produce certificates, signs, or other display text.

Use the GPRINT procedure to display as a graphic SAS procedure output that has
been saved in a text file. With GPRINT, you bring the text file into SAS/GRAPH and
then add titles, notes, and footnotes, and select colors for the output.
See Chapter 38, “The GPRINT Procedure,” on page 1147 for a complete description.

Combining Output into One Slide


Use the GREPLAY procedure to combine several graphs into a single output. You can
create special effects by overlaying or rotating the graphs at any angle.
Templated graphs display two or more graphs or text slides as one output by
replaying stored graphs into a template or framework. Like graphs and text slides,
templated graphs can be ordered in groups and stored in catalogs for replay as part of a
presentation.
14 Enhancing Graphics Output (graphs and text slides) Chapter 1

Figure 1.1 Templated graphs

In addition, you can use the GREPLAY procedure to create an automated or


user-controlled presentation of graphics output. The GREPLAY procedure enables you
to name, arrange, and customize the presentation of graphs that are stored in a catalog.
See Chapter 43, “The GREPLAY Procedure,” on page 1237 for a complete description.

Enhancing Graphics Output (graphs and text slides)

SAS/GRAPH Statements
You also can use global statements and graphics options in SAS/GRAPH programs.
With global statements, you can add titles and footnotes and control the appearance of
axes, symbols, patterns, and legends. With graphics options, you can control the
appearance of graphics elements by specifying default colors, fill patterns, fonts, text
height, and so on.

The Annotate Facility


The Annotate facility enables you to program graphics by using certain variables in
SAS data sets. It is often used to add text or special elements to the graphics output of
other procedures, although it also can be used to construct custom graphics output.
Text and graphics can be placed at coordinates derived from input data, as well as
coordinates expressed as explicit locations on the display.
Introduction to SAS/GRAPH Software Creating Custom Graphics 15

Figure 1.2 Annotated graphs

Creating Custom Graphics


The Annotate facility can also be used to generate custom graphics without using any
of the SAS/GRAPH graphing procedures.

The DATA Step Graphics Interface


The DATA Step Graphics Interface provides functions and calls that produce
graphics output from the DATA step, rather than from a procedure. The functions and
calls are similar in form to those specified by the ISO Graphic Kernal Standard (GKS);
however, the interface is not an implementation of the GKS. The form is similar enough
that many GKS-compliant programs may be converted easily to run as SAS/GRAPH
programs.

Graph-N-Go
To generate presentation graphs without writing any SAS/GRAPH code, you can use
Graph-N-Go (not available on mainframes). You can start Graph-N-Go in several ways:
3 from the menus in any SAS window, select
Solutions Reporting Graph-N-Go

3 submit either of the following from the SAS command line:


gng

graphngo

3 use an Explorer window to directly open a GFORM entry. Double-click (or


right-click and choose Open) on a GFORM entry to start a Graph-N-Go session
using that entry.
Information on using the application is in Graph–N-Go help, which you can access
from the application’s main window in either of two ways:
3 select
Help Using This Window
16 About this Book Chapter 1

3 press F1 (this may not work in some operating environments).


You can also get help for the application by submitting the following command from
the SAS command line:
help gng

About this Book


This book provides reference information for all facilities, procedures, statements,
and options that can be used with SAS/GRAPH software. This chapter describes what
you need to know to use SAS/GRAPH software, and what conventions are used in text
and example code. To gain full benefit from using this book, you should familiarize
yourself with the information presented in this chapter, and refer to it as needed.

Audience
This book is written for users who are experienced in using SAS System software.
You should understand the concepts of programming in the SAS language, and you
should have an idea of the tasks you want to perform with SAS/GRAPH software.

Prerequisites
The following table summarizes the SAS System concepts that you need to
understand in order to use SAS/GRAPH software:

To learn how to Refer to


invoke the SAS System at your site instructions provided by the SAS Software
Consultant at your site
use base SAS software SAS Language Reference: Concepts or SAS
use the DATA step to create and manipulate Language Reference: Dictionary
SAS data sets
use the SAS Text Editor to enter and edit text
allocate SAS data libraries and assign librefs documentation for using the SAS System under
create external files and assign filerefs the operating system for the hardware at your
site
manipulate SAS data sets using SAS procedures Base SAS Procedures Guide

Conventions Used in This Book


This section explains the conventions this book uses for text, SAS language syntax,
and file and library references. The book uses the following terms in discussing syntax:
keyword is a literal that is a primary part of the SAS language. (A literal
must be spelled exactly as shown, although it can be entered in
uppercase or lowercase letters.) Keywords in this book are procedure
Introduction to SAS/GRAPH Software Syntax Conventions 17

names, statement names, macro names, routine names, and function


names.
argument is an element that follows a keyword. It is either literal, or it is
user-supplied. It has a built-in value (for example, NODISPLAY), or
it has a value assigned to it (for example, COLOR=text-color).
Arguments that you must use are required arguments. Other
arguments are optional arguments, or simply options.
value is an element that follows an equal sign. It assigns a value to an
argument. It may be a literal, or it may be a user-supplied value.
parameter is a value assigned to an argument that itself takes a value, for
example, the COLOR= parameter of the LABEL= option in a
LEGEND statement, as shown in the following statement:
legend label=(color=blue);

Syntax Conventions
Type styles have special meanings when used in the presentation of SAS/GRAPH
software syntax in this book. The following list explains the style conventions for the
syntax sections:
UPPERCASE identifies SAS keywords such as the names of statements and
procedures (for example, PROC GCHART). Also identifies
arguments and values that are literals, (for example, NOLEGEND
and LABEL=NONE).
italic identifies arguments or values that you supply. Items in italic can
represent user-supplied values that are either
3 nonliteral values assigned to an argument (for example,
axis-color in COLOR=axis-color)
3 nonliteral arguments (for example, VBAR chart-variable. . . ; ).
In addition, an item in italics can be the generic name for a list of
arguments or parameters from which the user can choose (for
example, appearance-options).
The following symbols are used to indicate other syntax conventions:
< > (angle identify optional arguments. Any argument not enclosed in angle
brackets) brackets is required.
| (vertical bar) indicates that you can choose one value from a group. Values
separated by bars are mutually exclusive.
. . . (ellipsis) indicates that the argument following the ellipsis can be repeated
any number of times (plot-request <. . . plot-request-n>, for
example). If the ellipsis and the following argument are enclosed in
angle brackets, they are optional. In SAS/GRAPH software, an
ellipsis also indicates a range from which a value is selected
(LINE=1 . . . 46, for example).
The following examples illustrate the syntax conventions described in this section.
These examples contain selected syntax elements, not complete syntax.
PROC GANNO ANNOTATE=Annotate-data-set
<DATASYS>;
18 Syntax Conventions Chapter 1

3 PROC GANNO is in uppercase because it is a SAS keyword, the name of a


statement. The remaining elements are arguments for the statement.
3 ANNOTATE= is not enclosed in angle brackets because it is a required argument.
It is in uppercase to indicate that it is a literal and must be spelled as shown.
3 Annotate-data-set is in italic because it is a value that you must supply; in this
case, the value must be a data set name.
3 DATASYS is enclosed in angle brackets because it is an optional argument. It is in
uppercase to indicate that it is a literal and must be spelled as shown.
3 The ending semicolon (;) is required because it is outside the angle brackets for the
option.

SYMBOL <1 . . . 99>


<COLOR=symbol-color>
<MODE=EXCLUDE|INCLUDE>
<appearance-options>;

3 SYMBOL is in uppercase because it is a SAS keyword, the name of a statement.


The numbers 1 . . . 99 are in angle brackets because they are optional. The
ellipsis indicates that you choose one from the range of numbers 1 through 99.
The remaining elements are arguments for the statement.
3 COLOR= is enclosed in angle brackets because it is an optional argument.
3 Symbol-color is in italics because it represents a value that you specify.
3 MODE= is enclosed in angle brackets because it is an optional argument.
3 EXCLUDE and INCLUDE are in uppercase because they are literal values and
must be spelled exactly as shown. They are separated by a vertical bar (an or bar)
because you use one or the other but not both.
3 Appearance-options is in italics because it is a generic name for a list of options
that can be used in the SYMBOL statement.

HBAR chart-variable< . . . chart-variable-n>


</ <PATTERNID=BY | GROUP | MIDPOINT | SUBGROUP>
<statistic-options>>;

3 Chart-variable is italic because it is an argument that you supply. It is required


because it is not in angle brackets.
3 Chart-variable-n is enclosed in angle brackets because additional user-supplied
arguments are optional. The ellipsis before the argument indicates that it can be
repeated as many times as desired.
3 PATTERNID= is a literal option. The values BY, GROUP, MIDPOINT, and
SUBGROUP are literal values that are mutually exclusive. You can use only one,
and it must be spelled as shown.
3 Statistic-options is in italics because it is the generic name of a list of options that
affect the chart statistics.
When you are using an option, a statement, or a procedure whose syntax shows
arguments or values in italics, you must supply the argument or value. When the
argument or value is a font, color, or variable name, SAS/GRAPH software expects valid
Introduction to SAS/GRAPH Software Conventions for Examples and Output 19

font names, color names, and variable names. Consider the following four syntax
samples:

FONT=font

COLOR=color

COLOR=text-color

PIE chart-variable < . . . chart-variable-n>;

3 Font must be a valid SAS font name. (See Chapter 5, “SAS/GRAPH Fonts,” on
page 75 for details.)
3 Color and text-color must be valid SAS/GRAPH colors. (See Chapter 6, “SAS/
GRAPH Colors and Images,” on page 91 for details.)
3 Chart-variable must be a valid SAS variable name. (See SAS Language Reference:
Dictionary for details.)

Conventions for Examples and Output


Most of the chapters in this book include examples that illustrate some of the
features of a procedure or its statements. Each example contains
3 a description of the highlights of the example
3 the program statements that produce the output
3 the actual output from the example
3 an explanation of the features of the example.
The output that is shown for the examples in this book was generated in an HP-UX
operating environment, using the default XCOLOR display device. If you are using a
different operating environment or display device, you may need to make some minor
adjustments to the example programs.
The dimensions of the graphics output area vary across devices and when using the
GRAPH windows. The dimensions may affect aspects of the graphics output – for
example, the appearance of axes or the position of graphics elements that use explicit
coordinates in units other than percent. You may need to adjust the dimensions of your
graphics output area or the size of graphics elements to correct any differences you see.
Most of the examples in this book used a GOPTIONS statement to set the graphics
output area to 7 inches by 5 inches, which proved to be a good dimension for generating
output displays for this book:
goptions hsize=7in vsize=5in;

These HSIZE= and VSIZE= settings are not shown in the example code and are not
necessary for generating the output, but you may want to use similar settings if your
output looks different from the output that is shown in the book.
The examples use explicit color specifications, and the example code contains the
names of colors that approximate the colors you see in this book. The colors displayed
on your device may differ from those shown in the examples because of differences in
device capabilities.
20 Information You Should Know Chapter 1

The examples in this book do not specify actual names for the file structures used for
SAS data libraries or for external files. This is because different operating environments
and different computing installations use different conventions for naming files and
directories. Instead, the examples refer to storage locations generically. For example, a
LIBNAME statement to assign the libref STORE is shown as
libname store ’SAS-data-library’;

For SAS-data-library, you should supply the complete specification for the storage
location (for example, directory or z/OS data set) of the data library, using the form
required by your operating environment.
Similarly, a FILENAME statement to assign the fileref MYFILE is shown as
filename myfile ’external-file’;

For external-file, you should supply a fully qualified filename, using the form required
for your operating environment.
If you are unsure of the requirements at your site, see your SAS Software Consultant
for more information.
Some examples explicitly specify the font and height for text, the units, and border in
procedure statements. For those examples that do not include explicit specifications,
the following graphics options were used to produce uniform output:
RESET=GLOBAL cancels all currently defined AXIS, LEGEND, FOOTNOTE, TITLE,
PATTERN, and SYMBOL definitions.
GUNIT=PCT specifies the unit specification for options is in percent, unless
explicitly specified in another SAS statement.
FTEXT=SWISSB specifies that all text uses the SWISSB font, unless explicitly
specified in another SAS statement.
HTITLE=6 specifies that the first title line is 6 percent of the height of the
graphics output area, unless explicitly specified in another SAS
statement.
HTEXT=3 specifies that text is 3 percent of the height of the graphics output
area, unless explicitly specified.
BORDER causes a border to be drawn around the graphics output area. The
border, which appears in most output, represents the boundaries of
the graphics output area, whether or not a border is drawn by the
program.

Note: The way that output is presented on your device depends on the environment
in which you are running SAS/GRAPH software. 4

Information You Should Know


This section outlines information you should know before you attempt to run the
examples in this book.

Support Personnel
Most sites have personnel available to help users learn to run SAS System software.
Record the name of the SAS Software Consultant, SAS Software Representative, and
Introduction to SAS/GRAPH Software Sample Programs 21

system administrator at your site. Also record the names of anyone else you regularly
turn to for help with running SAS/GRAPH software.

Sample Programs
Most of the chapters in this book provide examples that demonstrate some of the
major features of SAS/GRAPH software. To minimize the typing you must do to run the
sample code yourself, the code is delivered to you through the SAS Sample Library.
Depending on your operating environment, there are up to three ways that you can
access the code that is in the sample library:
3 if you are viewing the sample code in SAS OnlineDoc, you can copy the code out of
the OnlineDoc and paste it into the Program Editor in your SAS session. This
alternative is not available if you do not have access to a Web browser in the
operating environment where you are running your SAS session.
3 in most operating environments (excluding mainframe environments), you can
access the sample code through the SAS Help facility. For example, from a SAS
window’s Help menu, you can choose SAS System Help to enter the help system.
You can then choose the link for Sample SAS Programs and Applications, which
takes you to the help page for the SAS Sample Library.
3 in most operating environments (excluding Windows), the SAS Sample Library
may have been installed in your file system. If the SAS Sample Library has been
installed at your site, ask your SAS Software Consultant where it is located.
To access the sample programs through SAS System Help or through your file
system, you must understand the naming convention used for the samples. The naming
convention for SAS/GRAPH samples is Gpcxxxxx, where pc is the product code and
xxxxx is an abbreviation of the example title. For example, the code for the first
example in the GMAP Procedure chapter, Example 1 on page 1045, is stored in sample
member GMPSIMPL. The sample-library member name is sometimes displayed as a
footnote in the output’s lower-right corner.
3 In SAS System Help, the sample programs are organized by product. Within each
product category, the samples are sorted alphabetically by title. Thus, to access
the code for the first example in the GMAP Procedure chapter, navigate in the
help system to the SAS Sample Library page, choose SAS/GRAPH from the list of
products, and then scroll to the listing "GMPSIMPL-Producing a Simple Block
Map."
3 In your file system, the files that contain the sample code have file names that
match the sample member names. For example, in a directory-based system, the
code for sample member GMPSIMPL is located in a file named GMPSIMPL.SAS.
Note: For WebGraph samples the naming convention is GWBxxxxx. 4

Note: Some of the examples include LIBNAME and FILENAME statements. You
must provide the name of the SAS data library or external file before running the
example. 4
22 Sample Programs Chapter 1

Table 1.1 Product Codes for SAS/Graph Proceedures

Procedure Code

dsgi DS
ganno AN

gchart CH
gradar GD

gcontour CT
gfont FO

gimport IP
gkeymap KY

gmap MP
goptions OP

gplot PL
gprint PR

gproject PJ
greduce RD

gremove RM
greplay RE

gslide SL
gtestit IT

g3d TD
g3grid TG

Table 1.2 Product Codes for SAS/Graph Statements

Statement Code

axis AX
by BY

footnote FO
goptions ON

legend LG
note NO

pattern PN
Introduction to SAS/GRAPH Software Annotate Macros Data Set 23

Statement Code

symbol SY
title TI

Table 1.3 Product Code for SAS/Graph WebGraphs

Statement Code
WebGraph WB

Map Data Sets


To run the examples that draw maps, you need to know where the map data sets are
stored on your system. Depending on your installation, the map data set may
automatically be assigned a libref. Ask your SAS Software Consultant or system
administrator where the map data sets are stored for your site.

Annotate Macros Data Set


To run the examples using Annotate macros, you need to know where the Annotate
macro data set is stored on your system. Depending on your installation, the Annotate
macro data set may automatically be assigned a fileref. Ask your SAS Software
Consultant or system administrator where the Annotate macro data set is stored for
your site.
24
25

CHAPTER

2
SAS/GRAPH Programs

Overview 25
Language Elements 26
SAS/GRAPH Procedures 26
SAS/GRAPH Global Statements 27
Annotate DATA Step 27
Other SAS Language Statements 27
FILENAME Statement 28
LIBNAME Statement 29
SAS Data Sets 29
Temporary and Permanent SAS Data Sets 29
Using a Library Reference to Specify a Data Set 30
Using a File Specification to Specify a Data Set 30
Data Set Requirements 31
Automatic Data Set Locking 31
Using Engines with SAS/GRAPH Software 31
Running SAS/GRAPH Programs 31
Modes of Operation 31
Running in Batch Mode 32
RUN-Group Processing 33
With global and local statements 33
With BY statements 33
With the WHERE Statement 33
Procedure Output and the Graphics Output Area 34
About the Graphics Output Area 34
External Dimensions 34
Device Resolution 35
Cells 36
Units 38
Placement of Graphic Elements in the Graphics Output Area 39
How Errors in Sizing Are Handled 40
Making Programs Portable 40

Overview
In general, SAS/GRAPH programs work like other SAS programs: the SAS/GRAPH
procedures use data from SAS data sets to produce output – in this case, graphics
output. In addition, SAS/GRAPH programs define the output environment and control
the format and destination of the graphics output. This chapter discusses SAS/GRAPH
programs and explains how they produce graphics output. It describes
3 the language elements used by SAS/GRAPH programs
26 Language Elements Chapter 2

3 ways of running SAS/GRAPH programs


3 where and how procedure output is produced
3 how to control certain attributes of the procedure output.
For information on using and managing SAS/GRAPH output, see Chapter 4, “SAS/
GRAPH Output,” on page 47; for information on using SAS/GRAPH programs to create
other kinds of graphics output, see “About Exporting SAS/GRAPH Output” on page 59.
For information on bringing SAS/GRAPH output to the Web, see Chapter 9,
“Introducing SAS/GRAPH Output for the Web,” on page 369.

Language Elements
The language elements used by SAS/GRAPH programs include SAS/GRAPH
procedures, SAS/GRAPH statements, and Annotate data sets. In addition to
SAS/GRAPH language elements, your SAS/GRAPH program may include Base SAS
statements and procedures that you use to process your data or control the destination
or format of your program output.

SAS/GRAPH Procedures
SAS/GRAPH procedures create graphics output, process data for other SAS/GRAPH
procedures to use, or manage graphics output that has been stored in a catalog. A
SAS/GRAPH procedure step typically contains these statements:
PROC statement
starts the procedure. Typically it identifies input and output data sets, and assigns
a destination for graphics output. For information on data sets and data
requirements, see “SAS Data Sets” on page 29. For information on assigning
graphics catalogs, see “Storing Graphics Output in SAS Catalogs” on page 53.
Subordinate statements
perform the work of the procedure; subordinate statements that generate graphs
are called action statements. For example, the HBAR statement in the GCHART
procedure is an action statement.
RUN statement
executes the statements in the procedure step. Use the QUIT statement to end the
procedure. See also “RUN-Group Processing” on page 33.
In addition, many SAS/GRAPH procedures can use the following statements:
BY statement
causes the procedure to produce multiple graphs, each corresponding to a BY
variable value. Each graph that is produced for a value of a BY variable is stored
as a separate catalog entry in either the default catalog, WORK.GSEG, or in the
catalog you specify with a GOUT= option in the PROC statement. See “BY
Statement” on page 141 for a complete description.
NOTE statement
adds text to the graphics output. See “TITLE, FOOTNOTE, and NOTE
Statements” on page 210 for a complete description.
You can also use other SAS language statements with SAS/GRAPH procedures. See
“Other SAS Language Statements” on page 27.
SAS/GRAPH Programs Other SAS Language Statements 27

SAS/GRAPH Global Statements


SAS/GRAPH has its own set of statements that affect only graphics output that is
generated by the SAS/GRAPH procedures and the graphics facilities Annotate and
DSGI.
SAS/GRAPH global statements define or modify the titles, footnotes, legends, axes,
symbols, and patterns that appear on your graphs, as well as controlling the
appearance of the graph, the graphics environment, the destination of the output, and
device characteristics.
You can specify these statements anywhere in your program, and they remain in
effect until explicitly changed or canceled. These are the SAS/GRAPH global statements:
AXIS
modifies the appearance, position, and range of values of axes in charts and plots.
GOPTIONS
specifies graphics options that control the appearance of graphics elements by
specifying characteristics such as default colors, fill patterns, fonts, or text height.
Graphics options can also temporarily change device settings.
LEGEND
modifies the appearance and position of legends generated by procedures that
produce charts, plots, and maps.
PATTERN
controls the color and fill of patterns that are assigned to areas in charts, maps,
and plots.
SYMBOL
specifies the shape and color of plot symbols as well the interpolation method for
plot data. It also controls the appearance of lines in contour plots.
TITLE and FOOTNOTE
add titles and footnotes to graphics output.
See Chapter 7, “SAS/GRAPH Statements,” on page 121 for complete descriptions of
these statements.

Annotate DATA Step


An Annotate DATA step generates a data set of graphics commands that can be
applied to SAS/GRAPH procedure output. See Chapter 24, “Using Annotate Data Sets,”
on page 587 for information on building and using Annotate data sets. See Chapter 25,
“Annotate Dictionary,” on page 613 for a complete description of all Annotate functions
and variables.

Other SAS Language Statements


These SAS language statements can also be used within SAS/GRAPH procedures:
FILENAME statements
identify external files or aggregate file storage locations that you want to use for
input or output. See “FILENAME Statement” on page 28 for more information.
FORMAT statement
assigns a format to a variable. SAS/GRAPH procedures use formatted values to
determine such aspects of the graph as midpoints, axis labels, tick-mark values,
and legend entries.
28 Other SAS Language Statements Chapter 2

LABEL statement
assigns a descriptive text string to a variable. Unless other text is specified in the
SAS/GRAPH program, the label appears in place of the variable name.
LIBNAME statements
identify SAS libraries that contain SAS data sets or catalogs that you want to use
with your SAS/GRAPH programs. See “LIBNAME Statement” on page 29 for more
information.
ODS statements
direct the output from certain SAS/GRAPH procedures to the Output Delivery
System.
The ODS LISTING statement directs PROC GDEVICE output to the SAS
listing file.
The ODS HTML statement is used with the GIF driver to direct graphics
output to one or more GIF files and create a variety of HTML files that can display
the GIF files in a Web browser. See “ODS HTML Statement” on page 164 for
information on using the ODS HTML statement with SAS/GRAPH procedures.
OPTIONS statement
changes the value of one or more SAS system options.
QUIT statement
executes any statements that have not executed and ends the procedure.
WHERE statement
specifies observations from SAS data sets that meet a particular condition. Using
a WHERE statement provides an easy way to graph a subset of your data.
For a complete description of these statements, see SAS Language Reference:
Dictionary.

FILENAME Statement
The FILENAME statement associates a SAS fileref with an external text file or
output device. With SAS/GRAPH software, you can use a FILENAME statement to
3 point to a text file that you want to use for data input or output.
3 assign the destination of a graphics stream file (GSF). This destination can be
either a single, specific file or an aggregate file storage location, such as directory
or PDS. See “About Exporting SAS/GRAPH Output” on page 59 for information on
creating graphics stream files.
You can also use the FILENAME statement to route input to and from other devices.
For details, see the SAS documentation for your operating environment.
A FILENAME statement that points to an external file has this general form:
FILENAME fileref ’external-file’;
fileref
is any SAS name.
external-file
is the physical name of the external file or aggregate file storage location you want
to reference. For details on specifying the physical names of external files, see the
SAS documentation for your operating environment.
For a complete description of the FILENAME statement, see SAS Language
Reference: Dictionary.
SAS/GRAPH Programs Temporary and Permanent SAS Data Sets 29

LIBNAME Statement
The LIBNAME statement associates a libref with a SAS data library. A SAS data
library can be either temporary or permanent. Typically, SAS data libraries used with
SAS/GRAPH software contain
3 SAS files for data input and output.
3 SAS catalogs that contain maps, fonts, or device entries.
3 SAS catalogs that contain graphics output. These catalogs are often stored in
permanent libraries. See “Storing Graphics Output in SAS Catalogs” on page 53
for information on storing graphics output in a permanent catalog.
The LIBNAME statement has this general form:
LIBNAME libref ’SAS-data-library’;
libref
is any SAS name.
SAS-data-library
is the physical name for the SAS data library on your host system. For details on
specifying SAS-data-library, see the SAS documentation for your operating
environment.
The libref WORK is reserved; it always points to an area where temporary data sets
and catalogs are kept. The contents of WORK are deleted when you exit a SAS session.
For a complete description of the LIBNAME statement, see SAS Language Reference:
Dictionary.

SAS Data Sets


Many SAS/GRAPH procedures use SAS data sets as input or output. When a
SAS/GRAPH procedure requires an input SAS data set, you usually specify the data set
with the DATA= option in the procedure statement, as shown in this example:
proc gplot data=reflib.stocks;

If you omit the DATA= option, the procedure uses the value of the SAS system option
_LAST_=. The default for _LAST_= is the most recently created SAS data set (either
permanent or temporary) in the current SAS job or session.
If you do not specify a data set and no data set has been created in the current SAS
session, an error occurs and the procedure stops.
Most of the procedures that read data sets or create output data sets accept data set
options. SAS data set options appear in parentheses after the data set specification, as
shown in this example:
proc gplot data=reflib.stocks(where=(year=1997));

For more information on SAS data sets and other data processing details, see SAS
Language Reference: Concepts. For a complete discussion of SAS data set options and
SAS system options, see SAS Language Reference: Dictionary.

Temporary and Permanent SAS Data Sets


SAS data sets are stored in SAS libraries and can be temporary or permanent. You
can specify a data set in either of two methods: using a library reference, or using a file
specification. A library reference is specified without quotation marks in the form
30 Temporary and Permanent SAS Data Sets Chapter 2

libref.SAS-data-set-name. A file specification must be enclosed in single quotation


marks and uses the file naming conventions of your operating environment.

Using a Library Reference to Specify a Data Set


Typically, temporary SAS data sets are stored in the WORK data library and are
referenced with a one-level name. The WORK library is defined automatically at the
beginning of the SAS session and is automatically deleted at the end of the SAS
session. Procedures assume that SAS data sets that are specified with a one-level name
are to be read from, or written to, the WORK data library, unless you specify a USER
data library. For example, this statement specifies a temporary data set from the
WORK library:
proc gplot data=stocks;

Typically, permanent SAS data sets have a two-level name of the form
libref.SAS-data-set-name in which libref identifies a storage location on your host
system. A LIBNAME statement associates a libref with the storage location. See also
“LIBNAME Statement” on page 29. For example, these statements specify a permanent
data set:
libname reflib ’my-SAS-library’;
proc gplot data=reflib.stocks;

You can use a one-level name for permanent SAS data sets if you specify a USER
data library. In this case, the procedure assumes that data sets with one-level names
are in the USER data library instead of in the WORK data library. You can assign a
USER data library with a LIBNAME statement or the USER= SAS system option. For
example, these statements use a single-level name to specify a permanent data set that
is stored in the library identified as the USER library:
options user=’my-SAS-library’;
proc gplot data=stocks;

Using a File Specification to Specify a Data Set


To use a file specification for specifying a data set, enclose the file specification in
single quotation marks. The specification can be a filename, or a path and filename. The
specification must follow the file naming conventions of your operating environment.
For example, the following code creates a file named mydata in the default storage
location, which is the location where the SAS session was started:
data ’mydata’;

The quotes are required for a file specification; if omitted, SAS treats the specification
as a library reference. In the above example, if the quotes are omitted, SAS creates the
data set in the temporary WORK catalog and identifies it by the name WORK.MYDATA.
To create the file in a location other than the default location, the quoted file
specification must include the full path to the desired location.
You cannot use quoted file specifications for
3 SAS catalog names
3 MDDB and FDB references
3 PROC SQL
3 the _LAST_= system option.
SAS/GRAPH Programs Modes of Operation 31

Data Set Requirements


SAS/GRAPH procedures often have certain requirements for the input data sets
they use. Some procedures may expect the input data set to be sorted in a certain way
while others may require the data set to contain certain variables or types of
information. If necessary, you can use DATA steps and base SAS procedures in your
program to manipulate the data appropriately. For specific requirements, see "About
the Input Data Set" in the "Concepts" section of the procedure chapter.

Automatic Data Set Locking


All SAS/GRAPH procedures that produce graphics output automatically lock the
input data sets during processing. By locking a data set, SAS/GRAPH software
prevents another user from updating the data at the same time you are using it to
produce a graph. If data in a data set changes while you are using it to draw a graph,
unpredictable results can occur in the graph or your program may end with errors.

Using Engines with SAS/GRAPH Software


In the SAS System, procedures use engines to access data. Characteristics of these
engines vary; generally, they allow SAS procedures to access a data library in a
particular way – the expected format for the SAS data file, the type of read/write
activity that can occur in SAS data files, and so on. In most cases, you use the default
engine for the current SAS version and do not specify an engine. If you are using an
engine other than the default, the engine must
3 support nonsequential access
3 equate observation numbers with internal record IDs (required for the GREDUCE
procedure only)
3 disallow shared update or spin a copy of the data set for input processing when a
procedure requires multiple passes over the data.

Note: The default engine for Versions 7 and 8 do not work with the GREDUCE
procedure if the input data set is compressed. 4
For more information about SAS engines, see SAS Language Reference: Concepts.

Running SAS/GRAPH Programs

Modes of Operation
There are several ways to run a SAS program. You can use
3 SAS windowing environment that gives you a text editor from which to submit
programs, windows for the SAS log and SAS output, and many other facilities
3 interactive line mode, in which you submit programs one line at a time
3 noninteractive mode, which executes a SAS program (stored in a file) in your
current terminal session
32 Running in Batch Mode Chapter 2

3 batch mode, which executes a SAS program (stored in a file) in a separate session.
The mode you use determines whether the graphics output displays on your monitor.
If you use the SAS windowing environment, interactive line mode, or noninteractive
mode, the SAS/GRAPH program can display graphics output on your monitor as well as
store the output in a catalog.
If you use batch mode, the graphics output is not displayed on your monitor. In this
case, your program must send the graphics output to a hardcopy device, permanent
catalog, or a graphics stream file. See Chapter 4, “SAS/GRAPH Output,” on page 47 for
more information on the destination of graphics output.
Regardless of how you run your programs, SAS/GRAPH software uses the values
stored in the device entry or specified by graphics options in a GOPTIONSChapter 36,
“The GOPTIONS Procedure,” on page 1075 statement to determine how to handle the
graphics output.

Running in Batch Mode


When you run in batch mode, some SAS/GRAPH device drivers such as device=GIF
attempt to use fonts from the X server to annotate the graph output. This can result in
a "CANNOT OPEN XDISPLAY" warning if the DISPLAY environment variable has not
been set.
To avoid this warning message, you can run in batch mode with the -NOTERMINAL
option. Although this suppresses the warning message, it has the disadvantage of not
allowing use of the high quality fonts that are available with the X server.
A better solution is to set your DISPLAY environment variable to any available X
server. This not only removes warning messages concerning the XDISPLAY, but it also
improves the quality of text in GIF output by using fonts avilable from the X server.
The GIF driver does not open any windows on the display referenced by the DISPLAY
variable.
An alternative solution does not require a display to be set. FreeType font support
can be enabled by setting CHARREC[0] in the device entry to use a TrueType or Type1
font available on your system as follows:
libname gdevice0 ’.’;
proc gdevice c=gdevice0.devices nofs;
copy gif from=sashelp.devices newname=mygif;
mod mygif charrec=(0,1,1, ’SAS Monospace’, ’Y’);
quit;

goptions reset=all dev=mygif ftext=’Arial’;


title h=5 ’Arial’;
proc gslide border;run;quit;

SAS Monospace is available on all hosts and other fonts can be made available by
running PROC FONTREG.
proc fontreg fontpath ’directory_containing_TT_or_Type1_fonts’;run;

FreeType font support is also available with the Universal GIF driver.
options dev=sasprtc printerpath=gif;
proc gtestit pic=1;run;
SAS/GRAPH Programs RUN-Group Processing 33

RUN-Group Processing
You can use RUN-group processing with the GCHART, GMAP, GPLOT, GREPLAY,
and GSLIDE procedures to produce multiple graphs without restarting the procedure
every time.
To use RUN-group processing, you start the procedure and then submit multiple
RUN-groups. A RUN-group is a group of statements that contains at least one action
statement and ends with a RUN statement. It can contain other SAS statements such
as AXIS, BY, GOPTIONS, LEGEND, TITLE, or WHERE. As long as you do not end the
procedure, it remains active and you do not need to resubmit the PROC statement.
To end RUN-group processing, submit a QUIT or RUN CANCEL statement, or start
a new procedure.
Note: When using SAS/GRAPH with the ODS statement, it is best to use a QUIT
statement after each procedure that uses RUN-group processing, rather than relying on
a new procedure to end the processing. Running too many procedures without an
intervening QUIT statement can use up so much memory as to crash the system
(depending, of course, on how many other processes are running). Also, note that failing
to do a QUIT before doing an ODS CLOSE results in the process memory not being
freed at all. 4

With global and local statements


Global statements and NOTE statements that are submitted in a RUN-group affect
all subsequent RUN-groups until you cancel the statements or exit the procedure. For
example, each of these two RUN-groups produces a plot and both plots display the title
defined in the first RUN-group:
/* first run group*/
proc gplot data=sales;
title1 ’Sales Summary’;
plot sales*model_a;
run;

/* second run group */


plot sales*model_b;
run;
quit;

With BY statements
BY statements persist in exactly the same way. Therefore, if you submit a BY
statement within a RUN-group, the BY-group processing produces a separate graph for
each value of the BY variable for the RUN-group in which you submit it and for all
subsequent RUN-groups until you cancel the BY statement or exit the procedure. Thus,
as you submit subsequent action statements, you continue to get multiple graphs (one
for each value of the BY variable). For more information, see “BY Statement” on page
141.

With the WHERE Statement


The WHERE statement enables you to graph only a subset of the data in the input
data set. If you submit a WHERE statement with a RUN-group, the WHERE definition
remains in effect for all subsequent RUN-groups until you exit the procedure or reset
the WHERE definition.
34 Procedure Output and the Graphics Output Area Chapter 2

Using a WHERE statement with RUN-group processing follows most of the same
rules as using the WHERE statement outside of RUN-group processing with these
exceptions:
3 With the GMAP procedure, the WHERE variable must be in the input data set.
3 With a procedure that is using an Annotate data set, the following requirements
must be met:
3 The ANNOTATE= option must be included in the action statement.
3 The WHERE statement must be executed before the action statement.
3 The WHERE variable must occur in the Annotate data set.

Procedure Output and the Graphics Output Area


The result of most SAS/GRAPH procedures is the graphic display of data in the form
of graphics output. Graphics output is made up of commands that tell a graphics device
how to draw graphic elements. A graphics element is a visual element of graphics
output – for example, a plot line, a bar, a footnote, the outline of a map area, or a border.
To generate graphics output, your program uses a device driver that directs the
graphics output to a display device (a graphics monitor or terminal), a hardcopy device,
or a file. Despite the fact that all graphics devices do not understand the same
commands, SAS/GRAPH software can produce graphics output on many types of
graphics devices. It does so by producing output in two steps:
1 It creates a catalog entry made up of graphics commands in a generic,
device-independent format.
2 It uses a device driver to translate the commands from the generic format to
commands that a particular graphics device understands. This is called
device-dependent output.
Your program controls this process as well as the graphics environment in which the
graphics appear. This section describes this graphics environment and how you can
modify it, how SAS/GRAPH uses it, and how you can make your programs work for
different output devices.

About the Graphics Output Area


When SAS/GRAPH software produces graphics output, it draws the graphic elements
inside of an area called the graphics output area. Characteristics of the graphics output
area are determined by the values of certain device parameters within the device entry.
You can modify some of these characteristics for a single graph or an entire SAS session
by using graphics options to change the values of the device parameters. This section
describes changes you can make to the external dimensions, the resolution, the cell size,
and the type of units. For a description of the graphics options and device parameters
referred to in this section, see Chapter 8, “Graphics Options and Device Parameters
Dictionary,” on page 261.

External Dimensions
The graphics output area is contained within the device’s display area. The external
dimensions of the device’s display area are controlled by the values of the XMAX and
YMAX device parameters. XMAX sets the maximum horizontal dimension; YMAX sets
the maximum vertical dimension. The orientation of the graphics output area, that is,
whether it is landscape or portrait, is determined by whether the larger value is XMAX
(orientation is landscape) or YMAX (orientation is portrait).
SAS/GRAPH Programs About the Graphics Output Area 35

The external dimensions of the graphics output area are controlled by the values of
the HSIZE and VSIZE device parameters.
Typically, the default dimensions of the graphics output area are the same as the
dimensions of the device. This is usually true for display devices. For those devices, the
default value of HSIZE and VSIZE is 0. However, for hardcopy devices, the XMAX,
YMAX values represent the external boundaries of the output medium (such as a sheet
of paper). If these devices need a margin, HSIZE, VSIZE and HORIGIN, VORIGIN are
assigned default values and the default graphics output area is somewhat smaller than
the device’s display area. Figure 2.1 on page 35 illustrates such a device.

Figure 2.1 Default Dimensions of the PSCOLOR Device


XMAX=8.5in
XPIXELS=2550

HSIZE=8.0in

YMAX=11.00in
YPIXELS=3300

VSIZE=8.5in
display area

graphics output area

HORIGIN=0.218in
VORIGIN=1.496in

Note that HORIGIN and VORIGIN define the left margin and bottom margin,
respectively. The right margin and top margin are calculated by the device driver as
follows:
right-margin = XMAX − (HSIZE + HORIGIN)
top-margin = YMAX −(VSIZE + VORIGIN)
You cannot specify values for right-margin and top-margin.
You can change the dimensions of the graphics output area for a SAS session or for a
single graph with the HSIZE= and VSIZE= graphics options. Changing the size of the
graphics output area does not change the dimensions of the device’s display area or
affect the resolution. The values of HSIZE= and VSIZE= cannot exceed the maximum
dimensions for the device as specified by XMAX and YMAX. Furthermore, you cannot
specify values for graphics options HSIZE= and VSIZE= that exceed the HSIZE and
VSIZE values in the device entry.

Device Resolution
The resolution of a device is the number of pixels per inch. It is determined by the
values of the device parameters XMAX, YMAX, and XPIXELS, YPIXELS, and is
calculated by dividing the number of pixels by the corresponding external dimension.
For example,
x-resolution = XPIXELS / XMAX
Therefore, the X resolution of the PSCOLOR device illustrated in Figure 2.1 on page
35 is 300dpi (dots per inch).
Ordinarily, you do not want to change the device resolution because changing it may
distort your image. However, you may want to change the size of the display area. To
36 About the Graphics Output Area Chapter 2

do so without changing the resolution, use the GOPTIONS statement to change the
values of only XPIXELS= and YPIXELS=, or the values of only XMAX= and YMAX=.
Then SAS/GRAPH will automatically calculate the correct value for the unspecified
parameters so that the device retains the default resolution.
If you do want to change the device resolution (usually for image files or graphs that
are displayed online), specify values for both XMAX= and XPIXELS= (horizontal
resolution) or both YMAX= and YPIXELS= (vertical resolution), or all four. In these
cases, SAS/GRAPH changes the dimensions and recalculates the device resolution.
Table 2.1 on page 36 summarizes the interaction of these options.

Table 2.1 Interactions of Graphics Options That Affect Resolution

If you specify values for and... then SAS/GRAPH...


XPIXELS= and YPIXELS= not XMAX= and YMAX= changes the dimensions and
recalculates the value of
XMAX= and YMAX= in order
to retain the resolution

XMAX= and YMAX= not XPIXELS= and YPIXELS= changes the dimensions and
recalculates the value of
XPIXELS= and YPIXELS= in
order to retain the resolution

XMAX= XPIXELS= changes the horizontal


dimension and recalculates the
resolution

YMAX= YPIXELS= changes the vertical dimension


and recalculates the resolution

Cells
Within the graphics output area, SAS/GRAPH software defines an invisible grid of
rows and columns. This grid is made up of character cells as shown in Figure 2.2 on
page 37.
The size and proportion of these cells affects the size and appearance of graphic
elements that are drawn using units of CELLS. The attributes of the cells are
determined by both the external dimensions of the graphics output area (controlled by
HSIZE and VSIZE) and the number of rows and columns. The number of rows is
controlled by the LROWS (if orientation is landscape) or PROWS (if orientation is
portrait) device parameter. Similarly, the number of columns is controlled by the
LCOLS (landscape) or PCOLS (portrait) device parameter.
You can change the number of rows and columns in the grid with the HPOS= and
VPOS= graphics options. HPOS= overrides the value of LCOLS or PCOLS and sets the
number of columns in the graphics output area. VPOS= overrides the value of LROWS
or PROWS and sets the number of rows in the graphics output area.
Figure 2.2 on page 37 illustrates the relationship between the graphics options or
device parameters that determine the dimensions of the graphics output area and those
that determine the number of character cells within the graphics output area.
SAS/GRAPH Programs About the Graphics Output Area 37

Figure 2.2 Rows, Columns, and Cells in the Graphics Output Area

HPOS=8
(columns in graphics output area; can also be
defined by LCOLS or PCOLS device parameter)

character
cell

VPOS=6 VSIZE=6 in
(rows in (can also be
graphics output defined by
area; can also YMAX device
be defined by parameter)
LROWS or
PROWS device
parameter)

HSIZE=8 in
(can also be defined by XMAX device parameter)

Changing only the external dimensions of the graphics output area (HSIZE= and
VSIZE=) retains the cell size but causes SAS/GRAPH to automatically recalculate the
number of rows and columns, as illustrated in Figure 2.3 on page 37.

Figure 2.3 Changing HSIZE=, VSIZE= Changes Dimensions and Recalculates


Number of Rows and Columns
HPOS=12
(recalculated)

HPOS=8

VPOS=18 VSIZE=9IN
(recalculated) (specified)

VPOS=12 VSIZE=6IN

HSIZE=4IN HSIZE=6IN
(specified)

Changing only the number of rows and columns (HPOS and VPOS) changes the size
of the cells without altering the overall size of the output. Figure 2.4 on page 37 shows
how increasing the number of rows and columns reduces the size of the individual cells.

Figure 2.4 Changing HPOS= and VPOS= Changes Cell Size


HPOS=12
HPOS=8 (specified)

VPOS=10 VSIZE=6IN
(specified) (no change)
VPOS=12 VSIZE=6IN

HSIZE=4IN HSIZE=4IN
(no change)
38 About the Graphics Output Area Chapter 2

Usually, you should not change the number of rows and columns from the default for
your device. However, if you must change them to make a graph fit, note that the size
of text in the graphics output will change if you specified text size using units of
CELLS. If the cells are large (that is, HPOS= and VPOS= have small values), the text
may not fit. If the cells are too small, the text may be too small to read. In this case,
you can adjust the size of the text with the HEIGHT= statement option or the HTEXT=
graphics option.
To change all the attributes of the graphics output area, specify values for all four
options, as shown in Figure 2.5 on page 38.

Figure 2.5 Changing HSIZE=, VSIZE= and HPOS=, VPOS= Changes Dimensions
and Number and Size of Cells
HPOS=6
(specified)

HPOS=8

VPOS=10 VSIZE=7.5IN
(specified) (specified)
VPOS=12 VSIZE=6IN

HSIZE=4IN HSIZE=6IN
(specified)

Table 2.2 on page 38 summarizes the interaction of the HSIZE=, VSIZE=, HPOS=,
and VPOS= graphics options.

Table 2.2 Interaction of Graphics Options Affecting Cells

If you specify values and ... then SAS/GRAPH ...


for ...
HSIZE= and VSIZE= not HPOS= and changes the external dimensions of the graphics
VPOS= (or specify output area and recalculates the number of
HPOS=0 and VPOS=0) rows and columns in order to retain cell size
and proportions.

HPOS= and VPOS= not HSIZE= and keeps the external dimensions but changes the
VSIZE= cell size according to the number of rows and
columns.

HSIZE= and VSIZE= HPOS= and VPOS= changes the dimensions of the graphics output
area, the number of rows and columns, and
recalculates the cell size.

Units
By default, most graphic elements are drawn using units of CELLS to determine
their size. For example, the default character height for the TITLE1 definition is two
cells; for all other text the default height is one cell.
Changing the cell size to control the size of one element, such as text, may distort
other parts of your graph. Instead, you may want to change the type of units that
SAS/GRAPH uses to control the size of the graphic elements. In addition to CELLS and
other absolute units such as inches (IN), centimeters (CM), and points (PT), you can
often use units of percent of the graphics output area (PCT). This unit specification
SAS/GRAPH Programs Placement of Graphic Elements in the Graphics Output Area 39

allows the height of the graphic elements to change in proportion to the size of the
graphics output area.
You can specify the type of unit for individual graphic elements or you can use the
GUNIT= graphics option to set the default units that will be used for most height
specifications.

Placement of Graphic Elements in the Graphics Output Area


By default, SAS/GRAPH software positions certain graphics elements in predefined
locations in the graphics output area. Figure 2.6 on page 39 shows the graphics output
area and the areas within it that are used by the following graphic elements:
3 Titles are placed in the title area at the top of the graphics output area.
3 Footnotes are placed in the footnote area at the bottom of the graphics output area.
3 The graph itself uses the procedure output area, which is the area left after the
titles and footnotes have been drawn.
3 Legends also use the procedure output area and may affect the amount of space
available for the graph. By default, space is reserved for the legend below the axis
area of a graph and above the footnote area. However, you can position the legend
in the part of the procedure output area that is reserved for the graph. For details,
see “LEGEND Statement” on page 151.

Note: Titles and footnotes can be positioned elsewhere on the graph as well, with
different effects on space allocation. See “TITLE, FOOTNOTE, and NOTE Statements”
on page 210 for details. 4

Figure 2.6 Default Locations for Graphic Elements in the Graphics Output Area

default title area

optional
area for
titles and
footnotes

optional procedure
area for output
titles and area
footnotes

graphics
output
area

default footnote area

Note: If the titles, footnotes, and legend are very large, they may make the
procedure output area too small for the graph. You can control the size of title and
footnote text and of most legend elements with statement options. For details, see
Chapter 7, “SAS/GRAPH Statements,” on page 121 for a description of the appropriate
statement. In addition, “GOPTIONS Statement” on page 146 lists the graphics options
that control the size of various graphic elements. See also “Making Programs Portable”
on page 40. 4
40 Making Programs Portable Chapter 2

How Errors in Sizing Are Handled


Sometimes SAS/GRAPH cannot fit one or more graphic elements on the graph. This
can happen if an element is too big for the available space (for example, the title is too
long), or if you have too many elements to fit in a given space (for example, a bar chart
has too many bars). In these cases, SAS/GRAPH either
3 resizes the graphics element and issues a warning explaining what it did
3 issues an error message and does not attempt to produce the graph.
For example, it adjusts the size of titles to make them fit but it does not drop bars in
order to produce a readable bar chart. If you get unexpected results or no graph, check
the SAS log for notes, warnings, and errors.

Making Programs Portable


When you want to write a program that will produce the same graphics output on two
different devices, you can use features in SAS/GRAPH software to simplify the process:
3 Use percent of the graphics output area (PCT) as the unit of measure when
specifying sizes of text and other graphics to make sure that text is proportional in
size across devices. A one-inch-high title may be appropriate on a standard piece
of paper, but it is almost all of the display area of a slide. To make units of
percentage the default for size specifications, use the GUNIT= graphics option:
goptions gunit=pct;

You can also specify PCT anywhere you specify a size:


axis1 label=(height=3 pct ’Year’);

See “GUNIT” on page 309 for a complete description of the GUNIT= graphics
option.
3 Compare colors and patterns for the devices you will use and use the colors of the
device that has the fewest colors, With a slide camera, for example, you can choose
from over 16 million colors, but some graphics monitors display only four or eight
colors at a time.
If you want to generate a graph on both a color device and a black-and-white
device, such as a laser printer or a monochrome graphics monitor, all colors are
remapped to black, white, or scales of gray, depending on the device. However,
with the PATTERN statement, you can substitute line-patterns for colors.
3 Preview the appearance of the output on a different device with the
TARGETDEVICE= graphics option. For example, to see how the output will look
on a color PostScript printer, specify
goptions targetdevice=pscolor;
41

CHAPTER

3
Device Drivers

Overview 41
About Device Drivers 42
Types of Device Drivers 42
How Device Drivers Are Assigned 43
Selecting a Device Driver 43
Viewing the List of Available Device Drivers 44
Browsing the Contents of a Device Entry 44
Specifying a Device Driver in a SAS Session 44
Controlling Output with Device Drivers 45
Modifying Device Parameters Permanently 45
Overriding Device Parameters Temporarily 46
Graphics Options 46
Statement Options 46

Overview
SAS/GRAPH procedures that produce graphics output require a device driver to
display the output. This chapter discusses the role of device drivers in generating
SAS/GRAPH output, provides directions for selecting and specifying device drivers, and
explains how you can change the settings of device parameters.
Other tasks related to device drivers are discussed in Chapter 4, “SAS/GRAPH
Output,” on page 47 and Chapter 9, “Introducing SAS/GRAPH Output for the Web,” on
page 369 and in the SAS Help facility for SAS/GRAPH. These include
3 displaying graphics output (see “Displaying Graphics Output on Monitors or
Terminals” on page 49)
3 previewing on one device how output will look on another device (see “Previewing
Output” on page 52)
3 sending graphics output to a printer or other hardcopy device (see “Printing
Graphics Output” on page 51)
3 creating external files in other graphics formats for use with other applications
(see “About Graphics Stream Files” on page 60)
3 creating graphics output that can be referenced in an HTML file and viewed with
a Web browser (see “About Graphics Stream Files” on page 60)
For a description of device catalogs and for information on creating and modifying
device drivers, see Chapter 31, “The GDEVICE Procedure,” on page 915.
42 About Device Drivers Chapter 3

About Device Drivers


To produce graphics output on a graphics output device, SAS/GRAPH software uses a
device driver. Device drivers are the components of SAS/GRAPH software that translate
the device-independent output from SAS/GRAPH procedures into the appropriate
commands to produce graphics output on particular output devices. Device drivers
contain settings that determine the default appearance of the output, such as
dimensions and orientation, cell size, colors, and hardware fonts. They can also contain
host commands that are issued before and after the driver produces output.
A device driver is composed of two parts:
3 a device entry in a SAS catalog
3 an executable module.
The device entry is a SAS catalog entry of type DEV. It is created and accessed with
the GDEVICE procedure and explicitly refers to the executable module. The device
entry contains device parameters whose settings can control
3 the appearance of the output
3 the destination to which the output is sent (native SAS/GRAPH drivers only)
3 communications between the operating environment and the device
3 how the device generates the output.
You can change these settings either by modifying the device parameters using the
GDEVICE procedure, or by overriding the parameter settings using graphics options in
a GOPTIONS statement. For details, see “Controlling Output with Device Drivers” on
page 45.
The executable module is a program that produces the device-specific commands from
the device-independent output of a SAS/GRAPH procedure. The executable module uses
the parameters specified in the device entry to tell it exactly how to do so.
SAS/GRAPH software provides device entries for your operating environment in the
Institute-supplied catalog, SASHELP.DEVICES.
If your site has created custom device entries, they may also be stored in
SASHELP.DEVICES, although typically custom devices are stored in the catalog
GDEVICE0.DEVICES. For more information about custom device entries, see “About
Device Catalogs” on page 916 or ask your SAS Support Consultant.

Types of Device Drivers


Most of the device drivers in SASHELP.DEVICES are SAS/GRAPH native device
drivers, which are those SAS/GRAPH drivers that produce output in the native
language of the device. For example, the PS300 driver is a "native device driver"
because it directly produces PostScript output.
A special set of interface drivers enable you to make route graphics output to the
default print device. For OpenVMS, UNIX, and z/OS operating environments, the
interface drivers use the Universal Printing subsystem to access a Universal Printer.
For Windows, the interface drivers use the Windows Print Manager subsystem to access
the printer that is defined as the default.
The interface drivers are:
SASPRTC (Color output)
SASPRTG (Grayscale output)
SASPRTM (Monochrome output)
The WINPRTx and XPRINTx series of drivers are identical to the SASPRTx drivers.
Device Drivers Selecting a Device Driver 43

For more information about Universal Printing, see the Base SAS Software section in
SAS Help and Documentation. For more information about Windows printing, see the
SAS Help facility for SAS/GRAPH.

How Device Drivers Are Assigned


Because many characteristics of the graphics output depend on parameter values
that are stored in the device entry, SAS/GRAPH procedures that produce graphics
output must know which device driver to use before they begin processing.
Usually SAS/GRAPH automatically selects a device driver for you and you are not
required to explicitly specify one. If you use the GRAPH window to display graphics
output, SAS/GRAPH selects a device driver that is appropriate for your device. The
default device driver for your site may also be selected by your SAS Installation
Representative.
If you submit a SAS procedure without specifying a device driver and your display
device does not support the GRAPH windows or you are running outside the SAS
windowing system, SAS/GRAPH prompts you for a driver name.
Whether or not a default device is assigned, you can always explicitly assign a device
driver. See “Selecting a Device Driver” on page 43 for more information.

Selecting a Device Driver


Although SAS/GRAPH software usually selects an appropriate device driver for
displaying graphics output on your display device, you may need to select a different
device driver if you want to direct your graphics output to another destination.
When you select a device driver, it must be one that is appropriate for your device.
The device driver must
3 send commands to the device that the device understands. For example, if you are
using an X Windows display, the SAS/GRAPH device driver sends the appropriate
data stream that can produce graphics output on the display device.
3 contain values of device parameters that are appropriate for the device. For
example, if you are using a color PostScript printer and you select a device driver
for a black and white PostScript printer, your graph will not print in color.
Occasionally the device driver you use is not the one that bears your device’s name.
This can happen when
3 your graphics device uses a common graphics language (for example, PostScript).
3 your graphics device emulates a different graphics device. (For example, there is
no SAS device driver for your plotter, but the plotter can be set up to emulate a
Hewlett-Packard 7550 plotter.)
In this case, you use the device driver that matches the language that your device
understands. For example, if your Hewlett-Packard LaserJet II printer has a PostScript
card installed, you would use one of the PostScript device drivers rather than HPLJS2.
Similarly, you could use an HP driver for a plotter (for example, HP7550A) when your
plotter emulates a Hewlett-Packard 7550 plotter.
You cannot force a device to act as a device with different capabilities by choosing a
different device driver.
44 Viewing the List of Available Device Drivers Chapter 3

Viewing the List of Available Device Drivers


You can view the list of device entries in SASHELP.DEVICES or in any other device
catalog in the following ways:
3 use the SAS Explorer window to display the contents of the device catalog.
3 use the GDEVICE procedure to open the GDEVICE DIRECTORY window, which
lists all of the device drivers in the current catalog. By default the current catalog
is SASHELP.DEVICES. To specify a catalog, include the CATALOG= option, as
shown in the following statement:
proc gdevice catalog=sashelp.devices;

See “Using the GDEVICE Windows” on page 928 for details.


3 use GDEVICE procedure statements to write the list of device drivers to the
Output window:
proc gdevice catalog=sashelp.devices nofs;
list;
run;
quit;

The NOFS on page 921 option in the PROC GDEVICE statement causes the
procedure not to use the GDEVICE windows.
If you want to write the list of devices to an external file you can
3 save the contents of the Output window.
3 use the PRINTTO procedure to redirect the GDEVICE procedure output to
an external file. See Base SAS Procedures Guide for a description of the
PRINTTO procedure.

Once you have generated the list of available device drivers, you can search the list
until you find the description that matches your output device. The corresponding name
is the name that you specify as the device driver.

Browsing the Contents of a Device Entry


You can also use any of the viewing methods to browse the contents of a device entry.
From the GDEVICE Directory window, select the device name to open the GDEVICE
Detail window. From there you can move to the other GDEVICE windows for the entry,
using either the menus or commands. For details, see “Using the GDEVICE Windows”
on page 928.
You can display the contents of a device entry in the Output window by selecting the
entry from the Explorer window or by submitting GDEVICE statements. The following
statements list in the Output window the contents of the PSCOLOR device entry:
proc gdevice c=sashelp.devices nofs;
list pscolor;
run;
quit;

See Output 31.1 for an illustration of the device listing.

Specifying a Device Driver in a SAS Session


You can specify a device driver in these ways:
Device Drivers Modifying Device Parameters Permanently 45

3 use the DEVICE= option in a GOPTIONS or OPTIONS statement. For example,


goptions device=pslepf;

For details, see “GOPTIONS Statement” on page 146.


3 change the device in the System Options window. To do so, type the OPTIONS
command on the command line, and in the Graphics group, choose "Driver
settings." You can then enter a Device value. Use the window’s Help button if you
need help editing values.
3 enter the device name in the DEVICE prompt window. The DEVICE prompt
window opens automatically if you submit a SAS/GRAPH program that produces
graphics output, no device has been specified, and you are running outside of the
SAS windowing system environment.
If you specify a device driver in more than one way, the most recently specified device
driver is used. The device driver stays in effect until you specify another device, submit
the graphics option RESET=GOPTIONS or RESET=ALL, or end your SAS session.
If you use the same device driver for most or all of your SAS/GRAPH programs, you
can put the GOPTIONS DEVICE= statement in an AUTOEXEC file. See the SAS
companion for your operating environment for details on setting up an AUTOEXEC file.
You can also specify a device for previewing or printing your output with the
TARGETDEVICE= graphics option. For details, see “Printing Graphics Output” on
page 51.

Controlling Output with Device Drivers


When a SAS/GRAPH procedure produces output, it first checks to see what device
driver you have specified. It then looks in the device entry for that driver to find the
current parameter settings. In general, parameter values control
3 the appearance of the graphics output. Device parameters control such aspects as
the size of the graphics output, units (such as inches or points) used to draw the
output, colors displayed, and text fonts and sizes used.
3 how the operating environment communicates with the device. For example, some
devices require the graphics commands to be formatted in a specific way or require
a particular communications protocol. Others may require that a set of
initialization commands precede the graphics commands.
3 how the output is produced – that is, how the output is displayed or printed. Some
device parameters control the behavior of a hardcopy device, such as the paper
feed between graphs as well as the display characteristics, such as orientation.
The parameter values for device entries in SASHELP.DEVICES reflect the most
common modes of operation of the supported devices. You can control the way the
device driver produces output for your device by changing values in the device entry.
You can change device parameters either permanently or temporarily.

Modifying Device Parameters Permanently


To change a device parameter permanently, you must make the change in the device
entry itself using the GDEVICE procedure. The modifications made to a device entry
are in effect for all SAS sessions.
The new values that you specify for device parameters must be within the device’s
capabilities. For example, all devices are limited in the size of the output they can
display. Some output devices cannot display color. If you try to increase the size of the
46 Overriding Device Parameters Temporarily Chapter 3

display past the device’s capability or if you specify colors for a device that cannot
display them, you will get unpredictable results.
Note: If you run SAS/GRAPH software in a multi-user environment, you should not
change the device entries in the Institute-supplied catalog, SASHELP.DEVICES, unless
you are the system administrator or the SAS Support Consultant. 4
If you need to change a device driver in SASHELP.DEVICES, copy it into a personal
catalog named DEVICES, and then modify the copy. To use the new device driver,
assign the libref GDEVICE0 to the library that contains the modified copy. See
“Creating or Modifying Device Entries” on page 934 for details.

Overriding Device Parameters Temporarily


You can temporarily override the settings of device parameters by using graphics
options in a GOPTIONS statement or by specifying options in other SAS/GRAPH
statements.

Graphics Options
To override device parameter settings with graphics options, simply submit the
options in a GOPTIONS statement. For example, the HSIZE= and VSIZE= graphics
options control the default size of the graphics output area and override the values of
the HSIZE= and VSIZE= device parameters in the current device entry. The following
GOPTIONS statement changes the dimensions of the graphics output area:
goptions hsize=6in vsize=4in;

These new values remain in effect until you change them, use the RESET= graphics
option to reset them, or end your SAS session.
The values that you specify for graphics options must be supported by your graphics
device. If you use an option that is not supported, SAS/GRAPH software ignores the
option. See “GOPTIONS Statement” on page 146 for information about specifying
graphics options.

Statement Options
You can also override parameters that control such attributes as text color and font
by using options in other SAS/GRAPH statements. For example, this TITLE statement
explicitly specifies the text color and font:
title color=blue font=zapf ’Production Quality’;

The COLOR= option overrides the default color selection from the device entry’s
colors list as well as any graphics options that affect text color. The FONT= option
overrides the device’s default font and any graphics options that affect the font. As long
as the values are supported by your graphics device, the values you specify in the
statements override the corresponding device parameters and graphics options when
the SAS program is executed.
When you specify options that override device parameter settings, this is the order of
precedence that SAS/GRAPH software uses:
1 options in a SAS/GRAPH procedure statement or AXIS, FOOTNOTE, LEGEND,
NOTE, PATTERN, SYMBOL, or TITLE statement
2 graphics options in a GOPTIONS statement
3 device parameters in a device entry
4 default hardware settings of a device.
47

CHAPTER

4
SAS/GRAPH Output

About SAS/GRAPH Output 48


What You Can Do With SAS/GRAPH Output 48
Displaying Graphics Output on Monitors or Terminals 49
Displaying Graphs with the GRAPH Window 49
Opening and Closing the GRAPH Window 49
Sizing the GRAPH Window 50
Displaying Graphs with Direct Display 50
Printing Graphics Output 51
Printing Directly to the Device 51
Saving and Printing a Graphics File 51
Printing From a Window 52
Previewing Output 52
Storing Graphics Output in SAS Catalogs 53
Accessing Catalogs from Different Versions of SAS 53
Creating and Specifying Catalogs 54
Names and Descriptions of Catalog Entries 55
Listing and Managing Catalog Entries 55
Modifying SAS/GRAPH Output 55
Transporting and Converting Graphics Output 56
Transporting Catalogs across Operating Environments 56
Example of Transporting GRSEGs 57
Example of Transporting Color Maps and Templates 58
Example of Transporting Fonts 58
Example of Transporting Device Attributes and Device Entries 58
Converting Catalogs to a Different Version of SAS 59
About Exporting SAS/GRAPH Output 59
About Graphics Stream Files 60
About Graphics File Formats 60
Ways to Export SAS/GRAPH Output 61
Exporting SAS/GRAPH Output Interactively 62
Exporting SAS/GRAPH Output with Program Statements 62
General Information 62
Common Requirements 62
Naming the Output 63
Using the NAME= option 63
Using the default output name 63
File extensions 63
Example 63
Saving One Graph to a File 64
Example 65
Saving Multiple Graphs to One File 66
48 About SAS/GRAPH Output Chapter 4

Example 66
Saving Multiple Graphs to Multiple Files 68
Example 68
Replacing Existing External Files 70
Example 71
Other Ways to Assign the Destination 72
Using GACCESS=GSASFILE 72
Using GACCESS= to Explicitly Specify a Destination 72
Exporting SAS/GRAPH Output Using Modified Device Entries 72
73
The Metagraphics Driver Facility 73

About SAS/GRAPH Output


Most SAS/GRAPH procedures produce graphics output, which is distinct from SAS
output. Whereas SAS output is made up of text, graphics output is made up of
commands that tell a graphics device how to draw graphics.
This chapter discusses how to display, print, store, modify, and transport
SAS/GRAPH output after you have created it. For information on SAS/GRAPH
language elements and programs and on how procedure output is generated, see
Chapter 2, “SAS/GRAPH Programs,” on page 25.

What You Can Do With SAS/GRAPH Output


By default, SAS/GRAPH procedures that produce graphics output display the output
on your monitor or terminal, using either the GRAPH window or the direct display
method. For details, see “Displaying Graphics Output on Monitors or Terminals” on
page 49. SAS/GRAPH also can direct graphics output to a variety of other destinations.
Graphics output can be
3 sent directly to a graphics hardcopy device, such as a printer, plotter, or slide
camera. The way you send graphics output to a hardcopy device depends on your
hardware, operating environment, and system configuration. For details, see
“Printing Graphics Output” on page 51.
3 saved in a temporary or permanent SAS catalog entry for later replay. For details,
see “Storing Graphics Output in SAS Catalogs” on page 53.
3 modified with the graphics editor. You can edit or create graphics output, and save
the modified graph to a catalog. For details, see “Modifying SAS/GRAPH Output”
on page 55.
3 transported in catalogs from one operating environment to another. For details,
see “Transporting and Converting Graphics Output” on page 56.
3 converted for use with a different version of SAS by converting the catalog
containing the graphics output. For details, see “Converting Catalogs to a
Different Version of SAS” on page 59.
3 exported to external files using different graphics file formats. For example, you
can save SAS/GRAPH output in formats such as CGM or PostScript for use with
other software packages. For details, see “About Exporting SAS/GRAPH Output”
on page 59.
In addition, you can produce graphics output as GIF files and automatically generate
HTML files so that you can display your graphics output with a Web browser. For
details, see Chapter 9, “Introducing SAS/GRAPH Output for the Web,” on page 369.
SAS/GRAPH Output Displaying Graphs with the GRAPH Window 49

Regardless of the other types of output generated, SAS/GRAPH procedures always


generate a SAS catalog entry. The entry is stored in the WORK.GSEG catalog unless
you specify a different catalog with the GOUT= option in a PROC statement. To
generate only catalog entries and suppress all other forms of graphics output, use the
NODISPLAY graphics option.

Displaying Graphics Output on Monitors or Terminals


If you want to see your graphics output immediately or preview it before generating
a hardcopy, you can send it to your monitor or terminal.
Note: If you are using a terminal or PC that emulates a terminal, it must be a
graphics terminal. 4
In most environments, SAS/GRAPH automatically displays graphics output in the
GRAPH window. If your environment does not support the GRAPH window,
SAS/GRAPH displays your graphs with the direct display method. See “Displaying
Graphs with Direct Display” on page 50.
You can suppress the display of graphics output with the NODISPLAY graphics
option. Suppressing a display is useful when you want to create only a catalog entry.

Displaying Graphs with the GRAPH Window


The GRAPH window, which is available in the SAS windowing environment, displays
catalog entries of type GRSEG. You can use this window to view either the graphics
output that you are currently generating or graphics output that has been stored in a
catalog. You can scroll backward and forward through the catalog entries.
Some devices allow you to use up to four graph windows: GRAPH1, GRAPH2,
GRAPH3, and GRAPH4. By default, the GRAPH1 window displays the graphs in the
default catalog, WORK.GSEG, or the catalog that you specified with the GOUT= option.
The GRAPH window acts like other SAS windows: you can resize it and move it, and
you can submit global SAS window commands from it. For details on sizing windows,
see the SAS documentation for your operating environment. For a description of SAS
window commands, see SAS Language Reference: Dictionary.
GRAPH window commands control how the graphs appear in the window. For a
description of these commands, refer to the SAS Help facility for the GRAPH window.

Opening and Closing the GRAPH Window


The GRAPH Window opens automatically when you submit a procedure that
produces graphics output, or when you select a catalog entry from the PROC GREPLAY
window or from the SAS Explorer window. You can also open the GRAPH window with
the GRAPHn command. The GRAPHn command opens the default catalog
WORK.GSEG, or a catalog you specify, or a specific entry.
The GRAPHn command has the following form:
GRAPHn <<libref.> catalog-name <.entry-name <.GRSEG>>>
n
is a number from 1 to 4 that indicates which GRAPH window to open.
libref
points to the library where the catalog is or will be stored.
50 Displaying Graphs with Direct Display Chapter 4

catalog-name
is the name of the catalog whose contents you want to view. The default is
WORK.GSEG. If the specified catalog does not contain any graphics entries, the
window opens but is empty. The catalog assignment is temporary and remains in
effect only while the GRAPH window remains open. To change the catalog,
resubmit the GRAPHn command.
entry-name
is the name of the catalog entry that you want to view. If you omit entry-name or
the entry does not exist, the last graph in the catalog is displayed. If you specify
entry-name, you must also supply the libref and catalog name.
GRSEG
is the type of catalog entry.
To close the GRAPH window, issue the END command.

Sizing the GRAPH Window


The default size of a GRAPH window depends on the display device.
CAUTION:
Resizing the GRAPH window after you have displayed a graph can distort the graphs. If you
replay a graph in a GRAPH window that is a different size from the size at which you
created the graph, the graph may be distorted. Distortion occurs if the new HSIZE
and VSIZE values do not maintain the width-to-height ratio of the original window. 4

Doing any of the following may change the HSIZE and VSIZE values and
consequently the size of the GRAPH window:
3 changing the device driver
3 specifying a target device
3 specifying dimensions with the HSIZE= and VSIZE= graphics options.
In addition, resizing the GRAPH window can reduce the number of cells available for
the output. In order to display some types of graphs in a reduced GRAPH window, you
may need to increase the number of cells either by using the HPOS= and VPOS=
graphics options or by modifying the device driver. To ensure that graphs have an
adequate number of cells, use a full-size GRAPH window when creating the graphs.You
can then reduce the window to replay the graphs. For more information on dimensions
and cell size, see “About the Graphics Output Area” on page 34.
If you create most or all of your graphs at the same size or with the same aspect
ratio, you can avoid distortion if you size the window before you draw the graphs and
then use the WSAVE command to save the position and dimensions of the window. If
you resize the GRAPH windows and do not use the WSAVE command, the new size is
not saved, even in the same SAS session.

Displaying Graphs with Direct Display


Environments that do not support the GRAPH window use the direct display
method. With this method, your display is cleared and the graph appears when you run
a graphics procedure.
If the procedure produces more than one graph, you are prompted to press ENTER
between each graph for the next one to be displayed. To return to your program, press
END or ENTER after the last graph.
You can display the graphs automatically and control the amount of time between
each graph with the GWAIT= and NOPROMPT graphics options. GWAIT= specifies the
SAS/GRAPH Output Saving and Printing a Graphics File 51

number of seconds before the next graph is drawn. NOPROMPT suppresses the delay
between the graphs displayed. In this case, SAS/GRAPH automatically returns to your
program after the last graph displays. (See Chapter 8, “Graphics Options and Device
Parameters Dictionary,” on page 261 for a complete description of these graphics
options.)
With the direct display method, you cannot scroll to other graphs in the catalog. To
redisplay graphs, you must rerun the procedure or replay the catalog entries. For
information on replaying graphs, see Chapter 43, “The GREPLAY Procedure,” on page
1237.

Printing Graphics Output


You can print your SAS/GRAPH output on hardcopy devices such as laser printers
and plotters. In addition, you can send the output to cameras or film recorders.
Regardless of the destination, there are several ways to produce hardcopy of your
SAS/GRAPH output:
3 Print SAS/GRAPH program output directly to a hardcopy device.
3 Print SAS/GRAPH program output by creating an external file of graphics
commands called a graphics stream file (GSF), saving it to disk, and printing the
file with host commands.
3 Print the displayed graph directly from the GRAPH window or the Graphics
Editor window.
The following sections provide a general description of these methods.
Operating Environment Information: Whatever way you choose, the exact steps for
printing graphics depend on the hardcopy device you are using and on the environment
in which you are using it. For complete information on printing graphics output in your
operating environment, see the SAS Help facility for SAS/GRAPH and the SAS
companion for your operating environment. 4

Printing Directly to the Device


You can send graphics output directly to a hardcopy device by sending the graphics
commands directly to the device or to a device port.
On most systems you can use any of the following methods to print directly to a
device:
3 Use a FILENAME statement, a GOPTIONS statement, and a SAS/GRAPH native
device driver. The FILENAME statement defines a fileref that points to the print
commands. The GOPTIONS statement references the fileref, assigns the device,
and specifies any additional parameters.
3 Use the GDEVICE procedure to modify a SAS/GRAPH device entry to spool output
directly to a printer. See Chapter 31, “The GDEVICE Procedure,” on page 915 for
information on adding host commands to a device entry.
3 Use the universal printing interface.
For detailed instructions on each of these methods, refer to the SAS Help facility for
SAS/GRAPH.

Saving and Printing a Graphics File


There are two steps to printing graphics output from an external file:
52 Printing From a Window Chapter 4

1 Save your SAS/GRAPH output in an external file. For information on creating


external files, see “About Exporting SAS/GRAPH Output” on page 59 and the SAS
Help facility for SAS/GRAPH.
2 Print the file from your host environment. The host commands vary across
operating environments and spooling utilities. See the SAS companion for your
operating environment for more information on printing.
You can perform these two steps separately or combine them by incorporating the
host printing commands into your program or device driver. In any case, you must
choose a graphics file format that is compatible with your hardcopy device. For
example, if you are using a PostScript printer, be sure to specify one of the PostScript
device drivers supplied in SASHELP.DEVICES. This technique is frequently used on
multi-user systems in which the output devices are shared.
You can use any of the following methods to create and print an external file:
3 Use the FILENAME and GOPTIONS statements to create the graphics stream
file. To route the output directly to the printer, include the print commands in the
SAS/GRAPH statements. Otherwise, save the file to disk and use a host command
to spool the file to a spooler for the device.
3 Use the GDEVICE procedure to modify a SAS/GRAPH device driver to save the
output to an external file and spool the output directly to a printer. See Chapter
31, “The GDEVICE Procedure,” on page 915 for information on modifying device
entries.
3 Use the universal printing interface.
For detailed instructions on each of these methods, refer to the SAS Help facility for
SAS/GRAPH.

Printing From a Window


In some operating environments you can print directly from the GRAPH window or
the Graphics Editor window by using the PRINT command in conjunction with the
TARGETDEVICE= graphics option. To do this, use TARGETDEVICE= to specify the
printer driver and use DEVICE= to specify the driver for the terminal or display on
which you want to preview the output.
The driver specified by TARGETDEVICE= determines the characteristics of the
printed output and sends the graphics output to either an output device or a graphics
stream file. The driver specified by DEVICE= controls some characteristics of the
output displayed in the window. In some cases, you may need to use a FILENAME and
GOPTIONS statements to define the destination of the PRINT command.
Note: If you have not previously specified TARGETDEVICE= when you issue the
PRINT command in the window, SAS/GRAPH prompts you for a device for the printed
output. However, in this situation the output that is sent to the printer reflects the
characteristics of the display device driver. To ensure that your printed output matches
what you see on your display, always use TARGETDEVICE= with the PRINT
command. 4
For details on printing directly from the GRAPH or Graphics Editor window, refer to
the SAS Help facility for SAS/GRAPH. See “TARGETDEVICE” on page 355 for a
complete description of TARGETDEVICE=.

Previewing Output
If you want to preview how a graph is going to appear on another device before you
send it to that device, you can use the TARGETDEVICE= graphics option. For example,
SAS/GRAPH Output Accessing Catalogs from Different Versions of SAS 53

to preview output on your display as it would appear on a color PostScript printer,


include TARGETDEVICE= in a GOPTIONS statement and specify the driver for the
printer:
goptions targetdevice=pscolor;

The output is displayed on your screen using


3 the orientation of the target device. As a result, the graph may not cover the
entire display area of the preview device.
3 the values of either the LCOLS and LROWS pair or the PROWS and PCOLS pair,
depending on the orientation of the target device.
3 the default colors list of the target device.
3 the values of the HSIZE and VSIZE device parameters for the target device.
3 the value of the CBACK device parameter for the target device.
All other device parameter values, including the destination of the output, come from
the current device entry. Therefore, the output displayed by TARGETDEVICE= may
not be an exact replication of the actual output, but it is as close as possible.
See “TARGETDEVICE” on page 355 for a complete description of TARGETDEVICE=.

Storing Graphics Output in SAS Catalogs


When you run a SAS/GRAPH procedure that produces graphics output, a copy of the
graphics output is always stored in a SAS catalog. A catalog is a type of SAS file in
which you can store different types of information, called catalog entries. Catalog
entries of type GRSEG store graphics output. In addition, SAS/GRAPH procedures
create other types of catalog entries such as DEV, CMAP, FONT, and TEMPLATE. You
can store multiple catalog entries in one catalog.
You can use catalog entries to store graphics output that you want to display again
without having to rerun the program. Use the GRAPH window, the GREPLAY
procedure, or the SAS Explorer window to redisplay graphics output stored in catalog
entries.
SAS catalogs can be either temporary or permanent. Temporary catalogs are erased
at the end of each SAS session and cannot be retrieved. Permanent catalogs are
retained until you delete them. Therefore, they exist after the end of a SAS session and
can be used in later SAS sessions.
Unless you select another catalog, either temporary or permanent, SAS/GRAPH
procedures always store a copy of your graph in the temporary catalog WORK.GSEG,
regardless of the other forms of graphics output that you choose. By default, each graph
is appended to the catalog. The graphs in WORK.GSEG are erased when you end the
SAS session.

Accessing Catalogs from Different Versions of SAS

CAUTION:
You can read Version 6 catalogs from Version 7 and Version 8, but you cannot write to
them unless you port them. 4
In some cases you have to specify an engine to read a Version 6 catalog from the
current SAS version:
3 If you are running the current version and you assign a libref that points to a
library that contains only Version 6 catalogs, the correct engine is automatically
54 Creating and Specifying Catalogs Chapter 4

applied and you can view the entries. However, you cannot write to the catalog
without porting it.
3 If you are running Version 7 or Version 8 and you assign a libref that points to a
library that contains both Version 6 and the current version catalogs, the
LIBNAME statement must specify the SASEB engine to view the entries in the
Version 6 catalog. Even with the engine assigned, you cannot write to the catalog
without porting it.
For more information, see “Transporting Catalogs across Operating Environments”
on page 56.
All Version 7 and Version 8 applications that support catalog entries that also existed
in Version 6 should be able to transparently read those Version 6 catalog entries. That
is, if a Version 7 or Version 8 user specifies the SASEB (Version 6 compatibility) engine
on the LIBNAME statement, the application should be able to read and process any
Version 6 data that the SASEB engine may return.
The Version 7 and Version 8 compatibility engines also support write access to
Version 6 catalogs.

Creating and Specifying Catalogs


To create or specify a catalog for graphics output, use the GOUT= option in a PROC
statement. The general form is
PROC procedure-name GOUT=<libref.> catalog-name;
procedure-name
is the graphics procedure you are running.
<libref.>catalog-name
is the name of a catalog where you want the output stored. If the specified catalog
already exists, the procedure simply adds a catalog entry to the catalog. If the
catalog does not exist, it is created.
For a temporary catalog, specify the name of the catalog and omit the libref.
(This is a one-level name.) The temporary catalog is stored in the WORK library
and erased when you end the SAS session.
For a permanent catalog, specify both a libref and a catalog name. (This is a
two-level name.) Libref must already be assigned to a SAS data library that
contains or will contain the catalog. For more information on assigning a libref,
see “LIBNAME Statement” on page 29.
When you run the procedure, the output is automatically appended to the end of the
specified catalog. If the procedure produces multiple graphics, then multiple entries are
added to the catalog.
If you want a catalog entry to replace all of the existing entries in the catalog, you
can use the following statement:
goptions goutmode=replace;

CAUTION:
Be careful using GOUTMODE=REPLACE. GOUTMODE=REPLACE replaces all existing
entries in the output catalog. You cannot retrieve previous entries once they have
been replaced. See “GOUTMODE” on page 302 for more information. 4
SAS/GRAPH Output Modifying SAS/GRAPH Output 55

Names and Descriptions of Catalog Entries


SAS/GRAPH software always assigns a name and a description to each catalog entry
so you can identify it. By default, the names and descriptions are determined by the
procedure. For example, a graph produced by the GCHART procedure would be
assigned the name GCHART and a description like PIE CHART OF MONTH.
By default, SAS/GRAPH appends each new entry to the catalog. If you create more
than one graph with a procedure during a SAS session and the graphs are stored in the
same catalog, SAS/GRAPH software adds a number to the end of the name of
subsequent catalog entries. This number makes the names unique within the catalog.
For example, if you create three graphs with the GCHART procedure during the same
SAS session, the catalog entries are named GCHART, GCHART1, and GCHART2.
SAS/GRAPH software uses this naming convention whether catalog entries are being
stored in a temporary or permanent catalog.
You can supply a name and description when you create the graph by using the
NAME= and DESCRIPTION= options. If you create more than one graph of the same
name, SAS/GRAPH software increments the specified name just as it does the default
names.

Listing and Managing Catalog Entries


You can use the SAS Explorer window or the PROC GREPLAY window to display a
list of all of the entries in a catalog. To open the Explorer window for a specific catalog,
use the CAT command:
CAT libref.catalog-name
To open the PROC GREPLAY window, submit the PROC GREPLAY statement with
or without a catalog specification. For details, see Chapter 43, “The GREPLAY
Procedure,” on page 1237.
Either method lets you view individual entries once you have displayed the list. For
more information, see “Displaying Graphics Output on Monitors or Terminals” on page
49.
There are several ways to manage catalogs and catalog entries:
3 The GREPLAY procedure can rename, delete, copy, or group graphics output that
is stored in either temporary or permanent catalogs.
3 The CATALOG procedure can copy or move an entire catalog or selected entries
within a catalog, and can rename or delete catalog entries. For details, see Base
SAS Procedures Guide.

Modifying SAS/GRAPH Output


The graphics editor is an interactive application that you can use from any GRAPH
window to modify graphs produced with SAS/GRAPH software or imported from other
graphics software.
You can invoke the graphics editor in several ways:
3 To edit a graph that you are viewing in the GRAPH window, select Edit –> Edit
current graph.
3 To open a GRAPH window and invoke the graphics editor without displaying an
existing graph, select Tools –> Graphics Editor from the SAS Explorer window.
After the window appears, you can either open an existing graph or create a
graphic image by drawing graphics elements in the window.
56 Transporting and Converting Graphics Output Chapter 4

3 To open a GRAPH window and edit a graph that is stored in a catalog, submit the
GRAPH command from the command line of the SAS Explorer window and add
EDIT to the end of the command. Separate the two commands with a semicolon
(;). For example, the following statement opens the GRAPH3 window, displays the
specified graph, and activates the graphics editor:
graph3 mylib.grafcat.slide1; edit

You can use the graphics editor to change graphics elements already displayed in the
graph such as text, lines, and polygons, or you can add graphics elements to the graph.
You can create, delete, or duplicate a graphics element and select, change, move, or
resize it. You can also change an element’s properties, such as its color or fill pattern, or
its values, such as the coordinates of one of its points. For instance, you can move a bar
from one side of the display area to the other, make a copy of it and place it in yet
another place, and change its fill color and pattern. You can undo and redo changes,
zoom in or out on the display, move an element to the foreground or background, and
read in or link to another graph that has already been created.
After you have made changes, you can save your modifications to a catalog and send
the modified graph to an output device, such as a printer.
For a complete description of the graphics editor, refer to the SAS Help facility for
SAS/GRAPH.
Note: Modifying your graphics output with the graphics editor does not change the
SAS programs that generated that output. 4

Transporting and Converting Graphics Output


You can use the following methods to transport and convert graphics output within
the SAS System:
3 Use the CPORT and CIMPORT procedures in base SAS software to transport
catalogs that contain graphics output to other operating environments that are
running the same version of SAS/GRAPH software.
3 Use a LIBNAME statement and the CATALOG procedure to convert catalogs from
Version 6 to Version 7 or Version 8.

Transporting Catalogs across Operating Environments


Use the CPORT and CIMPORT procedures to transport catalogs and catalog entries
from one machine to another machine running in a different operating environment. In
addition to graphics output stored in GRSEG catalog entries, SAS/GRAPH software
produces several other files that you can transport from host environment to host
environment. These other files include
3 colors maps
3 templates
3 fonts
3 device descriptions.
To transport catalog entries that contain graphics output (catalog entries of type
GRSEG), follow these steps:
1 Use the CPORT procedure to create a transport file from the catalog entries in the
current host environment. A transport file is a sequential file that contains the
catalog in SAS transport format. To create a transport file, you must specify a
catalog to be converted and a fileref for the transport file.
SAS/GRAPH Output Transporting Catalogs across Operating Environments 57

To retain the original order of the GRSEG entries in the catalog, use SELECT=
in the PROC CPORT statement to export individual graphs in the order they were
created. Otherwise, when you use the GREPLAY procedure to list the graphics
entries in the imported catalog, the procedure will list the entries in alphabetical
order, rather than the order in which they were created.
Note: Only the GREPLAY procedure can list catalog entries in the order they
were created. All other procedures list entries in alphabetical order.
To export a catalog that contains groups of entries created using the GREPLAY
procedure, you must use SELECT= in the PROC CPORT statement to select the
names of the groups, rather than the names of individual graphs, to be included in
the transport file. If you export the entire catalog without using SELECT=, the
groups are not maintained in the catalog created when you import the transport
file in the new host environment.
When you use the CPORT procedure, messages in the SAS log identify the
catalog entries that have been placed in the transport file. If the catalog entry was
created by replaying several graphs into a template, the log messages list the
names of all of the entries that contributed to the templated graph.
2 Move the transport file to the target machine, if necessary. You must move the
transport file in binary format. If you do not move the transport file in binary
format, the CIMPORT procedure cannot read the file you create.
Operating Environment Information: Use communications software or tape to
move the transport file. Refer to the documentation for your network or standard
procedures for using tape files. 4
3 Once you have moved the transport file to the target machine, import the
transport file into a catalog in the new host environment using the CIMPORT
procedure. The entries are imported in the order specified in SELECT= in the
PROC CPORT statement used to create the transport file.
The SELECT= option in the PROC CIMPORT statement does not affect the
order of the imported entries.

Note: You must use the CIMPORT procedure from the current version of the SAS
System. The CIMPORT procedure in a previous release cannot read a transport file
created by the CPORT procedure in the current version. For details on using the
CPORT and CIMPORT procedures, see the Base SAS Procedures Guide. 4

Example of Transporting GRSEGs


This example shows how to port three entries from the catalog MYLIB.GRAPHS.
First, the CPORT procedure writes selected graphs from MYLIB.GRAPHS to the
transport file TRANFILE. The SELECT option names the graphs to be ported.
libname mylib ’SAS-data-library’;
filename tranfile ’external-file’;

proc cport file=tranfile


catalog=mylib.graphs
select=(GPLOT.GRSEG, GPLOT1.GRSEG, GPLOT3.GRSEG);
run;

Once the transport file has been moved to the new host environment using
communications software or tape, the CIMPORT procedure creates a new catalog called
MYLIB.GRAPHS on the new machine.
58 Transporting Catalogs across Operating Environments Chapter 4

libname mylib ’SAS-data-library’;


filename tranfile ’external-file’;

proc cimport catalog=mylib.graphs


infile=tranfile
select=(GPLOT.GRSEG, GPLOT1.GRSEG, GPLOT3.GRSEG);
run;

Example of Transporting Color Maps and Templates


To transport color maps (catalog entries of type CMAP) and templates (catalog
entries of type TEMPLATE) from one host environment to another, use the CPORT and
CIMPORT procedures. For example, you could export a color map from the
NEWLIB.CMAPS catalog using the following statements:
filename tranfile ’external-file’;
libname newlib ’SAS-data-library’;

proc cport file=tranfile catalog=newlib.cmaps select=(mymap.cmap);


run;

After moving the transport file to the new host environment, you can import the color
map using the following statements:
filename tranfile ’external-file’;
libname newlib ’SAS-data-library’;

proc cimport infile=tranfile catalog=newlib.cmaps;


run;

Example of Transporting Fonts


To transport fonts (catalog entries of type FONT) from one operating system to
another, use the CPORT and CIMPORT procedures. For example, you could export a
font from the GFONT0.FONTS catalog using the following statements:
filename tranfile ’external-file’;
libname gfont0 ’SAS-data-library’;

proc cport file=tranfile


catalog=gfont0.fonts
select=(figures.font);
run;

After moving the transport file to the new host environment, you can import the font
using the following statements:
filename tranfile ’external-file’;
libname gfont0 ’SAS-data-library’;

proc cimport infile=tranfile catalog=gfont0.fonts;


run;

Example of Transporting Device Attributes and Device Entries


To transport device entries (catalog entries of type DEV) from one operating
environment to another, use the CPORT and CIMPORT procedures. For example, you
SAS/GRAPH Output About Exporting SAS/GRAPH Output 59

could export a device entry from the GDEVICE0.DEVICES catalog using the following
statements:
filename tranfile ’external-file’;
libname gdevice0 ’SAS-data-library’;

proc cport file=tranfile


catalog=gdevice0.devices
select=(cgm.dev);
run;

After moving the transport file to the new host environment, you can import the
device entry using the following statements:
filename tranfile ’external-file’;
libname gdevice0 ’SAS-data-library’;

proc cimport infile=tranfile catalog=gdevice0.devices;


run;

Converting Catalogs to a Different Version of SAS


To convert catalogs to a different version of SAS, for example from Version 6 to
Version 8, use the LIBNAME statement and the CATALOG procedure.
Note: You will not be able to use your old catalogs without transporting them first. 4
Before using PROC CATALOG, you must assign librefs to both catalogs and specify
the Version 6 Compatibility Engine (saseb) on the input catalog libname. Then use
PROC CATALOG with a COPY statement to convert a catalog from Version 6 to Version
7 or Version 8. For details on using the CATALOG procedure, see the Base SAS
Procedures Guide.
For example, the following statements can be submitted from Version 8 to assign the
Version 6 Compatibility Engine and convert a catalog from Version 6 to Version 8.
libname v6lib saseb ’SAS-data-library’;
libname v8lib ’SAS-data-library’;

proc catalog catalog=v6lib.v6cat;


copy out=v8lib.v8cat;
run;

About Exporting SAS/GRAPH Output


By default, SAS/GRAPH output is stored in SAS catalogs as catalog entries of type
GRSEG. These entries can be viewed and manipulated within the SAS System and, in
some operating environments, can be printed directly as hardcopy. However, you may
want to use your SAS/GRAPH output outside of the SAS System. For example, you
may want to
3 import your graphs into other software packages
3 use host system commands or applications to print or manage your graphs
3 run batch processes to create and print multiple copies of your graphs
3 create graphics output and HTML files that enable you to display SAS/GRAPH
output on the Web.
60 About Graphics Stream Files Chapter 4

In order to do these kinds of things with your SAS/GRAPH output, you must export
your graphs from SAS/GRAPH, using a different graphics file format, such as CGM,
GIF, or TIFF, and store them in external files.
For information on creating SAS/GRAPH output for Web publishing, see Chapter 9,
“Introducing SAS/GRAPH Output for the Web,” on page 369. For information on
SAS/GRAPH language elements and programs and on how procedure output is
generated, see Chapter 2, “SAS/GRAPH Programs,” on page 25. For information on
using and managing SAS/GRAPH output, see Chapter 4, “SAS/GRAPH Output,” on
page 47.

About Graphics Stream Files


When you export SAS/GRAPH output, you run the output through a device driver
that creates a graphics stream file or GSF. A GSF is an external file that contains
graphics commands. Typically, you select a device driver that produces the type of
graphics file format that you want, such as CGM, PS or EPS, GIF, or TIFF, although
you can select a driver that sends the output directly to a printer or other hardcopy
device without creating an external file. You can specify the exact name and location of
each file or assign a default location to which all files are sent.
Note: You can also use the Output Delivery System (ODS) or SAS/GRAPH device
drivers to generate SAS/GRAPH output as HTML and GIF files that you can view with
a Web browser. Details are discussed in Chapter 9, “Introducing SAS/GRAPH Output
for the Web,” on page 369. 4
Once you have created a GSF, you can
3 print the file using host commands
3 view the file with an appropriate viewer or browser
3 edit the file with the appropriate editing software
3 import the file into other software packages.

Note: A GSF is different from a SAS/GRAPH catalog entry. A GSF is an external


file that is independent of SAS, and a catalog entry is a type of SAS file. Consequently,
you use host commands to manipulate a GSF independent of the SAS System, whereas
you must use the SAS System to manipulate SAS catalog entries. For example, to view
graphics output stored in a catalog you must use the GREPLAY procedure or the
GRAPH window. 4

About Graphics File Formats


You can export your SAS/GRAPH output in many different graphics file formats.
These are some of the most common formats that SAS/GRAPH software supports:
BMP Windows bitmap
CGM Computer graphics metafile
EPS Adobe’s encapsulated PostScript language
GIF GIF format
HP-GL Hewlett Packard’s Graphics Language (plotter control language)
JPEG JPEG format
PBM Portable bitmap
SAS/GRAPH Output Ways to Export SAS/GRAPH Output 61

PDF Portable Document Format


PNG Portable Network Graphics format
PS Adobe’s PostScript language
PPM Portable pixmap
TIFF Tagged Image Format File
The type of graphics file format that you choose depends on how you are going to use
the output. If you are planning to import the graph into other software products, such
as Microsoft Excel or Word Perfect, you may prefer to create a CGM file. These
vector-based files are usually smaller than bitmapped files, and they can be edited. In
addition, they use hardware fonts and provide a clear image on high-resolution devices.
If you want to display the graph on a Web page, or import it into software that
cannot accept vector graphics like CGM, you will need to create a bitmapped file using
a format such as GIF or TIFF.
Note: The HTML and WEBFRAME drivers generate both HTML files and GIF files
specifically for use with a Web browser. For details, see Chapter 9, “Introducing SAS/
GRAPH Output for the Web,” on page 369. 4
Most software packages that process graphics input can accept one or more of these
file formats. Check the documentation for the hardware or software product to which
you want to send the graph to determine what file format or formats it can use.
For a complete list of graphics file formats available with SAS/GRAPH in your
operating environment, refer to the Device Help for SAS/GRAPH in the SAS Help
facility.

Ways to Export SAS/GRAPH Output


There are several ways to send SAS/GRAPH output to an external file in a different
graphics file format. You can export graphics output in these ways:
3 From the GRAPH window or the Graphics Editor window, use menu selections to
select the type of file format and specify a destination for the output that is
displayed in the window. When you export SAS/GRAPH output in this way, you
are limited to the types of file formats that the Export as Image window supports
in your operating environment. For details see “Exporting SAS/GRAPH Output
Interactively” on page 62.
Operating Environment Information: In Windows operating environments, WMF
formats cannot be exported using this method. 4
3 Use SAS/GRAPH program statements to direct the output to a graphics stream
file. When you use program statements to create a GSF, you explicitly specify a
SAS/GRAPH device driver. This driver can be one of the drivers supplied with
SAS/GRAPH software and stored in SASHELP.DEVICES, or a custom driver that
you have created. For details see “Exporting SAS/GRAPH Output with Program
Statements” on page 62.
3 Create a custom device driver that contains all of the commands for producing a
GSF. For details see “Exporting SAS/GRAPH Output Using Modified Device
Entries” on page 72.
3 Use the SAS/GRAPH web drivers or the Output Delivery System to create HTML
and GIF files. For details see Chapter 9, “Introducing SAS/GRAPH Output for the
Web,” on page 369.
62 Exporting SAS/GRAPH Output Interactively Chapter 4

Exporting SAS/GRAPH Output Interactively


You can export SAS/GRAPH output interactively from either the Graph window or
from the Graphics Editor window. To export a graph from one of these windows, follow
these steps:
1 Open the window and display the graph.
2 From the File menu select Export as Image
3 In the Export as Image window, select a file type and specify a destination or file
name.
4 Close the window by choosing Save or OK (button text depends on the operating
environment).
Because you can export only one catalog entry at a time, this method is most useful
for quickly exporting a few graphs.
Although you can use this method to create many types of graphics stream files, you
have a much larger choice of device drivers when you use SAS/GRAPH program
statements to create a GSF.

Exporting SAS/GRAPH Output with Program Statements


When you use program statements to create external files for your SAS/GRAPH
output, you use one of these processes:
3 create one file that contains one graph
3 create one file that contains multiple graphs
3 create multiple files that each contain one graph.
You can send the graphics output to external files either at the time you run the
program that creates the graphs, or later when you replay them from the catalog in
which they are stored. For this reason, these methods are most useful for processing
large quantities of output. In addition, using program statements allows you to specify
exactly the device driver you want and is therefore a more flexible and powerful way of
exporting SAS/GRAPH output.
The following sections provide some information common to all the processes and
then describes each process in detail.

General Information

Common Requirements
Regardless of the process you use to create a GSF from a SAS/GRAPH program, you
must specify the following:
3 a destination for the output. This can be an aggregate file storage location (for
example, a directory or a partitioned data set) or a specific file. Typically you
specify the destination with a FILENAME statement and one or more graphics
options. For more information, see “FILENAME Statement” on page 28.
3 a device driver that creates the type of graphics output that you want.
3 whether SAS/GRAPH should replace an existing file or append new records to it.
By default, SAS/GRAPH replaces an existing file with newly created output of the
same name. For details, see “Replacing Existing External Files” on page 70.
SAS/GRAPH Output General Information 63

Each requirement is explained in detail in the individual process descriptions.

Naming the Output


When you are working with both catalog entries and external files, you should
understand how both types of output are named.

Using the NAME= option


You can use the NAME= option in the SAS/GRAPH procedure to specify a name for
the catalog entry that the procedure generates. How this name is used depends on
whether the FILENAME statement points to a specific external file or to an aggregate
file storage location.
3 If you specify a specific filename for the external file and also use the NAME=
option, the external file is assigned the name specified in the FILENAME
statement and NAME= controls only the name given to the created catalog entry.
When you specify the filename, you should include the appropriate file extension,
such as .CGM, .GIF, or .PS).
3 If you specify an aggregate file storage location instead of a specific filename, and
also use the NAME= option, the name of the external file is built from the name of
the catalog entry, which is determined by the value of NAME=. In this case,
SAS/GRAPH supplies the appropriate file extension.
See Table 4.1 on page 64 for examples.

Using the default output name


If you omit NAME=, SAS/GRAPH uses the default naming convention to name the
catalog entry, and in some cases the external file. This convention uses up to eight
characters of the procedure name as the base name for the catalog entry. If the name
generated by the procedure duplicates an existing entry, the name is incremented, for
example, GCHART, GCHART1, GCHART2, and so forth. For details, see the
description of the NAME= option for a specific procedure.
3 If you specify a specific filename for the external file and omit the NAME= option,
the external file uses the name specified in the FILENAME statement and the
catalog entry uses the default name. When you specify the filename, you should
include the appropriate file extension, such as .CGM, .GIF, or .PS.
3 If you specify an aggregate file storage location instead of a specific filename, and
omit the NAME= option, both the catalog entry and the external file use the
default name and SAS/GRAPH supplies the appropriate file extension.
See Table 4.1 on page 64 for examples.

File extensions
When you send SAS/GRAPH output to an aggregate file storage location,
SAS/GRAPH generates the name of the external file by taking the catalog entry name
and adding the appropriate file extension. Most drivers provide a default extension. If a
driver does not generate an extension, SAS/GRAPH uses the default extension .GSF. To
specify a different extension from the one SAS/GRAPH provides, use the EXTENSION=
graphics option. (For details, see “EXTENSION” on page 288).

Example
illustrates how SAS/GRAPH generates names for catalog entries and external files,
depending on 1) whether the NAME= option is used, and 2) on the fileref specification.
This illustration assumes the GSLIDE procedure and DEV=GIF:
64 Saving One Graph to a File Chapter 4

Table 4.1 How SAS/GRAPH Generates Entry Names and File Names

If... And... Then


NAME=’FRED’ fileref points to a file named catalog entry name: FRED
’MYSLIDE.GIF’ external file name:
MYSLIDE.GIF

NAME=’FRED’ fileref points to a storage catalog entry name: FRED


location (for example, a external file name: FRED.GIF
directory)

NAME= (not specified) fileref points to a file named catalog entry name: GSLIDE
’MYSLIDE.GIF’ external file name:
MYSLIDE.GIF
NAME= (not specified) fileref points to a storage catalog entry name: GSLIDE
location (for example, a external file name:
directory) GSLIDE.GIF

Note: When the fileref points to an aggregate file storage location, the name of the
catalog entry always determines the name of the external file. It does not matter
whether the catalog entry name is the default name or a name assigned by NAME=. 4

CAUTION:
If the graph created by the program already exists in the catalog, a new catalog entry with
an incremented name will be created and a new external file may be created rather than
updating the existing file. 4
You cannot replace individual entries in a catalog; therefore, to replace an entry you
must first delete the entry and then re-create it. Therefore, even though the contents of
the external file are replaced, the catalog entry is not. Each time you submit the
program, a new entry is created and the catalog entry name is incremented.

Saving One Graph to a File


The simplest way to save one graph to a file is to use the FILENAME statement, the
GSFNAME= graphics option, and the default setting GSFMODE=REPLACE to create
one graphics stream file. These steps describe the general process:
1 Use a FILENAME statement to define a fileref for the external file where you
want to send the output. The file name must be the complete physical name of the
external file and should include a file extension that indicates what type of
graphics file you are creating, for example .GIF for a GIF file.
2 Assign the fileref to the GSFNAME= graphics option.
3 Specify the device driver with the DEVICE= graphics option.
4 Use the default setting GSFMODE=REPLACE so that SAS/GRAPH produces only
one graph per file (unless BY-group processing is in effect). Because REPLACE is
the default setting, you can omit GSFMODE=.
5 Submit the SAS/GRAPH program.
Note: The GSF remains open while the SAS/GRAPH procedure is running. Be sure
to end the procedure by submitting another procedure step, DATA step, or QUIT
statement. To be really safe, you can submit a FILENAME fileref CLEAR; statement to
explicitly close the GSF.
SAS/GRAPH Output Saving One Graph to a File 65

Operating Environment Information: On certain systems, other graphics options may


be required. For more information on creating a graphics stream file, refer to the SAS
Help facility for SAS/GRAPH Device Drivers for your operating environment. 4
4

Example
This example creates one GSF that contains one text slide created by a group of
TITLE and FOOTNOTE statements and the GSLIDE procedure.
Define the fileref. The FILENAME statement associates the fileref GRAFOUT with
the external file that is the destination for the GSF. The file extension .PS indicates
that the graphics output is PostScript.
filename grafout ’mygraph.ps’;

Specify graphics options for the GSF. RESET=ALL resets all global statements and
graphics options. DEVICE= specifies a PostScript device driver. GSFNAME= assigns
the fileref GRAFOUT as the destination for the GSF. GSFMODE=REPLACE (the
default) causes the contents of the external file to be replaced each time the graphics
procedure is run.
goptions reset=all
device=pscolor
gsfname=grafout
gsfmode=replace
ftext=swissb;

Produce one text slide. NAME= specifies the name that is assigned to the catalog
entry created by the procedure. If you omit NAME=, SAS/GRAPH uses the default
naming convention to name the entry.
proc gslide border name=’proposal’;
title1 h=4 ’Proposed Design Improvements:’;
title2 h=3 ’* Increase Stability’;
title3 h=3 ’* Increase Speed’;
title4 h=3 ’* Reduce Weight’;
footnote h=2 j=l ’ABC Company’;
run;
quit;

When you submit these statements, SAS/GRAPH does the following if no graphs of
the same name exist in the catalog:
3 Creates one catalog entry named PROPOSAL in WORK.GSEG.
3 Creates one external file that contains the output from the GSLIDE procedure and
sends a message to the LOG reporting the number of records and the name of the
file to which they were written. The file name is the one specified in the
FILENAME statement.
Because the destination is a specific file and because GSFMODE=REPLACE, each
time you run the program it replaces the contents of the external file. Therefore, this
method is particularly useful when you want to update an external file by resubmitting
an existing program.
However, if there is more than one run of a graphics procedure in this program, the
file would contain only the graphics output from the last procedure run because this
program replaces the external file each time a graphics procedure is run.
Note: Even though the contents of the external file are replaced, the catalog entry is
not. Unless you explicitly delete the existing entry named PROPOSAL, each time you
66 Saving Multiple Graphs to One File Chapter 4

submit the program, a new entry is created and the catalog entry name is incremented.
This table illustrates what happens if you submit the above program three times
without deleting the catalog entries: 4

Table 4.2

Pass Catalog Entries File Name

1 PROPOSAL mygraph.ps
2 PROPOSA1 mygraph.ps

3 PROPOSA2 mygraph.ps

Note that each new catalog entry replaces the contents of the external file, in this
case, mygraph.ps. For more information, see “Replacing Existing External Files” on
page 70.
For a complete description of the graphics options used in this example, see Chapter
8, “Graphics Options and Device Parameters Dictionary,” on page 261.

Saving Multiple Graphs to One File


If your program creates multiple graphs that you want to store in one file, you follow
the same steps as those for saving one graph to one file except you specify
GSFMODE=APPEND to add each new graph to the end of the file instead of replacing
the file.

Example
This example stores several text slides in one external file. The program is the same
as the previous example except the GOPTIONS statement specifies
GSFMODE=APPEND and the GSLIDE procedure uses RUN-group processing to create
multiple slides. Each slide includes the current TITLE statement and all previously
defined TITLE and FOOTNOTE statements.
Define the fileref.
filename grafout ’mygraph.ps’;

Specify graphics options for the GSF. GSFNAME= assigns the fileref GRAFOUT as
the destination for the GSF. GSFMODE=APPEND adds each new piece of output to the
end of the external file.
goptions reset=all
device=pscolor
gsfname=grafout
gsfmode=append
ftext=swissb
rotate=landscape;

Produce four text slides. Each RUN-group generates a new catalog entry. NAME=
specifies the base name for each catalog entry created by the procedure.
proc gslide border name=’proposal’;
footnote h=2 j=l ’ABC Company’;
title1 h=4 ’Proposed Design Improvements:’;
SAS/GRAPH Output Saving Multiple Graphs to One File 67

run;
title1 h=3 ’* Increase Stability’;
run;
title1 h=3 ’* Increase Speed’;
run;
title1 h=3 ’* Reduce Weight’;
run;
quit;

When you submit these statements, SAS/GRAPH does the following if no graphs of
the same name exist in the catalog:
3 Creates a new catalog entry for each graph, beginning with the name PROPOSAL.
After the first graph is created, the entry name is incremented so that subsequent
graphs are called PROPOSA1, PROPOSA2, and so forth.
3 Creates one external file that contains all of the output from the GSLIDE
procedure. The file name is the one specified in the FILENAME statement. Each
time a graph is added to the file, SAS/GRAPH sends a message to the LOG
reporting the number of records and the name of the file to which they were
appended.

Note: Because the destination is a specific file and because the GSFMODE= setting
is APPEND, each time you run the program SAS/GRAPH adds the new graphs to the
external file. If you want the file to contain only the newly created graphs, delete it
before resubmitting the program. 4
In addition, if you resubmit the program without deleting the original catalog entries,
SAS/GRAPH will create four new entries that will be added to the catalog entry and four
new graphs appended to the external file, both of which will contain all eight graphs.
This table illustrates what happens if you submit this program twice without
deleting the catalog entries or the external file:

Table 4.3

Pass Catalog Entries File Name File Contents

1 PROPOSAL mygraph.ps PROPOSAL, PROPOSA1,


PROPOSA1 PROPOSA2, PROPOSA3

PROPOSA2
PROPOSA3
2 PROPOSAL mygraph.ps PROPOSAL, PROPOSA1,
PROPOSA1 PROPOSA2, PROPOSA3,
PROPOSA4, PROPOSA5,
PROPOSA2
PROPOSA6, PROPOSA7
PROPOSA3
PROPOSA4
PROPOSA5
PROPOSA6
PROPOSA7

For more information, see “Replacing Existing External Files” on page 70.
68 Saving Multiple Graphs to Multiple Files Chapter 4

Saving Multiple Graphs to Multiple Files


When you want your SAS/GRAPH program to create multiple files that each contain
one graph, you can either
3 use a FILENAME statements for each PROC statement to explicitly specify a
destination file for each graph. To do this, simply repeat as many times as
necessary the process described in “Saving One Graph to a File” on page 64.
3 use one FILENAME statement to specify an aggregate file storage location as the
destination and let SAS/GRAPH automatically name and create the files for you.
These steps describe the general process:
1 Use a FILENAME statement to define a fileref for the aggregate file storage
location, such as a directory or PDS, where you want to send the output. Do not
point to a specific file.
2 Assign the fileref to the GSFNAME= graphics option.
3 Specify the device driver with the DEVICE= graphics option.
4 Use the default setting GSFMODE=REPLACE so that SAS/GRAPH produces only
one graph per file. Because REPLACE is the default setting, you can omit
GSFMODE=.
5 Submit the SAS/GRAPH program.

Although the general technique is the same, there are significant differences between
directing your graphics output to a specific file and directing it to an aggregate file
storage location. These differences are mostly concerned with how the file is named.
When the destination is an aggregate file storage location, SAS/GRAPH not only
creates the external file, it also names it. When SAS/GRAPH names an external file, it
always uses the name of the entry in the output catalog. This name is either
3 the name you specify in the NAME= option in the procedure
3 the default name supplied by SAS/GRAPH, such as GSLIDE.
In addition, SAS/GRAPH automatically appends the correct file extension to the
external file name. For example, if the output is named Q1SALES and the external file
is a GIF file, the file name is Q1SALES.GIF.
This technique of building the file name from the catalog entry name affects what
you do when you want to replace the contents of a file created in this way. For details,
see “Replacing Existing External Files” on page 70.

Example
This example creates four text slides and stores each one in a separate external file.
The program is similar to the previous examples except the fileref points to an
aggregate storage location instead of to a specific file.
Define the fileref. The FILENAME statement assigns an aggregate file storage
location as the destination for the files.
filename grafout ’external-file-location’; /* such as a directory */

Specify graphics options for the GSF. GSFNAME= assigns the fileref GRAFOUT as
the destination for the GSF. GSFMODE=REPLACE (the default) replaces the contents
of the external files with catalog entries of the same name.
goptions reset=all
device=pscolor
gsfname=grafout
SAS/GRAPH Output Saving Multiple Graphs to Multiple Files 69

gsfmode=replace
ftext=swissb
rotate=landscape;

Produce four text slides. Each RUN-group generates a new catalog entry. NAME=
specifies the base name for each catalog entry that is generated by the procedure. This
name is also the base name for the external files.
proc gslide border name=’proposal’;
footnote h=2 j=l ’ABC Company’;
title1 h=4 ’Proposed Design Improvements:’;
run;
title1 h=3 ’* Increase Stability’;
run;
title1 h=3 ’* Increase Speed’;
run;
title1 h=3 ’* Reduce Weight’;
run;
quit;

When you submit these statements, SAS/GRAPH does the following if no graphs of
the same name exist in the catalog:
3 Creates a new catalog entry for each graph, beginning with the name PROPOSAL.
After the first graph is created, the entry name is incremented so that subsequent
graphs are called PROPOSA1, PROPOSA2, and so forth.
3 Creates one external file for each catalog entry. The name of the file is the same as
the entry name plus the extension. In this case, the files are named
PROPOSAL.PS, PROPOSA1.PS, and so forth. For each file created, SAS/GRAPH
sends a message to the LOG reporting the number of records and the name of the
file to which they were written.

Note: Because you cannot replace individual entries in a catalog, each time you run
the program SAS/GRAPH creates new catalog entries and consequently new files. If
you want to replace the files, you must delete the corresponding catalog entries before
resubmitting the program. 4
This table illustrates what happens if you submit this program twice without
deleting the catalog entries:
70 Replacing Existing External Files Chapter 4

Table 4.4

Pass Catalog Entries File Name

1 PROPOSAL proposal.ps
PROPOSA1 proposa1.ps
PROPOSA2 proposa2.ps
PROPOSA3 proposa3.ps

2 PROPOSA4 proposa4.ps
PROPOSA5 proposa5.ps
PROPOSA6 proposa6.ps
PROPOSA7 proposa7.ps

Because the catalog names increment, there is never a matching file that the new
catalog can replace. Therefore, unless you delete the existing entries, the program
continues to create new files. To delete the existing entries, first run a GREPLAY
procedure with the DELETE option:
proc greplay igout=work.gseg nofs;
delete proposal proposa1 proposa2 proposa3;

Replacing Existing External Files


When you are working with aggregate file storage locations and automatic file
naming, it is important to remember that GSFMODE=REPLACE replaces a file only if
the name of the catalog entry is the same as the name of the file and you are using the
same type of driver. For example, to replace a file named Q1SALES.PS, your program
must create a catalog entry named Q1SALES, and you must also be using a PostScript
driver. If the entry named Q1SALES already exists in the catalog, SAS/GRAPH will
increment the name to Q1SALES1, and either create a new file with the incremented
name or replace an existing file whose name matches the new incremented name.
Therefore, to replace the contents of existing external files with a new set of graphs,
you must be sure that the catalog you are using does not already contain entries of the
same name. There are several ways to assure that a catalog does not contain entries
with the same names as your files:
3 Use a temporary catalog, such as the default WORK.GSEG, to store the output
and start a new SAS session. Initially, the catalog is empty.
3 Use a temporary or permanent catalog and use the GREPLAY procedure to do
either of the following:
3 delete the entire contents of the catalog before you submit your program
3 delete specified entries before you submit your program.

One additional method for replacing catalog entries is rarely recommended because it
is easy to accidentally delete catalog entries that you did not intend to delete. If you
want to replace the entire contents of the catalog and if you are running only one
procedure, you can use the graphics option GOUTMODE=REPLACE. Whenever a new
procedure starts, GOUTMODE=REPLACE replaces the entire contents of the current
catalog with the new entries; it does not replace individual entries.
SAS/GRAPH Output Replacing Existing External Files 71

Example
The following example uses the GREPLAY procedure to explicitly delete specified
catalog entries so that you can re-create them and replace the corresponding external
files. This example uses the permanent catalog MYLIB.GRAFCAT.
3 The GREPLAY procedure explicitly deletes existing catalog entries that have the
same name as the entries to be created. If no entries exist, PROC GREPLAY
issues a message and the program continues.
3 The GSLIDE procedure generates four text slides and stores them in the catalog
specified by GOUT=. NAME= specifies PROPOSAL as the base name for the
catalog entries created by the procedure.

Define the libref for the permanent catalog.


libname mylib ’SAS-data-library’;

Define the fileref. The FILENAME statement assigns an aggregate file storage
location as the destination for the files.
filename grafout ’external-file-location’;

Specify graphics options for the GSF. GSFNAME= assigns the fileref GRAFOUT as
the destination for the GSF. GSFMODE=REPLACE (the default) replaces the contents
of the external files with catalog entries of the same name.
goptions reset=all
device=pscolor
gsfname=grafout
gsfmode=replace
ftext=swissb
rotate=landscape;

Delete existing catalog entries of the same name. The GREPLAY procedure deletes
the specified catalog entries. These are the catalog names generated by the NAME=
option in the procedure. If the entries do not exist, PROC GREPLAY issues a message
and the program continues.
proc greplay nofs igout=mylib.grafcat;
delete proposal proposa1 proposa2 proposa3;
run;

Produce four text slides. Each RUN-group generates a new catalog entry. NAME=
specifies the base name for each catalog entry generated by the procedure. This name is
also the base name for the external files.
proc gslide border gout=mylib.grafcat name=’proposal’;
footnote h=2 j=l ’ABC Company’;
run;
title1 h=3 ’* Increase Strength’;
run;
title1 h=3 ’* Reduce Drag’;
run;
title1 h=3 ’* Increase Resistance to Sheer’;
run;
quit;

When you submit these statements, SAS/GRAPH does the following:


3 deletes the specified entries from the catalog MYLIB.GRAFCAT.
72 Other Ways to Assign the Destination Chapter 4

3 creates a new catalog entry in MYLIB.GRAFCAT for each slide, and increments
the entry names: PROPOSAL, PROPOSA1, PROPOSA2, and PROPOSA3.
3 creates one external file for each catalog entry. The file name is built from the
catalog entry name. If a file of the same name already exists, SAS/GRAPH
replaces the contents of the file.

Other Ways to Assign the Destination


You can use the GACCESS= graphics option to assign the destination for a graphics
stream file. There are two ways to do this.

Using GACCESS=GSASFILE
This method is similar to the GSFNAME= method described in the previous sections.
3 Use a FILENAME statement and assign a destination to the fileref GSASFILE.
When you use GACCESS, the fileref must be named GSASFILE. The destination
can be either a specific file or an aggregate file storage location.
3 Assign GSASFILE to the GACCESS= graphics option instead of to GSFNAME=.
For example, these statements define and assign the fileref for an aggregate file
storage location:
/* define a fileref for the destination */
filename gsasfile ’external-file-location’;

/* assign the fileref and specify a device */


goptions reset=all gaccess=gsasfile device=gif;

Using GACCESS= to Explicitly Specify a Destination


You can also use GACCESS= to assign the destination and omit the FILENAME
statement. In this case, you must also include the SASGASTD output format and quote
the entire value. The destination can be either a specific file or an aggregate file storage
location.
For example, this statement assigns a specific file location as the destination for the
graphics stream file:
/* assign the fileref and specify a device */
goptions reset=all
gaccess=’sasgastd > my-graph-file.gif’
device=gif;

Exporting SAS/GRAPH Output Using Modified Device Entries


If you frequently send graphics output to the same file or device, you may want to
create a custom device entry that automatically sends your output to that destination.
This simplifies the process by eliminating several graphics options from the GOPTIONS
statement and allowing you to create the GSF by simply specifying the custom device
entry with the DEVICE= graphics option.
To modify a device entry, use the GDEVICE procedure using either code-based
statements or the GDEVICE windows. In either case, copy the original entry from the
SASHELP.DEVICES catalog to your personal catalog (typically, GDEVICE0.DEVICES).
SAS/GRAPH Output 73

Then simply change the device parameters to create an entry that produces graphics
stream files by default.
Often these device parameters correspond to the graphics options in your program.
For example, if your program uses the fileref GRAFOUT, you can enter a value of
Grafout in the Gsfname: field in the Host File Options window.
See Chapter 31, “The GDEVICE Procedure,” on page 915 for more information on
modifying device entries. Refer to the Device Help for SAS/GRAPH in the SAS Help
facility for lists of available drivers and for specific information on modifying device
entries in your operating environment.

The Metagraphics Driver Facility


You can use the SAS/GRAPH Metagraphics facility to write your own device drivers
to create files in other formats for use by other graphics software. The Metagraphics
driver facility can be used to develop driver support for virtually any device you choose.
It is device-intelligent and can support most hardware features. A user-written
program is required to translate the Metagraphics metafile into the appropriate
graphics language recognized by the hardware product.
For assistance in creating a Metagraphics driver, contact Technical Support.
74
75

CHAPTER

5
SAS/GRAPH Fonts

Overview 75
Specifying Fonts in SAS/GRAPH Programs 75
Font Specifications 76
Default Fonts 77
Font Locations 77
Using Hardware Fonts 78
Default Hardware Fonts 78
Using a GOPTIONS Statement to Change the Default Hardware Font 79
Using the GDEVICE Procedure to Change the Default Hardware Font 79
Specifying the Full Font Name 80
Specifying Alternative Hardware Fonts 80
Specifying Special Characters 81
Using SAS/GRAPH Software Fonts 82
Rendering Fonts 82
Font Lists 82

Overview
The SAS/GRAPH software has a variety of type styles that you can use to display
text and special characters in your procedure output. These type styles are stored in
fonts that you can specify when you want to select type for the text on your graphs or
choose plot symbols.
This chapter explains how to specify a font, how to change the default hardware font,
how to produce special characters, and how to select a software font.
After the FONTREG procedure runs, the SASEMF device driver and graphs in the
ODS PDF destination can use FreeType fonts without any modification. However, you
will need to modify the GIF, JPEG, PNG, and TIFFP device drivers before these can
access FreeType fonts. For details about using FreeType fonts, refer to The FONTREG
Procedure.
Note: In some operating environments, you can access the System or TrueType fonts
that are available to the host print driver that is currently set for your printer. For
more information, see the SAS documentation for your operating environment. 4

Specifying Fonts in SAS/GRAPH Programs


When you select a type style for text or plot symbols, you use statement options to
assign the font. You can assign fonts for any amount of text from a single character in a
76 Font Specifications Chapter 5

title to all the text in your output. When the SAS/GRAPH software encounters an
explicit font specification in a SAS statement, it uses the font that you specify rather
than a font that is specified in a GOPTIONS statement or the device’s hardware font.
With SAS/GRAPH you can select existing hardware or software fonts or create your
own font. Hardware fonts are fonts that exist on hardcopy output devices (such as
printers or plotters) or on a computer. PC TrueType and UNIX system fonts are
examples of hardware fonts that exist on computers. Software fonts are the fonts
delivered with SAS. The software fonts are the entries in the SASHELP.FONTS
catalogue. If you do not make a font assignment, in most cases the SAS/GRAPH
software uses the default hardware font for your device.
Note: Java and ActiveX devices do not support software fonts. 4

Font Specifications
A font specification is an argument that takes a font name as its value. Font
specifications typically take the following form:
FONT=font
F=font
where font is a valid SAS name. The specified font can be
3 a software font that is either
3 a catalog entry that is supplied by SAS Institute (for example, CENTB),
or that is user-generated (for example, MYFONT generated by the
GFONT procedure)
3 a system font that is available in your operating environment.
Note: Font names greater than eight characters in length must be
enclosed in quotation marks. 4
To see a list of available software fonts, issue the FONTLIST command
from the SAS command line. See Base SAS Software Help for more
information on the FONTLIST command. The resulting window enables you
to copy a font name into the copy buffer so that you can paste the name into
your SAS program. The window’s Family box lists the software fonts that are
supplied by SAS Institute. Choose the System button to see a list of the
system fonts that are available in your operating environment. Choose the
Help button for help on using the window. See “Font Lists” on page 82 for
more information on the valid font names for Institute-supplied software
fonts.
3 a hardware font that is either in the form of
3 HWxxxnnn
3 hardware-font-name.
See “Specifying Alternative Hardware Fonts” on page 80 for details.
For example, the following statement specifies the Century Bold font in a title:
title font=centb ’This is a Title’;

However, there are other arguments that also take font as a value. For example, the
FTEXT= option in the following GOPTIONS statement specifies the Century Bold font
for all text that does not have a more explicit font specification:
goptions ftext=centb;
SAS/GRAPH Fonts Font Locations 77

Note: In this chapter, the argument FONT= is used to represent any argument that
takes font as its value. 4

Default Fonts
When a font is needed, theSAS/GRAPH software looks first for a font specification in
the statement or procedure that produces the output, and then it looks in the
GOPTIONS statement. If no font specification is found, the SAS/GRAPH software uses
one of the following:
3 for TITLE1 statements, the default font is SWISS.
3 for all other text, the default font is NONE. The NONE font specifies the default
hardware font for the output device.
In some cases, the device’s hardware font cannot be used and the SIMULATE font is
used instead. The SIMULATE font is a software font that simulates the device’s
hardware characters by allowing the same amount of space for the text that the
hardware characters use. The SIMULATE font is used whenever the default hardware
font is unavailable, including the following situations:
3 FONT=NONE or FONT=HWxxxnnn or no font is specified, and one of the
following conditions or sets of conditions is also met:
3 GOPTIONS NOCHARACTERS is specified.
3 The device driver does not support hardware text.
3 You request a hardware font for a different device.
3 You specify an angle or rotation for the characters that the device does not
support.
3 The device does not have scalable hardware characters (that is, hardware
characters can be generated only in the proportions specified with the font),
and one of the following conditions is also met:
3 The values of the HPOS= and VPOS= graphics options do not match the
values displayed in the LCOLS or PCOLS field or the LROWS or
PROWS field in the Detail window of the device entry.
3 The HSIZE= or VSIZE= graphics option is set to values that are not the
default.
3 You replay a graph in a template that is not the same size as the full
size of the graphics output area, or you use a device driver other than
the one you used to create the graph.
3 The target device and the display device have different values for the
HPOS= and VPOS= graphics options.
3 You use any height specification, including the HEIGHT=, HTEXT=,
HTITLE=, and HBY= graphics options, that is not equal to 1.

You should never delete the SIMULATE font from the fonts catalog.
Note: You can change the font that is used as the SIMULATE font with the
SIMFONT= graphics option. If you use the SIMFONT= option, it is better to specify a
uniform font. Do not specify a hardware font as a substitute for SIMULATE. See
“SIMFONT” on page 351 for more information on the SIMFONT= option. 4

Font Locations
SAS/GRAPH software fonts are stored in catalogs. The SAS/GRAPH software looks
only into catalogs with certain librefs and names to find fonts. By default, SAS/GRAPH
78 Using Hardware Fonts Chapter 5

searches for the font in the catalog SASHELP.FONTS, which contains


Institute-supplied fonts, key maps, and device maps.
If you want to specify fonts that you have created locally, submit a LIBNAME
statement that associates the libref GFONT0 with the location of your font catalog. If
you have specified more than one libref in the sequence GFONT0 through GFONT9,
theSAS/GRAPH software performs a sequential search of these catalogs when locating
the font that you have specified.
When you specify a font name, the SAS/GRAPH software searches for the font in the
following order:
1 If a SAS data library with the libref GFONT0 exists, then the SAS/GRAPH
software looks there for a catalog named FONTS. If GFONT0.FONTS exists, it is
checked for the specified font. If the font is not there, then the SAS/GRAPH
software looks next for a library with the libref GFONT1 and for a catalog named
FONTS in that library. The search is repeated for the sequence of librefs through
GFONT9.
2 If the SAS/GRAPH software fails to find the specified font in any FONTS catalog
in the libraries GFONT0 to GFONT9, or if it finds a GFONTn libref without a
FONTS catalog, or if it encounters an undefined libref in that sequence before
locating the specified font, then it searches for the font in SASHELP.FONTS.
(SASHELP is one of the standard librefs defined automatically whenever you start
your SAS session; you do not need to issue a LIBNAME statement to define it.)
3 If the specified font is not found in SASHELP.FONTS, then a warning is issued
and the SIMPLEX font is used. The SIMPLEX font is the default software font
and should never be deleted from the fonts catalog.
See Chapter 32, “The GFONT Procedure,” on page 939 for additional information on
specifying the libref GFONT0.

Using Hardware Fonts


There are four ways to use hardware fonts with SAS/GRAPH output:

3 By using the CHARTYPE= graphics options in a GOPTIONS statement to assign


the number of a font listed in the Chartype window of your device entry as the
default hardware font. See “Using a GOPTIONS Statement to Change the Default
Hardware Font” on page 79 for details.
3 By using the GDEVICE procedure to specify the number of the font you want to
use as the default hardware font. See “Using the GDEVICE Procedure to Change
the Default Hardware Font” on page 79 for details.
3 By specifying the full font name as it appears on the Chartype window of the
device driver entry. See “Specifying the Full Font Name” on page 80 for details.
3 By explicitly specifying a hardware font name of the type HWxxxnnn. See
“Specifying Alternative Hardware Fonts” on page 80 for details.
There are several advantages to using hardware fonts instead of software fonts.
Hardware fonts often are produced faster than software fonts and produce smaller
output files. Also, some devices, such as laser printers with resident hardware fonts,
may produce better quality output with hardware fonts than with software fonts.

Default Hardware Fonts


SAS/GRAPH software uses a device’s default hardware font to draw characters
when both of the following conditions are true:
SAS/GRAPH Fonts Default Hardware Fonts 79

3 No font specification is made in the SAS/GRAPH program, or FONT=NONE is


specified.
3 The hardware font can be used. See “Default Fonts” on page 77 for details on
when hardware fonts cannot be used.
Every available hardware font for a particular device has a number associated with
it. This number and the corresponding font name are listed in the Chartype window of
the device entry for your device. The default hardware font is the font whose number is
entered in the Chartype field in the Parameters window of the device entry. When
FONT=NONE or no font is specified, SAS/GRAPH software uses the font assigned to
this field.
If your device has more than one hardware font, there are two ways you can assign a
different default hardware font:

3 By specifying the font with the CHARTYPE= option in a GOPTIONS statement.


See “Using a GOPTIONS Statement to Change the Default Hardware Font” on
page 79
3 By using the GDEVICE procedure to modify the value of the Chartype field in the
Parameters window of your device entry. See “Using the GDEVICE Procedure to
Change the Default Hardware Font” on page 79 for more details.

If your device has only one hardware font (this is often the case), the Chartype field
has a value of 0.

Using a GOPTIONS Statement to Change the Default Hardware Font


To assign the default hardware font for your current SAS session, use the
CHARTYPE= option in a GOPTIONS statement. Assign it the actual number of the
hardware font as listed in the Chartype field in the Chartype window of the device
entry for your device.
Using the CHARTYPE= option only changes the default font for the duration of your
SAS session; using the CHARTYPE= option does not change the value of the field in the
device entry. (See “CHARTYPE” on page 269 for a complete description of the
CHARTYPE= option.)
When you specify a hardware font by using the graphics option CHARTYPE=n and
the font specification NONE, the size of the character cells is determined by the current
values for the HPOS= and VPOS= options. This means that the font is drawn using the
current cell size. As a result, the aspect ratio of the displayed font may be different and
the height of the characters, if displayed in cells, may be affected.
CAUTION:
Specifying a nonscalable hardware font with the CHARTYPE= option may cause the
SIMULATE font to be used. 4

In addition, if the font selected with CHARTYPE= is not scalable and if the values of
HPOS= and VPOS= do not match the values of the Rows and Cols fields in the
Chartype window, then the SIMULATE font is substituted.

Using the GDEVICE Procedure to Change the Default Hardware Font


To change the default hardware font with the GDEVICE procedure, change the
Chartype field in the Parameters window for the device:
1 Invoke the GDEVICE procedure and select the entry for your device.
2 Go to the Chartype window and review the available fonts.
80 Specifying the Full Font Name Chapter 5

3 Note the number of the font that you want to use as the default font and go to the
Parameters window.
4 Enter the number of the font in the Chartype field.
5 Close the window and exit the procedure.

Note: If you change the number in the Chartype field in the Parameters window of
the device entry, the change is permanent and remains in effect from one SAS session
to another until you change the entry again. 4
(See Chapter 31, “The GDEVICE Procedure,” on page 915 for information on viewing
device entries and changing device parameters.)

Specifying the Full Font Name


You can specify the full font name in any SAS statement where a font specification is
valid (such as for the FTEXT=font graphics option or the FONT=font specification on a
TITLE statement). For the value font, specify the full font name exactly as it appears
in the Chartype window of the device driver entry. For example, to specify the
Times-Roman font on a TITLE statement when you use the PS300 device driver, specify:
title font=’Times-Roman’ ’Testing the Times-Roman font’;

The SAS System allows up to 255 characters for the font name. The font name may
contain spaces. If the font name is longer than 40 characters, PROC GDEVICE in
fullscreen mode only displays the first 37 characters, followed by an ellipsis (...). To see
the complete font name when the name is longer than 40 characters, use PROC
GDEVICE with the NOFS (no fullscreen) option as follows:
proc gdevice c=sashelp.devices nofs;
list driver-name;
run;
quit;

When a font is quoted, the SAS System will first look at the Chartype window of the
device driver entry to see if it is a valid hardware font. If the font is not found in the
Chartype window, the SAS System will then check to see if the quoted font is a valid
SAS/GRAPH software font. If the font is not recognized as either a valid hardware font
or a valid SAS/GRAPH software font, the SIMPLEX font will be used.

Specifying Alternative Hardware Fonts


An alternative hardware font can be specified in any SAS statement where a font
specification is valid. You can use more than one hardware font in a single graph (or
even in a single statement), as long as all of the fonts that you specify exist on your
device. If you specify a hardware font, make sure that the font is available on the
device and that there is a corresponding Chartype value for the font. If you request a
hardware font that does not have a Chartype defined, SAS/GRAPH software
substitutes the SIMULATE font.
These are the three ways to specify alternative hardware fonts:
3 In the font specification, explicitly assign a hardware font using the following form:
HWxxxnnn
HW identifies the font as a hardware font. The font name
must begin with the characters HW.
SAS/GRAPH Fonts Specifying Special Characters 81

xxx are the last two or three characters of the module name in
the Module field in the Detail window of your device entry.
If the module name has eight characters (SASGDPSL, for
example), use the last three characters (PSL). If the
module name has only seven characters (SASGDVT, for
example), use the last two characters (VT).
nnn is the Chartype number of the hardware font that you
want to use as listed in the Chartype window in the
device entry. This value should be a three-digit decimal
number, with leading zeros if necessary.
3 In the font specification, explicitly assign a hardware font using the following form:
hardware-font-name
identifies the name of the hardware font that is listed in the Chartype
window of the device entry. Hardware-font-name must be enclosed in
quotation marks and the maximum length is 256 characters. The specified
font name will be converted internally to the HWxxxnnn name. Note that in
Annotate, the specified font name must be enclosed in both double quotes and
single quotes (see Chapter 25, “Annotate Dictionary,” on page 613 for details).
3 Assign one of the fonts listed in the Chartype window of your device entry as the
default hardware font with the CHARTYPE= graphics option. You can also change
the default hardware font by modifying the value of the Chartype field in the
Parameters window of your device entry. Then you can use FONT=NONE in your
SAS/GRAPH procedure or statement to specify the new default hardware font.
When you specify FONT=HWxxxnnn or hardware-font-name, the size of the
character cells is determined by the values in the Rows and Cols fields in the Chartype
window of the device entry, and the values of the HPOS= and VPOS= options are
ignored for the font. Consequently, the font retains its original proportions. In addition,
with this method the font catalog is checked for proportional spacing information. This
information is used by the software to determine how much space to reserve for
proportional text. See Chapter 8, “Graphics Options and Device Parameters
Dictionary,” on page 261 for additional information.

Specifying Special Characters


Some fonts contain characters that are not mapped to the keyboard and cannot be
typed directly into a text string. To display these special characters, substitute a
character code or a hexadecimal value in the text string.
Character codes include the letters, numbers, punctuation marks, and symbols that
are commonly found on a keyboard. They are usually associated with symbols or
national alphabets. These codes enable you to display the character by specifying the
font and using the keyboard character in the text string.
For example, to produce the character , assign the Greek font and specify the
character code z in the text string.
title font=greek ’z’;

Hexadecimal values are any two-digit hexadecimal numbers enclosed in quotation


marks and followed by the letter x, for example, ’3D’x. (In double-byte character sets,
the hexadecimal values contain four digits, for example, ’4E60’x.)
You display characters with hexadecimal values the same way that you display them
with character codes, that is, by specifying the font that contains the special character
and placing the hexadecimal value in the text string. For example, this TITLE
82 Using SAS/GRAPH Software Fonts Chapter 5

statement uses hexadecimal 18 to produce £ in the Zapf type style. (This example
assumes a U.S. key map).
title font=zapf ’18’x;

Note: The character code or hexadecimal value associated with any character in any
font is dependent on the key map that is currently being used. 4
In addition, you can use a key map to map selected characters to your keyboard. For
example, if you want to be able to type e directly, you could create a key map that maps
e to the key that usually generates the asterisk (*) and a device map that maps e to
your output device. Then, when you press the * key, although you see * on your display,
e is produced on your graphics device. See Chapter 34, “The GKEYMAP Procedure,” on
page 983 for details.

Using SAS/GRAPH Software Fonts

Rendering Fonts
The SAS/GRAPH software includes methods of storing rendered versions of
Bitstream fonts, along with three graphics options to control how the fonts are rendered.
When your graphics output uses one of the Bitstream fonts that are provided in the
SAS/GRAPH software, SAS/GRAPH must process information contained in
corresponding FONT catalog entries to determine how to draw characters of the
specified size and typeface. The process of calculating the character shapes and sizes is
known as rendering the font. Bitstream fonts that are available in the SAS/GRAPH
software include the Century, Swiss, and Zapf families.
The SAS/GRAPH software can store rendered versions of the Bitstream fonts in
memory or in special SAS files. Using these rendered versions of the fonts can provide
a speed improvement when characters of the same size and style are used again during
the SAS session. The SAS/GRAPH software can read the rendered version of the
characters from memory or from the rendered font file rather than having to perform
the rendering calculations again each time the characters are used. If you store the
rendered fonts in files in a permanent SAS data set, the SAS/GRAPH software can use
the rendered font files again in subsequent SAS sessions.
Note: Because the rendered font files use a special utility member type, they do not
appear in the list of library members that is displayed when you issue a DIRECTORY
command for the SAS data library in which the font files are stored. 4
You control whether and how rendered versions of fonts are stored using the
FONTRES=, RENDER=, and RENDERLIB= graphics options. See Chapter 8,
“Graphics Options and Device Parameters Dictionary,” on page 261 for details.

Font Lists
The fonts available with theSAS/GRAPH software are listed in the following tables.
All of the software fonts are stored in the catalog SASHELP.FONTS. For many fonts,
the last letter or letters of the font name indicates weight or spacing of the font:
B bold (thicker)
E empty (outline) versions of their counterparts
SAS/GRAPH Fonts Font Lists 83

I italic (slanted)
L light (thin)
U uniformly spaced versions of their counterparts; most of the
SAS/GRAPH fonts that do not end in U are proportionately spaced;
however, the Kanji fonts are always uniform.
X expanded (wider characters and extra space between characters).

CAUTION:
Empty and uniform versions of fonts cannot be used if you have deleted their filled or
proportionally spaced counterparts. 4
If the label of a font in SASHELP.FONTS is "Depends on," it is possible to delete it.
However, empty and uniform versions of fonts are generated from their regular, bold, or
italic counterparts. Therefore, if you delete any of these fonts, you cannot use the
uniform or empty version of that font. For example, you must have the CENTB
(Century Bold) font in order to use the CENTBE (Century Bold Empty) font.
84 Font Lists Chapter 5

Figure 5.1 Roman Alphabet Text Fonts


SAS/GRAPH Fonts Font Lists 85

Figure 5.2 Roman Alphabet Text Fonts–continued

Table 5.1 Non-Roman Alphabet Fonts

Uniform Font
Type Style Font Name Name
Arabic ARABIC

Arabic Empty ARABICE


Cyrillic CYRILLIC CYRILLIU

David DAVID
Davidb DAVIDB

Fsong FSONG FSONGU


Greek GREEK GREEKU

Greek (serif) CGREEK CGREEKU


Hebrew HEBREW

Hebrew NHEBREW*

Hebrewb HEBREWB
Hebrew Empty HEBREWE

Hei HEI HEIU


Hiragana HIRA

Hiragana NHIRA*
Kanji KANJI
86 Font Lists Chapter 5

Uniform Font
Type Style Font Name Name
Kanji KANSJIS

Kanji Subset
Kanji 1 KAN1

Kanji 2 KAN2
Kanji 3 KAN3

Kanji 4 KAN4
Kanji 5 KAN5

Kanji 6 KAN6
Kanji 7 KAN7

Kanji 8 KAN8

Katakana KATA
Katakana NKATA*

Mincho MINCHO MINCHOE


*This font requires a special keyboard and is
host-dependent. If you are not equipped to use this
font, use the host-independent version listed
directly above.

Table 5.2 Symbol Fonts

Font Uniform Font


Type Style Name Name

Cartographic CARTOG CARTOGU

Electronic ELECTRON ELECTROU


Marker MARKER

Marker MARKERE
Empty *

Math MATH MATHU


Music MUSIC MUSICU

Special SPECIAL SPECIALU


Weather WEATHER WEATHERU

*MARKERE is not displayed in the figures.


SAS/GRAPH Fonts Font Lists 87

Figure 5.3 Cartographic Font

Figure 5.4 Electronic Font

Note: Figure 5.5 on page 87 shows the MARKER font. The MARKERE font
produces the same symbols but in empty (outline) form. 4

Figure 5.5 Marker Font


88 Font Lists Chapter 5

Figure 5.6 Math Font

Figure 5.7 Music Font


SAS/GRAPH Fonts Font Lists 89

Figure 5.8 Special Font

Figure 5.9 Weather Font


90
91

CHAPTER

6
SAS/GRAPH Colors and Images

Using SAS/GRAPH Colors and Images 92


Specifying Colors in SAS/GRAPH Programs 92
Specifying Default Colors in a GOPTIONS Statement 92
Defining and Using a Colors List 93
Building a Colors List 93
Using a Device’s Default Colors List 94
Overriding the Default Colors List 94
Resetting the Colors List to the Default 94
Applying ODS Styles 94
Color-Naming Schemes 95
Selecting a Color-Naming Scheme 95
Hardware-Oriented Color-Naming Schemes Overview 95
RGB Color Codes 95
CMYK Color Codes 96
User-Oriented Color-Naming Schemes Overview 96
HLS Color Codes 97
HSV (or HSB) Color Codes 98
Gray-Scale Color Codes 99
SAS Color Names and RGB Values 99
CNS Color Names 99
Using the Color Utility Macros 100
Colors and Device Capabilities 103
Devices That Do Not Support User-defined Colors 103
Devices That Support User-defined Colors 104
Pen Plotters 104
Limitations 104
Specifying Images in SAS/GRAPH Programs 106
Image File Types Supported by SAS/GRAPH 106
Reading and Writing Image File Types 107
Including the FORMAT= attribute 108
Image Formats for Reading 108
Image Formats for Writing 110
Image File Types Supported Only on Certain Hosts 113
Placing a Background Image 113
Placing a Backplane Image on Graphs with Frames 115
Placing Images on the Bars of Two-Dimensional Bar Charts 116
Using Annotate to Display an Image 118
Using DSGI to Display an Image 119
Disabling and Enabling Image Output 120
92 Using SAS/GRAPH Colors and Images Chapter 6

Using SAS/GRAPH Colors and Images


SAS/GRAPH software lets you set colors or apply images to your graphics output, as
described in “Specifying Colors in SAS/GRAPH Programs” on page 92 and in
“Specifying Images in SAS/GRAPH Programs” on page 106.

Specifying Colors in SAS/GRAPH Programs


SAS/GRAPH software lets you set color
3 in any procedure that generates graphics output (refer to the chapter for the
individual procedure).
3 in global statements that enhance procedure output: AXIS, FOOTNOTE,
LEGEND, NOTE, PATTERN, SYMBOL, and TITLE (see Chapter 7, “SAS/GRAPH
Statements,” on page 121).
3 in the options on the GOPTIONS statement that defines default colors for graphics
elements (see “Specifying Default Colors in a GOPTIONS Statement” on page 92).
3 in the COLORS= option of the GOPTIONS statement to define a colors list (see
“Defining and Using a Colors List” on page 93).
3 in the colors list of the current device driver. (See “Colors and Device Capabilities”
on page 103 for general information about device capabilities. See Example 1 on
page 936 for information on how you can view or modify a device’s color list.)
These specifications, alone or in combination, give SAS/GRAPH software the colors it
needs to generate graphics output. Colors can be specified using color names, such as
RED, or color codes, such as CXFF0000. Color names must not exceed 64 characters.
Color codes must not exceed eight characters. All color values must be in a valid SAS
color-naming scheme (see “Color-Naming Schemes” on page 95).
Color specifications are searched for in the following order:

1 colors specified in the procedure itself


2 colors specified in global statements
3 color options in GOPTIONS
4 the COLORS list in the GOPTIONS statement
5 the color list in the current device driver.
SAS/GRAPH will search the color specifications in the order outlined above until a
valid color is found. If no valid colors are specified, the color will be retrieved from the
color list of the current device driver.

Specifying Default Colors in a GOPTIONS Statement


The GOPTIONS statement has several graphics options that specify default colors
for graphics elements:

Option Sets default color for


CBACK= background for graphics output

CBY= BY lines in graphics output


CPATTERN= PATTERN statements
SAS/GRAPH Colors and Images Defining and Using a Colors List 93

Option Sets default color for

CSYMBOL= SYMBOL statements


CTEXT= all text and the border in graphics output

CTITLE= border, plus all titles, footnotes, and notes

SAS/GRAPH software uses these values if you do not explicitly select colors in other
statements. Refer to Chapter 8, “Graphics Options and Device Parameters Dictionary,”
on page 261 for complete information about each of these graphics options.
If you have not explicitly specified a color in a SAS statement or set a default color
for a graphic element in the graphics output, SAS/GRAPH software searches for a
colors list.

Defining and Using a Colors List


If SAS/GRAPH software does not find a color specification on a procedure or global
statement, and a default color for the graphic element is not specified in the
GOPTIONS statement, then SAS/GRAPH uses colors from the following colors list:
1 the COLORS= option on a GOPTIONS statement
2 the color list of the current device driver. (Use the GTESTIT procedureExample 2
on page 1292 to view the color list for a device driver.)

The color selected from the colors list varies depending on the procedure using the
color and the graphics element that is being drawn. Usually, the first color in the list is
used; however, certain procedures may select other colors. For example, if the CAXIS=
option is not specified in the GCONTOUR procedure’s PLOT statement, the procedure
selects the second color from the colors list to draw the axes. See the documentation for
an individual procedure for more information.

Building a Colors List


To build a colors list, use the COLORS= option on the GOPTIONS statement. This
specified colors list overrides the colors list of the current device driver. Building a
colors list is useful for selecting a subset of colors to be used in a specific order for
graphics output. For example, to ensure that the colors red, green, and blue are
available in that order, you can specify:
goptions colors=(red green blue);

Each value you specify in a color list must be either a valid color name or a valid color
code. Color names must not exceed 64 characters and color codes must not exceed eight
characters. For an explanation of SAS color names and codes, see “Color-Naming
Schemes” on page 95.
SAS provides, in the SAS Registry, a set of ordinary-language color names that you
can use for colors that are common to most Web browsers. For a list of these names,
showing both the ordinary-language name and its associated RGB value, you can run
the following code and view the output in the Log window:
proc registry list
startat=’COLORNAMES’;
run;
94 Defining and Using a Colors List Chapter 6

You can also modify entries in this list and add your own names and their associated
RGB values. For more information on viewing and modifying the list of color names,
see Using the SAS Registry to Control Color in SAS Language Reference: Concepts.
Note: The COLORS= graphics option only provides a default lookup table. Any time
you explicitly select any other colors in your SAS/GRAPH program, those colors are
used to draw the graphics elements for which you have specified them. 4
For a pen plotter, SAS/GRAPH software uses the order of the colors in the COLORS=
graphics option to define the order of pens for a multiple pen plotter, or to make a pen
plotter prompt you to change the pen when a graph uses more colors than the plotter
has loaded.

Using a Device’s Default Colors List


If you do not define a colors list with the COLORS= graphics option, then
SAS/GRAPH software uses the colors list from the current device driver. This colors list
is found in the device entry of the specified device driver (for details on specifying a
device driver, refer to Chapter 36, “The GOPTIONS Procedure,” on page 1075). The
colors list will change if you select a different device driver during a SAS session and
have not specified the COLORS= graphics option.
To view and modify the device’s default colors list, use the GDEVICE procedure (for
details, refer to Chapter 31, “The GDEVICE Procedure,” on page 915).

Overriding the Default Colors List


If you do not specify colors for certain graphics elements or do not specify a colors list
with the COLORS= graphics option, then the SAS/GRAPH procedures assign colors
from the colors list of the current device driver. In some procedures, this assignment
takes up some of the 256 colors that you can specify for a graph. For example, if no
colors are specified, the G3D procedure uses the first three colors from the colors list to
draw the text, the plot axes, and the plot symbols. These colors take up three of the 256
colors that you can specify for the graph. Therefore, you can specify 253 additional
colors for your graph before a warning is issued and the colors are remapped.
To use only the colors that you explicitly specify in your SAS program, submit
goptions colors=(none);

The colors from any elements that have a color explicitly specified in your SAS
program are combined to form a color list. This color list is used to assign colors to the
elements that do not have a color explicitly specified. If no colors are explicitly specified,
black will be used. This setting is useful if you want to generate graphics output with
the maximum of 256 colors, and you do not want to use any of the default colors from
the current device driver.

Resetting the Colors List to the Default


If you have specified a colors list with the COLORS= graphics option and you want to
reset it back to the default colors list for the current device driver, then specify
goptions colors=();

Applying ODS Styles


If you are using ActiveX or Java device drivers to produce your graphic output, then
you can specify Output Delivery System (ODS) styles to be used for your output’s colors.
The ODS styles contain predefined color schemes that can be used to create
SAS/GRAPH Colors and Images Color-Naming Schemes 95

professionally styled graphic output. The ODS styles are available for both bar graphs
and pie charts. For more information on ODS Styles see “Using ODS Styles” on page
488 and SAS Output Delivery System: User’s Guide.

Color-Naming Schemes
The valid color-naming schemes are
3 RGB (red green blue)
3 CMYK (cyan magenta yellow black)
3 HLS (hue lightness saturation)
3 HSV (hue saturation brightness), also called HSB
3 gray scale
3 SAS color names (from the SAS Registry)
3 the SAS Color Naming System (CNS).
For the CMYK color scheme, color specifications must be enclosed in quotation
marks. For the SAS color names and CNS names, quotation marks are required if the
color name contains spaces. In all other instances, quotation marks are optional.
You can freely intermix colors using different color-naming schemes in your
programs. However, depending on your device capabilities, the color that is displayed
may not be the color that you expect. See “Colors and Device Capabilities” on page 103
for information on how to tell if your device supports user-defined colors.

Selecting a Color-Naming Scheme


Each of the color-naming schemes supported by SAS/GRAPH offer their own set of
advantages and disadvantages based on how the color-naming scheme and desired color
will be implemented. RGB and CMYK are older hardware-oriented color-naming
schemes. Creating specific RGB or CMYK colors may be less intuitive than creating
colors using the user-oriented color-naming schemes: HLS, HSV, gray scale, SAS named
colors, or CNS colors. For both hardware-oriented and user-oriented color-naming
schemes, the color utility macros allow you to create colors for a specific color-naming
scheme and convert color values between color-naming schemes (see “Using the Color
Utility Macros” on page 100 for more information).

Hardware-Oriented Color-Naming Schemes Overview


The RGB color-naming scheme is usually used to define colors for a display screen.
This color-naming scheme is based on the properties of light. With this color system, a
color is defined by its red, green, and blue components. Individual amounts of each
color are added together to create the desired result. All the colors combined together
create white and the absence of all color is black.
CMYK is a special color-naming scheme used in four-color printing. Whereas the
RGB scheme is based upon the principles of light, the CMYK scheme is based upon the
principles of objects reflecting light. Cyan, magenta, and yellow absorb red, green, and
blue light, respectively. When cyan is set at maximum, for example, all the red light is
absorbed. Combining equal values of cyan, magenta, and yellow produces black, but
this color may appear brown when printed. Therefore, the black component (K) of
CMYK may be used to specify the level of blackness in the output. A lack of all colors
produces white when the output is printed on white paper.

RGB Color Codes


You can use the RGB color-naming scheme to specify a color in terms of its red,
green, and blue components. Color names are of the form CXrrggbb, where
96 Color-Naming Schemes Chapter 6

3 CX indicates that this is an RGB color specification


3 rr is the red component
3 gg is the green component
3 bb is the blue component.
The components are given as hexadecimal numbers in the range 00 through FF (0%
to 100%), where lower values are darker and higher values are brighter. This allows for
up to 256 levels of each color component (over 16 million different colors). For example,
bright red is specified as CXFF0000, white as CXFFFFFF, black as CX000000, and
green as CX00FF00.
Any combination of the color components is valid. Some combinations will match the
color produced by predefined SAS color names. See SAS Language Reference: Concepts
for information on viewing the RGB combinations that match predefined SAS color
names.

Note: When printed, RGB color values are automatically converted to the CMYK
color values so that the colors display appropriately in the output. 4

CMYK Color Codes


To specify the colors from a printer’s Pantone Color Look-Up Table, you can use the
CMYK color-naming scheme to specify colors in terms of their cyan, magenta, yellow,
and black components. Color names are of the form ’ccmmyykk’, where
3 cc is the cyan component
3 mm is the magenta component
3 yy is the yellow component
3 kk is the black component.
The components are given as quoted hexadecimal numbers in the range 00 through
FF, where higher values are darker and lower values are brighter. This scheme allows
for up to 256 levels of each color component. For example, red is specified as
’00FFFF00’, green as ’FF00FF00’, process black (using cyan, magenta, and yellow ink)
as ’FFFFFF00’, and pure black (using only black ink) as ’000000FF’. For CMYK color
specifications, the quotes are required.
CMYK color specifications should only be used for devices that support four colors. If
a CMYK color is used on a three-color device, the color specification will be mapped to a
color that the device supports, but the resulting colors may not be appealing. Moreover,
different CMYK colors may map to the same device color because a four-color space
supports more colors than a three-color space.

Note: You can specify a CMY value by making the kk, the color’s black component,
zero (00). 4

User-Oriented Color-Naming Schemes Overview


The HLS color-naming scheme follows the Tektronix Color Standard illustrated in
Figure 6.1 on page 98. To make the HLS color model consistent with the HSV
coordinate system, Tektronix places blue at zero degrees. With the HLS color
naming-scheme you specify the hue, lightness, and saturation levels.
With the HSV color-naming scheme, you specify the hue, saturation, and value
(brightness) levels.
The gray scale color-naming scheme allows you to specify the lightness or darkness of
gray using the word GRAY and a lightness value.
SAS/GRAPH Colors and Images Color-Naming Schemes 97

A predefined list of the SAS color names and their accompanying RGB values are
contained in the SAS Registry Editor. The SAS Registry Editor also allows you to add
your own SAS color names. With these colors, you can specify the name itself or the
RGB value associated with that color name.
With CNS, you develop your color value by selecting and combining valid lightness,
saturation, and hue terms. The CNS colors are based on the HLS color model and will
display fairly uniform transitions between color values.
Note: Invalid color values will be replaced by the next valid color value on the
foreground color list. Messages are written to the SAS log detailing the colors
substituted for invalid color values. 4

HLS Color Codes


You can use the HLS color-naming scheme to specify colors in terms of hue,
lightness, and saturation components. SAS/GRAPH software uses an HLS color scheme
that is modeled directly after the Tektronix Color Standard illustrated in Figure 6.1 on
page 98. HLS color names are of the form Hhhhllss, where
3 H indicates that this is an HLS color specification
3 hhh is the hue component
3 ll is the lightness component
3 ss is the saturation component.
The components are given as hexadecimal numbers. The hue component has the
range of 000 through 168 hexadecimal (168 hexadecimal is equivalent to 360 decimal).
Both the lightness and saturation components are hexadecimal and scaled to a range of
0 to 255 expressed with values of 00 through FF (0% to 100%). Thus, they provide 256
levels for each component. For example, blue is specified as H00080FF and light gray
as H000BB00. When the saturation is set to 00, the color is a shade of gray that is
determined by the lightness value. Therefore, white is defined as HxxxFF00 and black
as Hxxx0000, where xxx can be any hue.
98 Color-Naming Schemes Chapter 6

Figure 6.1 Tektronix Color Standard

HSV (or HSB) Color Codes


You can use the HSV color-naming scheme to specify colors in terms of hue,
saturation, and value (or brightness) components. HSV color names are of the form
Vhhhssvv, where
3 V indicates that this is an HSV color specification
3 hhh is the hue component
3 ss is the saturation component
3 vv is the value or brightness component.
The components are given as hexadecimal numbers. The hue component has the
range of 000 through 168 hexadecimal (168 hexadecimal is equivalent to 360 decimal).
Both the saturation and value (brightness) components are hexadecimal and scaled to a
range of 0 to 255 expressed with values of 00 through FF (when the saturation is set to
00, the color is a shade of gray determined by the value). Thus, they provide 256 levels
for each component.
For example, blue is specified as V0F0FFFF, light gray as Vxxx00BB, and white as
Vxxx00FF, where xxx can be any hue. For white and black, the value component
determines the intensity of gray level.
SAS/GRAPH Colors and Images Color-Naming Schemes 99

Gray-Scale Color Codes


Gray-scale color names are of the form GRAYll. The value ll is the lightness of the
gray and is given as a hexadecimal number in the range 00 through FF. This scheme
allows for 256 levels on the gray scale. For example, GRAYFF is white, GRAY00 is
black, and GRAY4C is a dark gray.

SAS Color Names and RGB Values


The SAS Registry Editor contains valid color names and RGB values. The predefined
color names and RGB values in the SAS Registry are common to most web browsers. In
addition to viewing predefined SAS color names and RGB values, the SAS Registry
Editor also allows you to create and define your own color names and RGB values. See
SAS Language Reference: Concepts for more information.
Note: Hardware characteristics may cause some colors with different color
definitions to appear the same. Also, the same predefined color is likely to appear
different on different devices and may not appear correctly on some devices. 4

CNS Color Names


You can specify a CNS color value’s lightness, saturation, and hue using the following
terms:

Table 6.1

Lightness Saturation Hue

Black Gray Blue


Very Dark Grayish Purple

Dark Moderate Red


Medium Strong Orange/Brown

Light Vivid Yellow


Very Light Green

White

CNS values should be written in the following order: lightness saturation hue. The
color names may written without space separators between words, with an underscore
to separate words, or with a space to separate words. The following list contains
examples of valid color names:

verylightmoderatepurplishblue
very_light_moderate_purplish_blue
“very light moderate purplish blue”
Color names containing spaces must be enclosed in quotation marks.

Note: The %CNS macro only accepts CNS color names where a space is used to
separate the words in the color name. See Table 6.5 on page 101 for more information 4
If a CNS color name is also a color name in the SAS Registry, the SAS Registry color
value will be used. Some CNS color names and color names in the SAS Registry have
100 Color-Naming Schemes Chapter 6

different color values. To use a CNS color value when the color name is also in the SAS
Registry, place quotes around the color name.
The lightness values black and white should not be used with saturation or hue
values. If not specified, medium is the default lightness value and vivid is the default
saturation value. Gray is the only saturation value that can be used without a hue.
Unless the CNS value is black, white, or some form of gray, at least one hue value must
be used.
One or two hue values can be used in the CNS color name. When using two hue
values, the hues must be adjacent to form a color. The hues are located in the following
circular order: blue, purple, red, orange/brown, yellow, green, and then returning to
blue. When two hues are used, the resulting color is a combination of both colors. Use
the suffix “ish” to reduce the effect of a hue when two hues are combined. For example,
reddish purple is less red than red purple. If you are using a color with an “ish” suffix,
this color must precede the color without the “ish” suffix.

Using the Color Utility Macros


The %COLORMAC macro contains several subcomponent macros that can be used to
construct and convert color values for the different color-naming schemes supported by
SAS. The %HELPCLR macro provides information about the %COLORMAC
subcomponent macros. The following table shows information that will appear in your
SAS log when you call the %HELPCLR macro from the comand-line:

Table 6.2 Using the %HELPCLR macro

Use... To...
%HELPCLR; List the color utility macro names.

%HELPCLR(ALL); Display the short descriptions and examples for


each of the color utility macros.

%HELPCLR(macroname); Obtain a short description and an example of a


specific color utilities macro. Replace
macroname with the name of the color utility
macro you are interested in.

When the color utility macros are invoked, the calculated color value can be directed
to the SAS log or perform in-place substitutions in the code. The following tables list
and describe the color utility macros and provide an usage example of each macro:

Table 6.3 %CMY(cyan, magenta, yellow);

Description Usage Example


Replace cyan, magenta, yellow with numeric values to Entering the following code into your
create a RGB color value. The numeric values that are Program Editor:
used in place of cyan, magenta, yellow indicate the %COLORMAC;
percentage (0 to 100) of each of these colors to be included data _null;
in the RGB value. put ‘‘%CMY(100,0,100)’’;
run;
Returns the RGB value CX00FF00
which is green.
SAS/GRAPH Colors and Images Color-Naming Schemes 101

Table 6.4 %CMYK(cyan, magenta, yellow, black);

Description Usage Example

Replace cyan, magenta, yellow, black with numeric values Entering the following code into your
to create a CMYK color value. The numeric values that are Program Editor:
used in place of cyan, magenta, yellow, black indicate the %COLORMAC;
percentage (0 to 100) of each of these colors to be included data _null_;
in the CMYK color value. See “CMYK Color Codes” on put %CMYK(0,46,16,31);
run;
page 96 for more information on the color value produced
by using this macro. Returns the CMYK value 0075294F
which is purple.

Note: In the PUT statement, %CMYK(cyan, magenta, yellow, black), should not be
placed in quotations. 4

Table 6.5 %CNS(colorname);

Description Usage Example


Replace colorname with a color-naming scheme color name Entering the following code into your
to create a HLS color value. See “HLS Color Codes” on Program Editor:
page 97 for more information on HLS color values. For %COLORMAC;
more information on valid color-naming scheme color data _null_;
names see “CNS Color Names” on page 99 or enter the put ‘‘%CNS(GRAYISH REDDISH PURPLE)’’;
run;
following into the command-line of the Program Editor:
%HELPCLR(CNS); Returns the HLS value H04B8040
which is grayish reddish purple.

Table 6.6 %HLS(hue, lightness, saturation);

Description Usage Example

Replace hue, lightness, saturation with numeric values to Entering the following code into your
create a HLS color value. Hue should be replaced with any Program Editor:
value from 0 to 360. Lightness and saturation indicate a %COLORMAC;
percentage (0 to 100) to be included in the HLS color value. data _null_;
See “HLS Color Codes” on page 97 for more information. put ‘‘%HLS(0,50,100)’’;
run;
Returns the HLS value H00080FF
which is blue.
102 Color-Naming Schemes Chapter 6

Table 6.7 %HSV(hue, saturation, value);

Description Usage Example

Replace hue, saturation, value with numeric values to Entering the following code into your
create a HLS value from HSV components. Hue should be Program Editor:
replaced with any value from 0 to 360. Saturation and %COLORMAC;
value (brightness) indicate a percentage (0 to 100) to be data _null_;
included in the HLS color value. See “HSV (or HSB) Color put ‘‘%HSV(0,100,75)’’;
run;
Codes” on page 98 and “HLS Color Codes” on page 97 for
more information. Returns the HSV value V000FFBF
which is dark red.

Table 6.8 %RGB(red, green, blue);

Description Usage Example


Replace red, green, blue with numeric values to create a Entering the following code into your
RGB color value from RGB color components. The numeric Program Editor:
values that are used in place of red, green, blue indicate the %COLORMAC;
percentage (0 to 100) of each of these colors to be included data _null_;
in the RGB color value. See “RGB Color Codes” on page 95 put ‘‘%RGB(100,100,0)’’;
run;
for more information.
Returns the RGB value CXFFFF00
which is yellow.

Table 6.9 %HLS2RGB(hls);

Description Usage Example

Replace hls with a HLS color value to create a RGB color Entering the following code into your
value. See “HLS Color Codes” on page 97 and “RGB Color Program Editor:
Codes” on page 95 for more information. %COLORMAC;
data _null_;
put ‘‘%HLS2RGB(H04B8040)’’;
run;
Returns the RGB value CX9F5F8F
which is grayish reddish purple.
SAS/GRAPH Colors and Images Colors and Device Capabilities 103

Table 6.10 %RGB2HLS(rgb);

Description Usage Example


Replace rgb with a RGB color value to create a HLS color Entering the following code into your
value. See “RGB Color Codes” on page 95 and “HLS Color Program Editor:
Codes” on page 97 for more information. %COLORMAC;
data _null_;
put ‘‘%RGB2HLS(CX9F5F8F)’’;
run;
Returns the HLS value H04C7F40
which is grayish reddish purple.

Note: Round-trip conversions using HLS2RGB and then RGB2HLS macros or vice
versa, may produce ultimate output values that differ from the initial input values. For
example, converting CXABCDEF (a light blue) using %RGB2HLS (CXABCDEF)
produces H14ACDAD. Converting this value back to RGB using %HLS2RGB
(H14ACDAD) returns CXAACCEE. While not identical, the three colors are very
similar on the display and when printed. 4
For additional information on color-naming schemes, see Effective Color Displays:
Theory and Practice by David Travis and Computer Graphics: Principles and Practice
by Foley, van Dam, Feiner, and Hughes.

Colors and Device Capabilities


Your graphics output device determines the colors that you can use. SAS/GRAPH
software translates the color that you specify to the color definition system on your
device. It then checks to see if the color is available. If the color is not available,
SAS/GRAPH software produces a message in the Log and remaps the color either to a
color that closely matches the color you specified or to the next available color in the
colors list. The remapping behavior depends on the capabilities of your device.
Graphics devices can be grouped into the following categories:
3 devices that do not support user-defined colors
3 devices that support user-defined colors
3 pen plotters.
You can determine whether your device supports user-defined colors in two ways:
3 Check the documentation for your graphics device.
3 Run the GTESTIT procedure and display picture 1. The OPTS= string indicates if
the device supports user-defined colors. If the second digit of the OPTS= string is
an odd integer or d, b, or f, then the driver supports user-defined colors.

Devices That Do Not Support User-defined Colors


Devices that do not support user-defined colors are those that come with predefined
nonalterable color palettes. These devices have a palette of between 1 and 256
predefined colors, but the actual number of colors that can be displayed at one time
may be less than that.
When using devices that do not support user-defined colors, you can specify colors
using any color-naming scheme; however, any unsupported colors that you specify in
RGB, HLS, or gray-scale format are remapped to colors in your device’s default colors
104 Colors and Device Capabilities Chapter 6

list. Some devices try to match the user-defined color with the closest color in the
device’s color palette. Others merely remap the color to the next available color in the
device’s color palette. To avoid having colors remapped, use the colors in your device’s
default colors list.

Devices That Support User-defined Colors


Devices that support user-defined colors are graphics devices that allow you to
configure the colors from the device’s color palette. A device in this category may have a
palette of over 16 million colors, but it may only be able to display a subset of colors
from the color palette at any one time.
On a device that supports user-defined colors, you can use any color-naming scheme
to specify colors. If you specify a color that your device does not support, SAS/GRAPH
software remaps the color to an available color that is the closest match.

Pen Plotters
The colors you can use with a pen plotter are determined by your set of pens. You
specify the color names in the GOPTIONS statement’s COLORS= option, then place
pens with those color names in the plotter when the following message appears (the
message does not appear if you specify the NOPROMPT graphics option):
Please mount the following pens: . . .

By default, SAS/GRAPH software tries to keep a standard set of pens in the plotter’s
carousel. If colors in the standard set of pens are named in the COLORS= graphics
option, a mount request is issued for the entire standard set, even if all of them are not
used in the output. This minimizes the number of times pens must be reshuffled as a
graph is being drawn. If GOPTIONS COLORS=(NONE) is used, you are only prompted
to mount pens for the colors that are actually used in the output.
Note: You can specify any valid SAS name for a color when using a pen plotter. It
does not have to be a predefined or user-defined color name. For example, you can
specify COLOR=PEN3, and you will be prompted to mount PEN3 or SAS/GRAPH
software will assume a pen of that color is in the appropriate slot. This feature is often
helpful if you are using transparency pens or other special pens. 4

Limitations
Using colors in SAS/GRAPH software is limited by the number of colors that you can
use in one graph and by the capabilities of your device. The following sections discuss
these limitations.
Maximum Number of Colors Displayable in SAS/GRAPH Software
You can use a maximum of 256 unique colors on each graph, including the
background color (specified with the CBACK= graphics option or the CBACK device
parameter). If you use more than 256 unique names in a program, SAS/GRAPH
software issues a warning and remaps the 257th and any subsequent colors to
existing color names, beginning with the first color name in the existing color list.
Note: If you specify a color using two different color-naming schemes for the
same graph (for example, WHITE and RGB white, CXFFFFFF), SAS/GRAPH
software counts them as two color specifications out of the 256 colors that you are
allowed to use on one graph. 4
Maximum Number of Colors Displayable on a Device
The number of colors that you can display is limited by the type of graphics output
device that you have. If you generate a graph with more colors than the device can
SAS/GRAPH Colors and Images Colors and Device Capabilities 105

display, the colors that cannot be displayed are mapped to an existing color. You
may also receive a note in the SAS log telling you when a color is mapped to
another color in the colors list and what color will be used instead.
Although your device may support 256 colors, it may not let you use all of them
at once. The MAXCOLORS device parameter tells SAS/GRAPH software the
maximum number of colors that can be displayed at one time. MAXCOLORS is
the number of foreground colors plus the background color and has a range of two
to 256. If you use more than the number of colors set by the MAXCOLORS device
parameter, the excess colors are remapped.
Note: The MAXCOLORS device parameter defaults to the number of
displayable colors on the basic model of each graphics device supported. If your
graphics device can display more colors than the base model, use the
PENMOUNTS= graphics option to specify the number of colors that can be
displayed. Optionally, you can use PROC GDEVICE to modify the value of the
MAXCOLORS device parameter. 4
For pen plotters, you use the PENMOUNTS= graphics option to indicate the
number of pen holders on the plotter. PENMOUNTS is the number of foreground
colors and has a range of one to 255. PENMOUNTS does not include the
background color. Using this graphics option does not limit the number of colors
that you can specify for a graph that is produced on a pen plotter. If you use more
colors than the plotter has pen holders, you will be prompted to change pens
unless you have also specified the NOPROMPT graphics option.
Replaying Graphs on a Device That Displays Fewer Colors
You can use the GREPLAY Procedure to display graphs previously generated.
Sometimes you may need to replay the graphs on a device that cannot display as
many colors as the device on which the graph was originally developed. Use
“CMAP” on page 270 to control some of the remapping.
When you replay graphs on devices that display fewer colors than are in the
graph, two situations may cause problems:
3 Colors are specified that the device does not support.
3 More colors are specified than the device can display at one time.
If you specify colors on a device that does not support those colors, the colors are
remapped to those available for that device. You may also receive a note in the
SAS log telling you when a color is mapped to another color in the colors list and
what the new color is.
The number of colors that your device can display affects the actual color
displayed. If your graphics output device can generate a maximum of 64 distinct
colors and your graph contains 256 colors, the 65th through the 256th color
specifications are remapped to the device’s available colors and may not display as
the color you specify.
You can use the TARGETDEVICE= graphics option to preview the way a graph
is going to look on a different device. You set this graphics option to the device
entry name of the device driver that will be used later. The graph is displayed as
close as possible to the way it will display when the other device is used.
Note: When you use the TARGETDEVICE= graphics option, SAS/GRAPH
software uses the colors list of the target device as the default colors list; any color
that you explicitly use is displayed when you preview the graph, although the
target device may cause the color to be mapped. Refer to “TARGETDEVICE” on
page 355 for complete information about the TARGETDEVICE= graphics option. 4
Trueness of Color Displayed on a Device
The size of the color palette in your device determines the trueness of the color
that is actually produced. For example, a device with a palette of 64 colors can
106 Specifying Images in SAS/GRAPH Programs Chapter 6

only produce colors that contain a combination of four shades of red (including no
red), four shades of green (including no green), and four shades of blue (including
no blue). Consequently, ranges of color will be remapped to available colors. For
example, color specifications CX008080, CX258080, and CX3F8080 will all look the
same (no red). CX408080 through CX7F8080 will look redder; CX808080 through
CXBF0000, redder still; and CXC08080 through CXFF8080, the reddest. Larger
palettes have more color resolution but may not have more simultaneous colors.

Specifying Images in SAS/GRAPH Programs


SAS/GRAPH software enables you to display images as part of your graph. You can
place an image in the background area of a graph, in the backplane of graphs that
support frames, or on the bars of two-dimensional bar charts. You can also apply
images at specified graph-coordinate positions using the Annotate facility or the DATA
Step Graphics Interface (DSGI).
The images you add to your graphs can be SAS files or external files in a wide range
of image formats. If you wish to withold images from your graphics output, you can
specify the NOIMAGEPRINT graphics option.

Image File Types Supported by SAS/GRAPH


For displaying images in your graphs, SAS/GRAPH software supports the following
image file types:

File Type Description


BMP (Microsoft Windows Device Independent supports color-mapped and true color images
Bitmap) stored as uncompressed or run-length encoded.
BMP was developed by Microsoft Corporation for
storing images under Windows 3.0.

CAT (SAS Catalog IMAGE entry) supports color-mapped images as well as true
color images. The images can be optionally
compressed.
DIB (Microsoft Windows Device Independent see the description of BMP.
Bitmap)

EMF (Microsoft NT Enhanced Metafile) supported under Windows 95, Windows 98,
Windows 2000, and Windows NT.

GIF (Graphics Interchange Format) supports only color-mapped images. GIF is


owned by CompuServe, Inc.

JPEG (Joint Photographic Experts Group) supports compression of images with the use of
JPEG File Interchange Format (JFIF) software.
JFIF software is developed by the Independent
Joint Photographic Experts Group.
PBM (Portable Bitmap Utilities) supports gray, color, RGB, and bitmap files. The
Portable Bitmap Utilities is a set of free utility
programs that were primarily developed by Jeff
Poskanzer.
SAS/GRAPH Colors and Images Reading and Writing Image File Types 107

File Type Description

PCD (Photo CD) Kodak Photo CD format which supports


multiple image resolutions.

PCL (Printer Control Language) developed by HP.


PCX (PC Paintbrush) supports bitmap, color-map, and true color
images. PCX and PC Paintbrush are owned by
Zsoft Corporation.
PNG (Portable Network Graphic) supports truecolor, 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.
TGA (Targa) supports both true color images and
color-mapped images; however, the current
release of the Image classes supports only true
color TGA files. Targa is owned by Truevision,
Inc.
TIFF (Tagged Image File Format) internally supports a number of compression
types and image types, including bitmap,
color-map, gray-scale, and true color. TIFF was
developed by Aldus Corporation and Microsoft
Corporation and is used by a wide variety of
applications.

WMF (Microsoft Windows Metafile) supported only under Microsoft Windows


operating systems.

XBM (X Window Bitmaps) supports bitmap images only. XBM is owned by


MIT X Consortium.
XPM (X Window Pixmap) is an extended version of XBM that supports
color bitmaps.
XWD (X Window Dump) supports all X visual types (bitmap, color-map,
and true color.) XWD is owned by MIT X
Consortium.

Reading and Writing Image File Types


The image file types supported by SAS/GRAPH may be supported for reading or
writing. In addition, all SAS/GRAPH supported file types can be printed. The printed
output’s appearance is dependent on the driver that is selected. See “Image Formats for
Reading” on page 108 and “Image Formats for Writing” on page 110 for more
information on specific file type capabilities and attributes.
When you are reading some images, the FORMAT= attribute is required. See
“Including the FORMAT= attribute” on page 108 for more information. Some of the file
types that require the FORMAT= attribute are only supported by certain hosts. “Image
File Types Supported Only on Certain Hosts” on page 113 contains information on these
file types, the reader and writer attributes, and the host support.
If you are using SAS/GRAPH on the z/OS platform, you must be running the UNIX
System Services Hierarchical File System (HFS) to read and write image files.
108 Reading and Writing Image File Types Chapter 6

Including the FORMAT= attribute


When you are reading images, include the FORMAT= attribute if
3 you are reading a format supported only on certain hosts. See “Image File Types
Supported Only on Certain Hosts” on page 113 for more information.
3 images reside in SAS catalogs.
3 images are read from a system pipe.
FORMAT= is not required in other cases, but it is always more efficient to specify it.

Image Formats for Reading


The following table describes the attributes for the image readers that are supported
by SAS/GRAPH:

File Type Reader Attributes Comment

BMP FORMAT=BMP
COMPRESS=NONE is the default. Sets compression to
COMPRESS=RLE run-length encoded.

CAT FORMAT=CAT

DIB FORMAT=DIB is supported only by Windows NT, Window


2000, and Windows XP.

EMF FORMAT=EMF is supported only by Windows NT, Window


2000, and Windows XP.
GIF FORMAT=GIF

JFIF FORMAT=JFIF required for reading JPEG files that use


JPEG File Interchange Format (JFIF).

DCT=mode selects specific type of Discrete Cosine


Transform (DCT) to use when processing
the image; mode can be
3 INT — an integer DCT
3 FAST — a faster and less accurate
integer DCT
3 FLOAT — a slightly more accurate
method that can be slower unless the
host has very fast floating point
hardware.

GRAYSCALE produces a gray-scale image even if the


JPEG file is in color. This is useful for
viewing on monochrome displays. The
reader runs noticeably faster in this mode.

VERSION prints the version number and copyright


messages for the Independent JPE Group’s
JFIF software to the log.

FAST enables certain recommended processing


options for fast, low quality output;
equivalent to enabling ONEPASS,
DITHER=ORDERED, COLORS=216,
NOSMOOTH, and DCT=FAST.
SAS/GRAPH Colors and Images Reading and Writing Image File Types 109

File Type Reader Attributes Comment

NOSMOOTH uses a faster, lower quality, upsampling


routine.

ONEPASS uses a one-pass color quantization instead


of the standard two-pass quantization. The
one-pass method is faster and needs less
memory, but it produces a lower-quality
image. This attribute is ignored unless you
also specify the COLORS attribute.
ONEPASS is always enabled for gray-scale
output.

COLORS=n reduces the number of colors in the image


to at most n colors; n must be in the range
2...256.

SCALE_RATIO=n scales the output image by a factor of 1/n.


Currently the scale factor must be 1/1, 1/2,
1/4, or 1/8. This is useful when processing a
large image and only a smaller version is
needed, as the reader is much faster when
scaling down the output.
DITHER=mode selects the specific type of dithering to use
color quantization; mode can be
3 FS — Floyd-Steinberg dithering
3 ORDERED — ordered dithering
3 NONE — no dithering.

PBM FORMAT=PBM
PCD FORMAT=PCD specifies photo CD format. FORMAT=PCD
RES= specifies the image resolution to be
read. Photo CD images have multiple
resolution images in each image. Values
are:

BASE/64 64x96

BASE/16 128x192

BASE/4 256x384

BASE 512x768 (default)

4BASE 1024x1536

16BASE 2048x3072.

PCX FORMAT=PCX is not supported for writing.


PNG FORMAT=PNG

TGA FORMAT=TGA

TIFF FORMAT=TIFF
XBM FORMAT=XBM
110 Reading and Writing Image File Types Chapter 6

File Type Reader Attributes Comment

XPM FORMAT=XPM is supported only under the X Windows


System under UNIX.

XWD FORMAT=XWD

Image Formats for Writing


The following table describes the attributes for the image writers that are supported
by SAS/GRAPH:

File Type Writer Attributes Comment

BMP FORMAT=BMP
CAT FORMAT=CAT

COMPRESS=G3FAX sets compression to FAX CCITT Group 3


for monochrome black-and-white images
(depth of 1) only.

COMPRESS=G4FAX sets compression to FAX CCITT Group4 for


monochrome black-and-white images
(depth of 1) only.
DESC= enables description for catalog description

DIB FORMAT=DIB is supported only by Windows NT, Window


2000, and Windows XP.

EMF FORMAT=EMF is supported only by Windows 95, Windows


98, Windows 2000, and Windows NT.
GIF FORMAT=GIF

JFIF FORMAT=JFIF is required for writing JPEG files that use


JPEG File Interchange Format (JFIF).

DCT=mode selects specific type of Discrete Cosine


Transform (DCT) to use when processing
the image; mode can be
3 INT — an integer DCT
3 FAST — a faster and less accurate
integer DCT
3 FLOAT — a slightly more accurate
method that can be slower unless the
host has very fast floating point
hardware.

GRAYSCALE produces a gray-scale image even if the


JPEG file is in color. This is useful for
viewing on monochrome displays. The
writer runs noticeably faster in this mode.

VERSION prints the version number and copyright


messages for the Independent JPE Group’s
JFIF software to the log.
SAS/GRAPH Colors and Images Reading and Writing Image File Types 111

File Type Writer Attributes Comment

FAST enables certain recommended processing


options for fast, low quality output;
equivalent to enabling ONEPASS,
DITHER=ORDERED, COLORS=216,
NOSMOOTH, and DCT=FAST.

NOSMOOTH uses a faster, lower quality, upsampling


routine.

ONEPASS uses a one-pass color quantization instead


of the standard two-pass quantization. The
one-pass method is faster and needs less
memory, but it produces a lower-quality
image. This attribute is ignored unless you
also specify the COLORS attribute.
ONEPASS is always enabled for gray-scale
output.

COLORS=n reduces the number of colors in the image


to at most n colors; n must be in the range
2...256.

SCALE_RATIO=n scales the output image by a factor of 1/n.


Currently the scale factor must be 1/1, 1/2,
1/4, or 1/8. This is useful when processing a
large image and only a smaller version is
needed, as the writer is much faster when
scaling down the output.
DITHER=mode selects the specific type of dithering to use
color quantization; mode can be
3 FS — Floyd-Steinberg dithering
3 ORDERED — ordered dithering
3 NONE — no dithering.

PBM FORMAT=PBM
COMPRESS=NONE creates a text PBM file.

COMPRESS=BINARY | if either of these values is specified, creates


RAW a PBM file of reduced size by packing the
pixels as binary data (when FORMAT=PBM
is specified, output is produced by default
as if one of these values is specified).

PCL FORMAT=PCL
DPI=num specifies the number of dots per inch to use
to calculate the visual size of the image on
the PostScript page in the output file. The
default is 300. For example, a 600-pixel by
600-pixel image appears as a 2-inch by
2-inch image on the PostScript page if you
use the default setting.

EPS does not reset the printer margins; use to


embed an image into another PCL
document
112 Reading and Writing Image File Types Chapter 6

File Type Writer Attributes Comment

PNG FORMAT=PNG
PS FORMAT=PS

COMPRESS=NONE is the default for color images.


COMPRESS=RLE sets compression to run-length encoded;
default for gray-scale images.
DPI=num specifies the number of dots per inch to use
to calculate the visual size of the image on
the PostScript page in the output file. The
default is 300. For example, a 600-pixel by
600-pixel image appears as a 2-inch by
2-inch image on the PostScript page if you
use the default setting.

EPS does not reset the printer margins; used to


embed an image in another PCL document.

PREVIEW specifies whether a scaled-down, 1–bit,


black-and-white preview image is written
into the encapsulation header. The preview
image enables this file to be written by
software (such as SAS) that doesn’t support
a real PostScript writer.
PREWIDTH=x sets the size of the preview image in pixels
PREHEIGHT=y if PREVIEW is specified (default: 25% of
original size).
XSCALE directly sets width scaling in points (1/72
inch). Default: calculate it.
YSCALE directly sets height scaling in points (1/72
inch). Default: calculate it.

PAGEX sets output page width in points (1/72 inch).


Default: 612 (a typical 8.5–inch page).

PAGEY sets output page height in points (1/72


inch). Default: 792 (a typical 11–inch page).

NOFIT turns off the default of scaling an oversized


image down to fit the page. Must be used
with XSCALE and YSCALE. Although this
option is still supported in this release, the
PAGEFIT option will replace it.

PAGEFIT 0 = Image size is not adjusted


(equivalent of NOFIT).
1 = Image size is adjusted only if the
image exceeds the page size (default).
2 = Image size is always adjusted to fill
the page.
This option replaces the NOFIT option.

TIFF FORMAT=TIFF
COMPRESS=NONE is the default
SAS/GRAPH Colors and Images Placing a Background Image 113

File Type Writer Attributes Comment

COMPRESS=G3FAX sets compression to FAX CCITT Group 3


for monochrome black-and-white (depth of
1) images only.
COMPRESS=G4FAX sets compression to FAX CCITT Group 4
for monochrome black-and-white (depth of
1) images only.
WMF FORMAT=WMF is supported only under Windows operating
systems.
XBM FORMAT=XBM is supported for writing only from
interactive windows under UNIX.

XPM FORMAT=XPM is supported only under the X Windows


System under UNIX.

Image File Types Supported Only on Certain Hosts


Some file types are only supported by certain hosts. You must include a FORMAT=
attribute when you are reading or writing the following image file types shown in the
following table:

File Type Reader Attributes Writer Attributes Host

DIB FORMAT=DIB FORMAT=DIB Windows NT, Window


2000, and Windows XP

EMF FORMAT=EMF FORMAT=EMF Windows NT, Window


2000, and Windows XP
WMF FORMAT=WMF Windows operating
systems
XBM FORMAT=XBM interactive windows
under UNIX
XPM FORMAT=XPM FORMAT=XPM X Windows System
under UNIX

Placing a Background Image


Any SAS/GRAPH procedure that produces a picture can place an image on the
graph’s background area. To place an image on the graph background, use the IBACK=
option on a GOPTIONS statement. On IBACK=, specify either the full path to the
image file in quotation marks, or a fileref that has been defined to point to the image
file as follows:
goptions iback=’external-image-file’;

“Image File Types Supported by SAS/GRAPH” on page 106 shows the image file
formats that you can use. “Disabling and Enabling Image Output” on page 120 shows
how to suppress the image output without removing the imaging code from your
114 Placing a Background Image Chapter 6

SAS/GRAPH program; for example, you might want to suppress the image when
printing the graph.
By default, the image is tiled on the background, which means that the image is
copied as many times as needed to fill the background area. You can specify
IMAGESTYLE=FIT on the GOPTIONS statement to stretch the image so that a single
image fits within the entire background area:
goptions iback=’external-image-file’
imagestyle=fit;

After fitting the image, you can tile subsequent images by resetting the GOPTIONS
statement or by specifying IMAGESTYLE=TILE. The following graphs illustrate the
use of tiled versus stretched images.
The following example displays an image behind a pie chart. Because the
IMAGESTYLE option is not used, the image is tiled in the background area.
goptions reset=all ctitle=cx90d0d9 ftitle=swissb
ctext=white htext=0.85 htitle=2.5 ftext=swissb
colors=(cx00cccc cxcd0369 cx5b768d
cx594f4a cx008080 cxff8f71)
iback=’external-image-file’;
title ’Projected Automobile Sales’;
data sales;
length month $ 9;
input month amount;
datalines;
January 200
February 145
March 220
April 180
May 155
June 250
;
proc gchart;
pie month / freq=amount value=inside
noheading coutline=black;
run;
quit;

The preceding program generates the following graph, which illustrates the tiling of
an image to fill an area.
SAS/GRAPH Colors and Images Placing a Backplane Image on Graphs with Frames 115

Figure 6.2 Pie Chart with a Tiled Image in the Background

Adding the IMAGESTYLE=FIT goption to the preceding program generates the


following graphics output, where a single instance of the image is stretched to fit the
background of the graph:

Figure 6.3 Pie Chart with a Stretched Image in the Background

Placing a Backplane Image on Graphs with Frames


Procedures GCHART, GPLOT, GRADAR, and GSLIDE support frames, which are the
backplanes behind the graphs. Each of these procedures enables you to place an image
on the backplane.
To place an image on the backplane of a graph that supports frames, specify the
IFRAME= option on the procedure that generates the graph. On the IFRAME= option,
specify either the full path to the image file in quotation marks, or a fileref that has
been defined to point to the image file as follows:
iframe=fileref | ’external-image-file’

“Image File Types Supported by SAS/GRAPH” on page 106 shows the image file
formats that you can use. “Disabling and Enabling Image Output” on page 120 shows
how to suppress the image output without removing the imaging code from your
116 Placing Images on the Bars of Two-Dimensional Bar Charts Chapter 6

SAS/GRAPH program; for example, you might want to suppress the image when
printing the graph.
By default, the image is tiled on the backplane, which means that the image is copied
as many times as needed to fill the backplane.
To stretch a single instance of the image to fill the backplane, specify
IMAGESTYLE=FIT as follows:
iframe=fileref | ’external-image-file’
imagestyle=fit;

To switch from a single fitted image back to a series of tiled images, you can specify
IMAGESTYLE=TILE.
The following example displays an image on the backplane of a horizontal bar chart.
Because the IMAGESTYLE= option is not used, the image is tiled by default.
goptions reset=all ctitle=cx000080 ftitle=swissb
ctext=black htext=0.85 htitle=2.5 ftext=swissb
cback=cxf7e1c2;
title ’Projected Automobile Sales’;
data sales;
length month $ 9;
input month amount;
datalines;
January 200
February 145
March 220
April 180
May 155
June 250
;
pattern1 value=solid color=cxcd0369;
axis1 width=1.5 major=(width=1.5)
label=( h=1 ’Number of Cars’) noplane;
axis2 width=1.5 major=(width=1.5)
label=( h=1 ’Month’) noplane;

proc gchart;
hbar3d month / freq=amount
nostats
axis=axis1
maxis=axis2
iframe=’external-image-file’
coutline=black;
run;
quit;

Placing Images on the Bars of Two-Dimensional Bar Charts


Using the PATTERN statement, you can place images on the two-dimensional bars of
graphs that are generated by the GCHART procedure’s HBAR or VBAR statements. To
place an image on a two-dimensional bar, use the IMAGE= option on a PATTERN
statement. On the IMAGE= option, specify the image file as follows:
pattern image=fileref | ’external-image-file’;
SAS/GRAPH Colors and Images Placing Images on the Bars of Two-Dimensional Bar Charts 117

“Image File Types Supported by SAS/GRAPH” on page 106 shows the image file
formats that you can use. “Disabling and Enabling Image Output” on page 120 shows
how to suppress the image output without removing the imaging code from your
SAS/GRAPH program; for example, you might want to suppress the image when
printing the graph.
By default, the image is tiled on the bar, which means that the image is copied as
many times as needed to fill the bar area. You can specify IMAGESTYLE=FIT on the
PATTERN statement to stretch a single instance of the image to fit the dimensions of
the bar, as follows:
pattern image=’external-image-file’
imagestyle=fit;

After fitting the image, you can tile subsequent images by resetting the PATTERN
statement or by specifying IMAGESTYLE=TILE.

Note: Images are only supported on the bars that are generated by the HBAR and
VBAR statements. If an image is specified on a PATTERN statement that is used with
another type of chart, then the PATTERN statement is ignored and default pattern
rotation is affected. For example, if you submit a PIE statement when an image has
been specified on PATTERN, the default fill pattern is used for the pie slices; however,
rather than rotating that pattern through the colors list, each slice in the pie displays
the fill pattern in the same color. 4

The following example generates a bar chart that shows the sales for different
automobile manufacturers. The bars that represent the sales figures for each
manufacturer display a model vehicle for that manufacturer. Because
IMAGESTYLE=FIT is not specified, each image is tiled on the bar that displays it.
goptions reset=all ctitle=cx000080 ftitle=swissb
ctext=black htext=0.85 htitle=2.5
ftext=swissb cback=cxf7e1c2;
title ’Projected Automobile Sales’;
data sales;
length Month $ 9 Manufacturer $ 10;
input Month amount Manufacturer;
datalines;
January 100 Nissan
February 80 Nissan
March 210 Nissan
April 201 Nissan
January 400 Dodge
February 90 Dodge
March 220 Dodge
April 202 Dodge
January 300 Cheverolet
February 70 Cheverolet
March 230 Cheverolet
April 203 Cheverolet
January 200 Ford
February 100 Ford
March 240 Ford
April 204 Ford
;
run;
pattern1 image=’external-image-file’; /* corvette image */
pattern2 image=’external-image-file’; /* viper image */
118 Using Annotate to Display an Image Chapter 6

pattern3 image=’external-image-file’; /* mustang image */


pattern4 image=’external-image-file’; /* nissan image */

axis1 label=( h=1 ’Number of Cars’);

proc gchart;
vbar month / freq=amount
coutline=black
subgroup=Manufacturer
axis=axis1
cframe=olive;
run;
quit;

Using Annotate to Display an Image


The Annotate facility enables you to display an image at the coordinate location that
you specify with the X and Y variables. To display an image, specify the file
specification for the image file in quotation marks on the IMGPATH variable, set the
image coordinates with the X and Y variables, and then call the IMAGE function, as
shown in the following example. One corner of the image is located by the current X
and Y position, and the opposite corner is located by the X and Y variables that are
associated with the IMGPATH variable.
x=10; y=5; function=’move’; output;
x=35; y=15; imgpath=’external-image-file’;
style = ’fit’;
function=’image’; output;

The code above draws an image from (10,5) to (35,15).


By default, the image is tiled, which means that it is copied as many times as needed
to fill the area. To stretch the image so that a single image fits within the area, set the
STYLE variable equal to ’fit’, as shown in the code above.
“Image File Types Supported by SAS/GRAPH” on page 106 shows the image file
formats that you can use. “Disabling and Enabling Image Output” on page 120 shows
how to suppress the image output without removing the imaging code from your
SAS/GRAPH program; for example, you might want to suppress the image when
printing the graph.
Here is a complete example:
goptions reset=all cback=olive;
data wrldtotl;
length company $ 10;
input company $ 1-10 mean 12-15;
datalines;
Nissan 550
Cheverolet 571
Ford 137
Dodge 273
Honda 546
Saturn 430
;
run;
data wrldanno;
length function style color $ 8 text $ 20 image $ 50;
SAS/GRAPH Colors and Images Using DSGI to Display an Image 119

retain line 0 xsys ysys ’2’ hsys ’3’ x 8;


set wrldtotl end=end;
function=’move’; x=x+8; y=20; output;
if company=’Nissan’ then
imgpath=’external-image-file’; /* Nissan image */
else if company=’Cheverolet’ then
imgpath=’external-image-file’; /* Corvette image */
else if company=’Ford’ then
imgpath=’external-image-file’; /* Mustang image */
else if company=’Dodge’ then
imgpath=’external-image-file’; /* Viper image */
else if company=’Honda’ then
imgpath=’external-image-file’; /* Honda image */
else if company=’Saturn’ then
imgpath=’external-image-file’; /* Saturn image */
function=’image’; y=y+(mean); x=x+9;
output;
function=’label’; y=0; x=x-4; size=3.5;
position=’E’; style=’swiss’;
color=’blue’; text=company; output;
function=’move’; y=y+(mean)-3; output;
function=’label’; x=x-1; text=left(put(mean,3.));
position=’5’; style=’swiss’; size=7; color=’red’; output;
if end then do;
function=’move’; x=10; y=20; output;
function=’draw’; x=90; y=20; line=1;
size=.5; color=’blue’; output;
function=’label’; x=50; y=95; text=’Projected Sales’;
xsys=’3’; ysys=’3’; position=’5’; style=’swissb’;
size=7; color=’ ’; output;
x=92; y=5; size=3; style=’swiss’; output;
function=’frame’; color=’blue’; when=’b’;
style=’empty’; output;
end;
run;
proc ganno annotate=wrldanno
datasys;
run;
quit;

Using DSGI to Display an Image


Using the DATA Step Graphics Interface (DSGI), you can display an image in a
designated position. To display an image, specify the file specification for the image file
in quotation marks on the GDRAW(’IMAGE’,...) function as follows:
rc=gdraw(’image’, ’external-image-file’, 20, 20, 40, 40, ’fit’);

The code above displays the image in the screen coordinates (20, 20) to (40, 40). The
last parameter indicates how to display the image. The following keywords are
available:

fit fits the image within the specified area. This stretches the image, if
necessary.
120 Disabling and Enabling Image Output Chapter 6

tile tiles the image within the specified area. This copies the image as
many times as needed to fit the area.
“Image File Types Supported by SAS/GRAPH” on page 106 shows the image file
formats that you can use. “Disabling and Enabling Image Output” on page 120 shows
how to suppress the image output without removing the imaging code from your
SAS/GRAPH program; for example, you might want to suppress the image when
printing the graph.
Here is a complete example:
goptions reset=all;
title ’DGSI with image’;
footnote ’ dsgi with image option’;
data image;
rc=ginit();
rc=graph(’clear’);
rc=gdraw(’image’,’external-image-file’,
5, 5, 90, 90,’fit’);
rc=graph(’update’);
rc=gterm();
run;
quit;

Disabling and Enabling Image Output


The NOIMAGEPRINT graphics option disables image output as follows:
goptions noimageprint;

NOIMAGEPRINT can be useful for printing output without images. To enable image
output, reset the GOPTIONS statement or specify the IMAGEPRINT graphics option.
121

CHAPTER

7
SAS/GRAPH Statements

Overview 123
AXIS Statement 124
Description 124
Syntax 125
Options 126
Text Description Suboptions 135
Using Text Description Suboptions 139
Tick Mark Description Suboptions 139
Using the AXIS Statement 140
Assigning AXIS Definitions 140
BY Statement 141
Description 141
Syntax 141
Required Arguments 142
Options 142
Preparing Data for BY-Group Processing 142
Controlling BY Lines 143
Suppressing the BY line 143
Suppressing the name of the BY variable 143
Controlling the appearance of the BY line 143
Naming the Catalog Entries 143
Using the BY Statement 143
With the GCHART Procedure 144
With the GMAP Procedure 144
With the GPLOT Procedure 144
With the RUN Groups 144
With the Annotate Facility 145
With TITLE, FOOTNOTE, and NOTE Statements 145
With PATTERN and SYMBOL Definitions 145
FOOTNOTE Statement 146
GOPTIONS Statement 146
Description 146
Syntax 146
Options 150
Using the GOPTIONS Statement 150
Graphics Option Processing 150
LEGEND Statement 151
Description 151
Syntax 151
Options 152
Text Description Suboptions 158
122 Contents Chapter 7

Using Text Description Suboptions 161


Using the LEGEND Statement 161
Positioning the Legend 162
Positioning the Legend on the Graphics Output Area 162
Using POSITION= and OFFSET= 162
Using ORIGIN= 163
Relating Legends to Other Graphic Elements 163
Interactions Between POSITION= and MODE= 163
Creating Drop Shadows and Block Effects 163
NOTE Statement 164
ODS HTML Statement 164
Description 164
Syntax 164
Required Arguments 165
Using the ODS HTML Statement 168
Specifying a Destination for ODS HTML Output 168
About Anchors 168
PATTERN Statement 169
Description 169
Syntax 169
Options 170
Using the PATTERN Statement 176
Altering or Canceling PATTERN Statements 177
About Default Patterns 177
How Default Patterns and Outlines Are Generated 178
Things That Affect Default Patterns 178
Working with PATTERN Statements 179
Explicitly Specifying Patterns 179
Generating Multiple Pattern Definitions 179
Selecting an Appropriate Pattern 180
Controlling Outline Colors 180
The Effect of the CPATTERN= Graphics Option 180
Specifying Version 6 Patterns 181
Specifying Device-Dependent Hardware Patterns 181
GDDM Drivers 181
TEK42xx Series Terminal Drivers 181
HPLJxxxx Drivers 181
Metagraphics Drivers 181
Understanding Pattern Sequences 182
Generating Pattern Sequences 182
Repeating Pattern Sequences 183
SYMBOL Statement 183
Description 183
Syntax 184
Options 184
Using the SYMBOL Statement 202
Altering or Canceling SYMBOL Statements 203
Controlling Consecutive SYMBOL Statements 203
Setting Definitions for PROC GPLOT 204
Specifying Plot Symbols 205
Specifying a Default Interpolation Method 205
Sorting Data with Spline Interpolation 205
Using Color 206
Specifying Colors with SYMBOL Statements 206
SAS/GRAPH Statements Overview 123

Specifying Color with CSYMBOL= 207


Specifying Line Types 207
Using Generated Symbol Sequences 208
Default Symbol Sequences 209
Symbol Sequences Generated from SYMBOL Statements 209
TITLE, FOOTNOTE, and NOTE Statements 210
Description 211
Syntax 212
Options 212
Using TITLE and FOOTNOTE Statements 224
Using the NOTE Statement 224
Using Multiple Options 224
Setting Defaults 225
Using Options That Can Reset Other Options 225
Substituting BY Line Values in a Text String 226
Example 1. Ordering Axis Tick Marks with SAS Datetime Values 226
Example 2. Specifying Logarithmic Axes 229
Example 3. Rotating Plot Symbols through the Colors List 231
Example 4. Creating and Modifying Box Plots 233
Example 5. Filling the Area between Plot Lines 236
Example 6. Enhancing Titles 238
Example 7. Using BY-group Processing to Generate a Series of Charts 240
Example 8. Creating a Simple Web Page with the ODS HTML Statement 245
Example 9. Combining Graphs and Reports in a Web Page 248
Example 10. Creating a Bar Chart with Drill-down for the Web 255
Details 259
Building an HREF value 259
Creating an image map 259
Referencing SAS/GRAPH output 260
See Also 260

Overview
SAS/GRAPH programs can use some of the SAS language statements that you
typically use with the base SAS procedures or with the DATA step, such as LABEL,
WHERE, and FORMAT. These statements are described in the SAS Language
Reference: Dictionary.
In addition, SAS/GRAPH has its own set of statements that affect only graphics
output generated by the SAS/GRAPH procedures and the graphics facilities Annotate
and DSGI. Most of these statements are global statements. That is, they can be
specified anywhere in your program and remain in effect until explicitly changed or
canceled. These are the SAS/PH global statements:
AXIS
modifies the appearance, position, and range of values of axes in charts and plots.
FOOTNOTE
adds footnotes to graphics output. This statement is like the TITLE statement and
is described in that section.
GOPTIONS
submits graphics options that control the appearance of graphics elements by
specifying characteristics such as default colors, fill patterns, fonts, or text height.
Graphics options can also temporarily change device settings.
124 AXIS Statement Chapter 7

LEGEND
modifies the appearance and position of legends generated by procedures that
produce charts, plots, and maps.
NOTE
adds text to the graphics output. This statement is an exception because it is not
global but local, meaning that it must be submitted within a procedure.
Otherwise, NOTE is like the TITLE statement and is described in that section.
PATTERN
controls the color and fill of patterns assigned to areas in charts, maps, and plots.
SYMBOL
specifies the shape and color of plot symbols as well the interpolation method for
plot data. It also controls the appearance of lines in contour plots.
TITLE
add titles to graphics output. The section describing the TITLE statement includes
the FOOTNOTE and NOTE statements.
These statements are described in this chapter, which also includes two Base
language statements that have a special effect when used with SAS/GRAPH procedures:
BY
processes data according to the values of a classification (BY) variable and
produces a separate graph for each BY-group value.
ODS HTML
generates one or more files written in Hyper Text Markup Language (HTML). If
you use it with SAS/GRAPH procedures, you can specify one of the device drivers
GIF, ACTIVEX, or JAVA (ACTIVEX and JAVA are only available with GCHART,
GCONTOUR, GMAP, GPLOT, and G3D). With the GIF device driver, the graphics
output is stored in GIF files. With the ACTIVEX device driver, graphics output is
stored as XML input to ActiveX controls. With the JAVA device driver, graphics
output is stored as XML input to Java applets. The HTML files that are generated
reference the graphics output. When viewed with a Web browser, the HTML files
can display graphics and non-graphics output together on the same Web page.

AXIS Statement
The AXIS statement controls the location, values, and appearance of the axes in plots
and charts.
Used by:
GBARLINE, GCHART, GCONTOUR, GPLOT, and GRADAR procedures
Global

Description
AXIS statements specify the characteristics of an axis, including:
3 the way the axis is scaled
3 how the data values are ordered
3 the location and appearance of the axis line and the tick marks
3 the text and appearance of the axis label and major tick mark values.
AXIS definitions are used only when they are explicitly assigned by an option in a
procedure that produces graphs with axes.
SAS/GRAPH Statements AXIS Statement 125

Figure 7.1 on page 125 illustrates the terms associated with the various parts of axes.

Figure 7.1 Parts of Axes

Syntax
AXIS<1...99>< options>;
option(s) can be one or more options from any or all of the following categories:
3 axis scale options:
INTERVAL=EVEN | UNEVEN | PARTIAL
LOGBASE=base | E | PI
LOGSTYLE=EXPAND | POWER
ORDER=(value-list)

3 appearance options:
COLOR=axis-color
LENGTH=axis-length <units >
NOBRACKETS
126 AXIS Statement Chapter 7

NOPLANE
OFFSET=(<n1 ><,n2 >)<units > | (<n1<units>><,n2<units >>)
ORIGIN=<(x><,y >)<units> | (<x<units >><,y<units>>)
STYLE=line-type
WIDTH=thickness-factor
3 tick mark options:
MAJOR=(tick-mark-suboption(s) )| NONE
MINOR=(tick-mark-suboption(s) )| NONE
3 text options:
LABEL=(text-argument(s) )| NONE
REFLABEL=(text-argument(s) )| NONE
SPLIT="split-char"
VALUE=(text-argument(s) )| NONE

Options
When the syntax of an option includes units, use one of these:
CELLS character cells
CM centimeters
IN inches
PCT percentage of the graphics output area
PT points
If you omit units, a unit specification is searched for in this order:
1 GUNIT= in a GOPTIONS statement
2 the default unit, CELLS.

COLOR=axis-color
C=axis-color
specifies the color for all axis components (the axis line, all tick marks, and all
text) unless you include a more explicit AXIS statement color specification. Any of
these color specifications override COLOR= for the specified item:

Table 7.1

Option Items Affected

AXIS statement: axis label


LABEL=(COLOR=color) reference-line labels
REFLABEL=(COLOR=color) major tick mark values
VALUE=(COLOR=color)

calling procedure: all axis text (AXIS label and major tick mark
CTEXT= value descriptions)
CAXIS= axis line and major and minor tick marks

If you omit all color options, the AXIS statement looks for a color specification
in this order:
SAS/GRAPH Statements AXIS Statement 127

1 the CTEXT= graphics option in a GOPTIONS statement.


2 If CTEXT= is not used, the color of all axis components is the first color in
the colors list, except for PROC GCONTOUR, which uses the second color.
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226 .
INTERVAL=EVEN | UNEVEN | PARTIAL
The INTERVAL option affects the LOGBASE option on the AXIS statement.
Specifying the option INTERVAL=UNEVEN and LOGBASE=10, permits
non-base10 values to be specified for the ORDER option, while retaining a
logarithmic scale for the axis.
LABEL=(text-argument(s)) | NONE
modifies an axis label. Text-argument(s) defines the appearance or the text of an
axis label, or both. NONE suppresses the axis label. Text-argument(s) can be one
or more of these:
’text-string’
provides up to 256 characters of label text. By default, the text of the axis
label is either the variable name or a previously assigned variable label.
Enclose each string in quotes. Separate multiple strings with blanks.
text-description-suboption
modifies a characteristic such as the font, color, or size of the text string(s)
that follows it. Text-description-suboption can be
ANGLE=degrees
COLOR=text-color
FONT=font | NONE
HEIGHT=text-height <units >
JUSTIFY=LEFT | CENTER | RIGHT
ROTATE=degrees
See “Text Description Suboptions” on page 135 for a complete description.
Specify as many text strings and text description suboptions as you want, but
enclose them all in one set of parentheses.
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226, “Example 2. Specifying Logarithmic Axes” on page 229 , and
“Example 7. Using BY-group Processing to Generate a Series of Charts” on page
240
Not supported by: Java (partial), ActiveX (partial)

LENGTH=axis length <units >


specifies the length of the axis in number of units. If you request a length that
cannot fit the display, an error message is issued and no graph is drawn.
This option is not supported by the GRADAR Procedure.
Featured in: “Example 2. Specifying Logarithmic Axes” on page 229 and
“Example 9. Combining Graphs and Reports in a Web Page” on page 248 .
Not supported by: Java, ActiveX

LOGBASE=base | E | PI
scales the axis values logarithmically according to the value specified. Base must
be greater than 1. How the values are displayed on the axis depends on the
LOGSTYLE= option. For example, LOGBASE=E with the default
LOGSTYLE=EXPAND generates an axis like the one in Figure 7.2 on page 128.
128 AXIS Statement Chapter 7

Figure 7.2 Axis Generated with LOGBASE=E and LOGSTYLE=EXPAND

NUM
e ** 4

e ** 3

e ** 2

e ** 1

e ** 0

This option is not supported by the GRADAR Procedure.


Featured in: “Example 2. Specifying Logarithmic Axes” on page 229.
Not supported by: Java
LOGSTYLE=EXPAND | POWER
specifies whether the values displayed on the logarithmic axis are the values of the
base or the values of the power. LOGSTYLE= is meaningful only when you use
LOGBASE=.
LOGSTYLE=EXPAND specifies that the values displayed are the values of the
base raised to successive powers and that the minor tick marks are logarithmically
placed. For example, if the base is 10, the values displayed are 10, 100, 1000,
10000, and so on. The default is LOGSTYLE=EXPAND. This statement generates
an axis like the one in part (a) of Figure 7.3 on page 128:
axis logbase=10 logstyle=expand;

LOGSTYLE=POWER specifies that the values displayed are the powers to


which the base is raised (for example, 1, 2, 3, 4, 5, and so on). For example, this
statement generates an axis like the one in part (b) of Figure 7.3 on page 128:
axis logbase=10 logstyle=power;

Figure 7.3 Axes Generated with the LOGSTYLE=option

NUM NUM LOG 10


100000 5

10000 4

1000 3

100 2

10 1

a. b.

If you use ORDER= with a logarithmic axis, the values specified by ORDER=
must match the style specified by LOGSTYLE=. For example, if you specify a
logarithmic axis with a base of 2 and you want to display the first five expanded
values, use this statement:
SAS/GRAPH Statements AXIS Statement 129

axis logbase=2 logstyle=expand


order=(2 4 8 16 32);

If you use LOGSTYLE=POWER, the values in ORDER= must represent the


powers to which the base is raised, as in this example:
axis logbase=2 logstyle=power order=(1 2 3 4 5);

If the values that are specified by ORDER= do not match the type of values
specified by LOGSTYLE=, the request for a logarithmic axis is ignored.
This option is not supported by the GRADAR Procedure.
Featured in: “Example 2. Specifying Logarithmic Axes” on page 229 .
Not supported by: Java
MAJOR=(tick-mark-suboption(s) )| NONE
modifies the major tick marks. Tick-mark-suboption(s) defines the color, size, and
number of the major tick marks. NONE suppresses all major tick marks, although
the values represented by those tick marks are still displayed.
Tick-mark-suboption can be
COLOR=tick-color
HEIGHT=tick-height <units >
NUMBER=number-of-ticks
WIDTH=thickness-factor
See “Tick Mark Description Suboptions” on page 139 for complete descriptions.
List all suboptions and their values within the parentheses.
AXIS definitions assigned to the group axis of a bar chart by the GAXIS= option
ignore MAJOR= because the axis does not use tick marks.
Note: By default, tickmarks are now placed at three intervals on the spokes of
a GRADAR chart. They are placed at the minimum value, maximum value, and at
one value in between. The tick marks on the 12 o’clock spoke are also labeled by
default.
HEIGHT is not supported by Java or ActiveX. WIDTH is not supported by
Java. 4
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226 , “Example 2. Specifying Logarithmic Axes” on page 229, and
“Example 7. Using BY-group Processing to Generate a Series of Charts” on page
240.
Not supported by: Java (partial), ActiveX (partial).
MINOR=(tick-mark-suboption(s) )| NONE
modifies the minor tick marks that appear between major tick marks.
Tick-mark-suboption(s) defines the color, number, or size of the minor tick marks.
NONE suppresses all minor tick marks. Tick-mark-suboption can be
COLOR=tick-color
HEIGHT=tick-height <units >
NUMBER=number-of-ticks
WIDTH=thickness-factor
See “Tick Mark Description Suboptions” on page 139 for complete descriptions.
List all suboptions and their values within the parentheses.
AXIS definitions assigned to the group axis of a bar chart by the GAXIS= option
ignore MINOR= because the axis does not use tick marks.
This option is not supported by the GRADAR Procedure.
HEIGHT is not supported by Java or ActiveX.
130 AXIS Statement Chapter 7

Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226, “Example 2. Specifying Logarithmic Axes” on page 229, and
“Example 7. Using BY-group Processing to Generate a Series of Charts” on page
240.
Not supported by: Java (partial), ActiveX (partial)
NOBRACKETS
suppresses the printing of group brackets drawn around the values on the group
axis in a bar chart. NOBRACKETS applies only to the group axis of bar charts.
This option is not supported by the GRADAR Procedure.
See also: GROUP= on page 805 and GAXIS= on page 805.
Not supported by: Java, ActiveX
NOPLANE
removes either the horizontal or vertical 3D axis plane in bar charts produced by
the HBAR3D and VBAR3D statements. NOPLANE affects only the axis to which
the AXIS statement applies.
To remove selected axis elements such as lines, values or labels, use specific
AXIS statement options. To remove all axis elements except the 3D planes use the
NOAXIS option in the procedure. To remove the backplane, use the NOFRAME
option in the procedure.
This option is not supported by the GRADAR Procedure.
Featured in: “Example 7. Using BY-group Processing to Generate a Series of
Charts” on page 240.
OFFSET=(<n1><,n2>)<units > | (<n1<units>><,n2<units>>)
specifies the distance from the first and last major tick marks or bars to the ends
of the axis line.
The value of (n1 )is the distance from the beginning (origin) of the axis line to
the first tick mark or middle of the first bar, and the value of (n2 )is the distance
from the end of the axis line to the last tick mark or middle of the last bar.
On a horizontal axis, the (n1) offset is measured from the left end of the axis
line and the (n2) offset is measured from the right end. On a vertical axis, the (n1)
offset is measured up from the bottom of the axis line and the (n2) offset is
measured down from the top of the line.
To specify the same offset for both n1 and n2, use one value, with or without a
following comma. For example, either option sets both n1 and n2 to 4 centimeters:
offset=(4 cm)
offset=(4 cm,)

To specify different offsets, use two values, with or without a comma separating
them. For example,
offset=(4 cm, 2 cm)

To specify only the second offset, use only one value preceded by a comma. This
option offsets the last major tick mark or bar 3 centimeters from the right-hand
end of the axis line:
offset=(,3 cm)

You can specify units for the n1,n2 pair or for the individual offset values.
This option is not by the GRADAR Procedure .
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226.
Not supported by: Java
ORDER=(value-list )
SAS/GRAPH Statements AXIS Statement 131

specifies the order in which data values appear on the axis. The values specified
by ORDER= are the major tick mark values. You can modify the appearance of
these values with the VALUE= option.
The way you specify value-list depends on the type of variable:
3 For numeric variables, value-list is either an explicit list of values or a
starting and an ending value with an interval increment, or a combination of
both forms:
n <...n>
n TO n <BY increment>
n<...n> TO n <BY increment > <n <...n > >
If a numeric variable has an associated format, the specified values must
be the unformatted values.
Values must be listed in either ascending or descending order. By default
the increment value is 1. You can use a negative integer for increment to
specify a value list in descending order. In all forms, multiple n values can be
separated by blanks or commas. Here are some examples:
order=(2 4 6)
order=(6,4,2)
order=(2 to 10 by 2)
order=(50 to 10 by -5)

If the specified range is not evenly divisible by the increment value, the
highest value displayed on the axis is the last incremental value below the
ending value for the range. For example, this value list produces a maximum
axis value of 9:
order=(0 to 10 by 3)

3 For character variables, value-list is a list of unique character values enclosed


in quotes and separated by blanks:
’value-1’ <...’value-n’>
If a character variable has an associated format, the specified values must
be the formatted values for PROC GCHART and the unformatted values for
PROC GPLOT.
Character values can be specified in any order, but the character strings
must match exactly the variable values in case and spelling. For example,
order=(’Paris’ ’London’ ’Tokyo’)

Observations can be inadvertently excluded if entries in the value-list are


misspelled or if the case does not match exactly.
3 For date and time values, value-list can have the following forms:
’SAS-value’i <...’SAS-value’i>
’SAS-value’i TO ’SAS-value’i <BY interval>
’SAS-value’i
is any SAS date, time, or datetime value described for the SAS
functions INTCK and INTNX. Enclose the value in quotes and
specify one of the following for i:
D date
T time
DT datetime
interval
132 AXIS Statement Chapter 7

is one of the valid arguments for the INTCK or INTNX functions.


These are the default intervals:
DAY default interval for date
SECOND default interval for time
DTSECOND default interval for datetime
These value lists use SAS date and time values:
order=(’25MAY98’d ’04JUL98’d ’07SEP98’d)
order=(’01JUL97’d to ’01AUG97’d)
order=(’01JUL97’d to ’01JAN98’d by week)
order=(’9:25’t to ’11:25’t by minute)
order=(’04JUN97:12:00:00’dt to
’10JUN9712:00:00’dt by dtday)

With SAS date and time values, use a FORMAT statement so that the tick
mark values have an understandable form. For more information on SAS
date and time values, see the SAS Language Reference: Dictionary.
With any type of value-list, specifying values that are not distributed uniformly
or are not in ascending or descending order, generates a warning message in the
SAS log. The specified values are spaced evenly along the axis even if the values
are not distributed uniformly.
Using ORDER= to restrict the values displayed on the axis may result in
clipping. For example, if the data range is 1 to 10 and you specify ORDER=(3 TO
5), only the data values from 3 to 5 appear on the plot or chart. For charts, the
omitted values are still included in the statistic calculation.
Note: Values out of range do not always produce a warning message in the
SAS log. 4

CAUTION:
The ORDER= option does not calculate midpoint values; as a result it is not
interchangeable with the MIDPOINTS= option in the GCHART procedure. 4
You can use ORDER= to specify the order in which the midpoints are displayed
on a chart, but do not use it to calculate midpoint values. Be sure that the values
you specify match the midpoint values that are calculated either by default by the
GCHART procedure or by the MIDPOINTS= option. For details, see the
description of MIDPOINTS= for the appropriate statement in Chapter 29, “The
GCHART Procedure,” on page 773.
ORDER= overrides the suboption NUMBER= described in “Tick Mark
Description Suboptions” on page 139.
ORDER= is not valid with the ASCENDING, DESCENDING and NOZEROS
options used with the bar chart statements in the GCHART procedure.
This option is not supported by the GRADAR procedure.
Note: The Java applet supports ORDER= for numeric axes, but does not
support ORDER= for categorical, character, midpoint, or group axes.
The ActiveX control supports only simple order lists. Non-uniform interval
values, such as dates, are not supported. Only max and min values are supported
with a default interval of one day. 4
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226, “Example 5. Filling the Area between Plot Lines” on page 236, and
“Example 7. Using BY-group Processing to Generate a Series of Charts” on page
240
SAS/GRAPH Statements AXIS Statement 133

Not supported by: Java (partial), ActiveX (partial)


ORIGIN=(<x><,y>)<units> | (<x<units>><,y<units>>)
specifies the x coordinate and the y coordinate of the origin of the axis. The origin
of the horizontal axis is the left end of the axis, and the origin of the vertical axis
is the bottom of the axis. ORIGIN= explicitly positions the axis anywhere on the
graphics output area.
If you specify only one value, with or without a comma following it, only the x
coordinate is set to that value. For example, this specification sets x to 4
centimeters:
origin=(4 cm,)

If you specify two values, with or without a comma separating them, the first
value sets the x coordinate and the second value sets the y coordinate, as in this
example:
origin=(2 pct, 4 pct)

If you specify one value preceded by a comma, only the y coordinate is set to
that value, as shown here:
origin=(,3 pct)

You can specify units for the x,y pair or for the individual coordinates.
This option is not supported by the GRADAR Procedure.
Not supported by: Java, ActiveX
REFLABEL=(text-argument(s)) | NONE
creates and defines the appearance of a reference-line label. Text-argument(s)
defines the appearance or the text of the label, or both. NONE suppresses the
reference-line label. Text-argument(s) can be one or more of these:
’text-string’
provides up to 256 characters of label text. By default, a reference line does
not have a label. Enclose each string in quotes. Separate multiple strings
with blank spaces; the strings are applied to the reference lines consecutively
along the axis, from the plot origin to the end of the axis.
text-description-suboption
modifies a characteristic such as the font, color, or size of the text string(s)
that follows it. Text-description-suboption can be
ANGLE=degrees
AUTOREF
COLOR=text-color
FONT=font | NONE
HEIGHT=text-height <units >
JUSTIFY=LEFT | CENTER | RIGHT
POSITION=TOP| MIDDLE| BOTTOM
ROTATE=degrees
T=n
See “Text Description Suboptions” on page 135 for a complete description.
Specify as many text strings and text description suboptions as you want, but
enclose them all in one set of parentheses.
REFLABEL is not supported by the GRADAR Procedure.
Not supported by: Java, ActiveX.
134 AXIS Statement Chapter 7

SPLIT="split-char"
specifies the split character that the AXIS statement uses to break axis values into
multiple lines. Split-char can be any character value that can be specified in a SAS
character variable. The split character must be embedded in the variable values in
the data set or in an associated format. When the AXIS statement encounters the
split character, it automatically breaks the value at that point and continues on
the next line. For example, suppose the data set contains the value Berlin,
Germany, and you specify SPLIT=",". The value would appear on the axis as
Berlin
Germany

Note that the split character itself is not displayed.


Axis values specified with VALUE= do not use the split character. For example,
suppose you specify this statement:
axis1 spilt="," value=(t1=’December, 1999’);

The value will appear on the axis on one line as December, 1999. However,
any other axis values containing a comma would honor the split character.
This option is not supported by the GRADAR Procedure.
Featured in: Example 7 on page 856
Not supported by: Java, ActiveX
STYLE=line-type
specifies a line type for the axis line. Valid values for line-type are 0 through 46. If
you specify STYLE=0, the axis line is not drawn. The default is 1, a solid line.
Note: In order for the axis line to be altered by the STYLE= option, the
NOFRAME option must also be set. If only the STYLE=option is set, the axis
frame will be modified.
Note: This option overrides the LineStyle attribute in graph styles. For more
information on graph styles, see SAS Output Delivery System: User’s Guide . 4
4
Note: See also: Figure 7.22 on page 208 for examples of the available line
types. 4
VALUE=(text-argument(s) )| NONE
modifies the major tick mark values. That is, this option modifies the text that
labels the major tick marks on the axis. Text-argument(s) defines the appearance
or the text of a major tick mark value, or both. NONE suppresses the major tick
mark values, although the major tick marks are still displayed. Text-argument(s)
can be one or more of these:
’text-string’
provides up to 256 characters of text for the major tick mark value. By
default, the value is either the variable value or an associated format value.
Enclose each string in quotes and separate multiple strings with blanks.
Specified text strings are assigned to major tick marks in order. If you
specify only one text string, only the first tick mark value changes, and all
the other tick mark values display the default. If you specify multiple strings,
the first string is the value of the first major tick mark, the second string is
the value of the second major tick mark, and so forth. For example, to change
default tick mark values 1, 2, and 3 to First, Second, and Third, use this
option:
value=(’First’ ’Second’ ’Third’)
SAS/GRAPH Statements AXIS Statement 135

Note: Although VALUE= changes the text displayed at a major tick mark,
it does not affect the actual value represented by the tick mark. To change
the tick mark values, use ORDER=. Also note that with client-side rendering
using Java or ActiveX, it is necessary to use ORDER= to ensure that the
same number of tick marks are displayed as with server-rendered graphics.
For example, specify ORDER=(1 to 12) to ensure that tick marks for all
twelve months are displayed on the client.
To change the value of midpoints in bar charts produced with the
GCHART procedure, use the MIDPOINTS= option in the procedure. 4
text-description-suboption
modifies a characteristic such as the font, color, or size of the text string(s)
that follows it. Text-description-suboption can be
ANGLE=degrees
COLOR=text-color
FONT=font | NONE
HEIGHT=text-height <units >
JUSTIFY=LEFT | CENTER | RIGHT
ROTATE=degrees
TICK=n.
For a complete description, see “Text Description Suboptions” on page 135.
Place text description suboptions before the text strings they modify.
Suboptions not followed by a text string affect the default values. To specify
and describe the text for individual values or to produce multi-line text, use
the TICK= suboption.
Specify as many text strings and text description suboptions as you want, but
enclose them all in one set of parentheses.
Note: If an end-user viewing a graph in the Java applet or ActiveX control
zooms in on a particular part of a graph for which VALUE= is specified, the values
are not readjusted in coordination with the zooming. 4
Featured in: “Example 2. Specifying Logarithmic Axes” on page 229, “Example
7. Using BY-group Processing to Generate a Series of Charts” on page 240, and
“Example 9. Combining Graphs and Reports in a Web Page” on page 248.
Not supported by: Java (partial), ActiveX (partial)
WIDTH=thickness-factor
specifies the thickness of the axis line. Thickness increases directly with the value
of thickness-factor. By default, WIDTH=1.
Note: In order for the axis line to be altered by the WIDTH= option, the
NOFRAME option must also be set. If only the WIDTH=option is set, the axis
frame will be modified.
Java does not support WIDTH. ACTIVEX ignores the WIDTH option for the
vertical axis of an AXIS statement with GPLOT and GCONTOUR. 4
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226.
Not supported by: Java, ActiveX (partial)

Text Description Suboptions


Text description suboptions are used by the LABEL=, REFLABEL=, and VALUE=
options to change the color, height, justification, font, and angle of either default text or
136 AXIS Statement Chapter 7

specified text strings. See LABEL= on page 127, REFLABEL= on page 133, and
VALUE= on page 134.
ANGLE=degrees
A=degrees
specifies the angle of the baseline with respect to the horizontal. A positive value
for degrees moves the baseline counterclockwise; a negative value moves it
clockwise. By default, ANGLE=0 (horizontal) unless the text is automatically
angled or rotated to avoid overlapping. For an illustration of the effect of
ANGLE=, see Figure 7.24 on page 213.
Note: Changing the angle of a vertical axis-label can result in the label being
positioned above the graph when using client-side rendering with Java or
ActiveX. 4
See also: the ROTATE= suboption on page 138
Featured in: Example 7 on page 856 .
Not supported by: Java (partial)

AUTOREF
automatically labels each reference line on an axis with the response value at the
reference line’s position. AUTOREF is only used with the REFLABEL= option.
The automatic labels are applied only to reference lines that do not have specific
labels assigned to them. For example, the following option uses the response-axis
value as the label for every reference line except the second reference line, which
is assigned the label two:
reflabel=(autoref t=2 "two")

Note, however, that if at the same time you also request automatic labeling with
a PLOT or BUBBLE statement (using the AUTOHREF or AUTOVREF option),
then the automatic labeling of the PLOT or BUBBLE statement can write on top
of your custom label specified with t he AXIS statement. You must ensure that
your custom labels specified with the AXIS statement are not at the same position
as automatic labels requested with a different statement.
Not supported by: Java, ActiveX, GIF

COLOR=text-color
C=text-color
specifies the color for the text. If you omit the COLOR= suboption, a color
specification is searched for in this order:
1 the CTEXT= option for the procedure
2 the CTEXT= option in a GOPTIONS statement
3 the default, the first color in the colors list.

FONT=font | NONE
F=font | NONE
specifies the font for the text. See Chapter 5, “SAS/GRAPH Fonts,” on page 75 for
details on specifying font. If you omit FONT=, a font specification is searched for
in this order:
1 the FTEXT= option in a GOPTIONS statement
2 the default hardware font, NONE.
Not supported by: Java (partial)

HEIGHT=text-height <units >


H=text-height <units >
SAS/GRAPH Statements AXIS Statement 137

specifies the height of the text characters in number of units. By default,


HEIGHT=1 CELL. If you omit HEIGHT=, a text height specification is searched
for in this order:
1 the HTEXT= option in a GOPTIONS statement

2 the default value, 1.

JUSTIFY=LEFT | CENTER | RIGHT


J=L | C | R
specifies the alignment of the text. The default depends on the option with which
it is used and the text it applies to.
3 With the LABEL= option:
3 for a left vertical axis label, the default is JUSTIFY=RIGHT
3 for a right vertical axis label, the default is JUSTIFY=LEFT
3 for a horizontal axis label, the default is JUSTIFY=CENTER.
3
With the REFLABEL= option:
3 for a vertical axis, the default is JUSTIFY=CENTER. RIGHT places the
text string on the right end of the line, CENTER in the middle of the
line, and LEFT to the left of the line.
3 for a horizontal axis label, the default is JUSTIFY=RIGHT. RIGHT
places the text string just to the right of the line, CENTER is centered
on top of the line, and LEFT places the text string just to the left of the
line.

3 With the VALUE= option:


3 for numeric variables on a vertical axis, the default is JUSTIFY=RIGHT
3 for character variables on a vertical axis, the default is JUSTIFY=LEFT
3 for all variables on a horizontal axis, the default is JUSTIFY=CENTER.

Note: With client-side output using Java and ActiveX, text justification is
relative to the text string, not the tick mark. For example, left justification means
that the left end of the text string is justified with respect to the drawing location,
as well as other strings in a multiline label—which may be to the right of a tick
mark. 4
You can use JUSTIFY= to print multiple lines of text by repeating JUSTIFY=
before the text string for each line. You can also use JUSTIFY= to specify
multi-line text at specified major tick marks. For example, this statement
produces an axis label and major tick mark values like those shown in Figure 7.4
on page 138.
axis label=(’Current’ justify=c
’Sales Projections’)
value=(tick=1 ’JAN’ justify=c ’1997’
tick=2 ’FEB’ justify=c ’1997’
tick=3 ’MAR’ justify=c ’1997’
tick=4 ’APR’ justify=c ’1997’
tick=5 ’MAY’ justify=c ’1997’);
138 AXIS Statement Chapter 7

Figure 7.4 The JUSTIFY= suboption

JAN FEB MAR APR MAY


1997 1997 1997 1997 1997
Current
Sales Projections

Specify additional suboptions before any string.


See also: the suboption TICK= on page 138.
Not supported by: Java
POSITION=TOP | MIDDLE | BOTTOM
specifies the position of a reference-line label relative to the reference line. The
default is TOP for both vertical and horizontal reference lines. POSITION= is only
available on the REFLABEL= option.
3 For horizontal reference lines, TOP places the label just above the reference
line, MIDDLE places the label on the reference line, and BOTTOM places the
label just under the reference line.
3 For vertical reference lines, TOP places the label at the top end of the
reference line, MIDDLE places the label in the middle of the line, and
BOTTOM places the label at the bottom end of the line.
Not supported by: Java, ActiveX
ROTATE=degrees
R=degrees
specifies the angle at which each character of text is rotated with respect to the
baseline of the text string. A positive value for degree rotates the character
counterclockwise; a negative value moves it clockwise. By default, ROTATE=0
(parallel to the baseline) unless the text is automatically angled or rotated to avoid
overlapping. For an illustration of the effect of ROTATE=, see Figure 7.31 on page
222.
See also: the suboption ANGLE= on page 136
Not supported by: Java (partial)
TICK=n
T=n
specifies the n reference line or tick mark value. Used only with REFLABEL= or
with VALUE=. If neither one is specified, then T= is ignored.

3 With REFLABEL=, T= specifies the nth reference line. It is used to limit


modifications to individual reference lines when there are multiple reference
lines on an axis. For example, the following option changes the color of only
the third reference line’s label and leaves all other reference-line labels
unchanged:
reflabel=(autoref t=3 color=red)

Suboptions that precede T= affect all the reference-line labels on an axis.


Suboptions that follow T= affect only the specified line’s label. For example,
the following option assigns the color green to all the reference-line labels on
an axis, but left-justifies only the third reference line’s label:
reflabel(c=green "one" "two" t=3 j=left "three")
SAS/GRAPH Statements AXIS Statement 139

For the options to be applied to a text string, they must precede the quoted
string. In the following option, the j=left is ignored because it follows the
string:
reflabel(c=green "one" "two" t=3 "three" j=left)

3
Note: Client-side rendering with the Java applet or ActiveX control does not
support the REFLABEL option.
With VALUE=, TICK= specifies the nth major tick mark value. It is used to
designate the tick mark value whose text and appearance you want to modify.
For example, the following option changes the color of only the third tick
mark value and leaves all others unchanged:
value=(tick=3 color=red)

Suboptions that precede TICK= affect all the major tick mark values.
Suboptions that follow TICK= affect only the specified value. For example,
the following option makes all the major tick mark values 4 units high and
colors all of them blue except for the third one, which is red:
value=(height=4 color=blue tick=3 color=red)

Not supported by: Java, ActiveX

Using Text Description Suboptions


Text description suboptions affect all the strings that follow them unless the
suboption is changed or turned off. If the value of a suboption is changed, the new
value affects all the text strings that follow it. Consider this example:
label=(font=swiss height=4 ’Weight’
justify=right height=3 ’(in tons)’)

FONT=SWISS applies to both Weight and (in tons). HEIGHT=4 affects Weight,
but is respecified as HEIGHT=3 for (in tons). JUSTIFY=RIGHT affects only (in
tons).

Tick Mark Description Suboptions


Tick mark description suboptions are used by MAJOR= and MINOR= to change the
color, height, width, and number of the tick marks to which they apply. See MAJOR=
and MINOR=.
COLOR=tick-mark-color
C=tick-mark color
colors the tick marks. If you omit the COLOR= suboption, a color specification is
searched for in this order:
1 the COLOR= option in the AXIS statement
2 the CAXIS= option for the procedure
3 the default, the first color in the colors list.
HEIGHT=tick-height <units>
H=tick-height <units>
specifies the height of the tick mark. The defaults for the HEIGHT= suboption
depend on the option with which it is used:
3 With MAJOR= the default height .5 CELLS.
3 With MINOR= the default height .25 CELLS.
140 Using the AXIS Statement Chapter 7

If you specify a negative number, tick marks are drawn inside the axis.
Not supported by: Java, ActiveX
NUMBER=number-of-ticks
N=number-of-ticks
specifies the number of tick marks to be drawn. With MAJOR=, number-of-ticks
must be greater than 1. With MINOR=, number-of-ticks must be greater than 0.
With MAJOR=, the NUMBER= suboption can be overridden by a major tick
mark specification in the procedure, which in turn can be overridden by ORDER=.
With MINOR=, the NUMBER= suboption can be overridden by a minor tick
mark specification in the procedure.
NUMBER= is not valid with logarithmic axes.
WIDTH=thickness-factor
W=thickness-factor
specifies the thickness of the tick mark, where thickness-factor is a number.
Thickness increases directly with thickness-factor. By default, WIDTH=1.
Not supported by: Java (partial)

Using the AXIS Statement


AXIS statements can be defined anywhere in your SAS program. They are global and
remain in effect until redefined, canceled, or until the end of your SAS session. AXIS
statements are not applied automatically, and must be explicitly assigned by an option
in the procedure that uses them.
You can define up to 99 different AXIS statements. If you define two AXIS
statements of the same number, the most recently defined one replaces the previously
defined statement of the same number. An AXIS statement without a number is treated
as an AXIS1 statement.
Cancel individual AXIS statements by defining an AXIS statement of the same
number without options (a null statement):
axis4;

Canceling one AXIS statement does not affect any other AXIS definitions. To cancel
all current AXIS statements, use the RESET= option in a GOPTIONS statement:
goptions reset=axis;

Specifying RESET=GLOBAL or RESET=ALL cancels all current AXIS definitions as


well as other settings.
To display a list of current AXIS definitions in the LOG window, use the GOPTIONS
procedure with the AXIS option:
proc goptions axis nolist;
run;

Assigning AXIS Definitions


AXIS definitions must always be explicitly assigned by the appropriate option in the
statement that generates the graph. The following table lists the procedures and
statements that generate axes, the type of axis, and the statement option that assigns
an AXIS definitions to that axis:
SAS/GRAPH Statements BY Statement 141

Statement that
generates an Option that assigns an AXIS
Procedure axis Type of axis definition

GCHART HBAR | VBAR group axis midpoint GAXIS= MAXIS= RAXIS=


axis response axis
GCONTOUR PLOT horizontal axis HAXIS= VAXIS=
vertical axis
GPLOT PLOT horizontal axis HAXIS= VAXIS=
vertical axis
GRADAR CHART star axis STARAXIS=

Some types of axes cannot use certain AXIS statement options:


3 group and midpoint axes ignore LOGBASE=, MAJOR=, and MINOR=
3 midpoint, horizontal and vertical axes ignore NOBRACKETS.

BY Statement
The BY statement processes data and orders output according to the BY group.
Used by:
GCHART, GCONTOUR, GMAP, GPLOT, GREDUCE, G3D, G3GRID procedures

Description
The BY statement divides the observations from an input data set into groups for
processing. Each set of contiguous observations with the same value for a specified
variable is called a BY group. A variable that defines BY groups is called a BY variable
and is the variable that is specified in the BY statement. When you use a BY
statement, the graphics procedure
3 processes each group of observations independently
3 generates a separate graph or output for each BY group
3 automatically adds a heading called a BY line to each graph identifying the BY
group represented in the graph
3 adds BY statement information below the Description field of the catalog entry.
By default, the procedure expects the observations in the input data set to be sorted
in ascending order of the BY variable values.
Note: The BY statement in SAS/GRAPH is essentially the same as the BY
statement in base SAS, but the effect on the output is different when it is used with
SAS/GRAPH procedures. 4

Syntax
BY<DESCENDING>variable
<...<DESCENDING>variable-n>
<NOTSORTED>;
142 Preparing Data for BY-Group Processing Chapter 7

Required Arguments

variable
specifies the variable that the procedure uses to form BY groups. You can specify
more than one variable. By default, the procedure expects observations in the data
set to be sorted in ascending order by all the variables that you specify or to be
indexed appropriately.

Options

DESCENDING
indicates that the data set is sorted in descending order by the specified variable.
The option affects only the variable that immediately follows the option name, and
must be repeated before every variable that is not sorted in ascending order. For
example, this BY statement indicates that observations in the input data set are
arranged in descending order of VAR1 values and ascending order of VAR2 values:
by descending var1 var2;

This BY statement indicates that the input data set is sorted in descending
order of both VAR1 and VAR2 values:
by descending var1 descending var2;

NOTSORTED
specifies that observations with the same BY value are grouped together, but are
not necessarily sorted in alphabetical or numeric order. The observations can be
grouped in another way, for example, in chronological order.
NOTSORTED can appear anywhere in the BY statement and affects all
variables specified in the statement. NOTSORTED overrides DESCENDING if
both appear in the same BY statement.
The requirement for ordering or indexing observations according to the values
of BY variables is suspended when you use the NOTSORTED option. In fact, the
procedure does not use an index if you specify NOTSORTED. For NOTSORTED,
the procedure defines a BY group as a set of contiguous observations that have the
same values for all BY variables. If observations with the same value for the BY
variables are not contiguous, the procedure treats each new value it encounters as
the first observation in a new BY group and will create a graph for that value,
even if it is only one observation.

Preparing Data for BY-Group Processing


Unless you specify the NOTSORTED option, observations in the input data set must
be in ascending numeric or alphabetic order. To prepare the data set, either sort it with
the SORT procedure using the same BY statement that you plan to use in the target
SAS/GRAPH procedure or create an appropriate index on the BY variables.
If the procedure encounters an observation is out of the proper order, it issues an
error message.
If you need to group data in some other order, such as chronological order, you can
still use BY-group processing. To do so, process the data so that observations are
arranged in contiguous groups that have the same BY-variable values and specify the
NOTSORTED option in the BY statement.
For an example of sorting the input data set, see “Example 7. Using BY-group
Processing to Generate a Series of Charts” on page 240 .
SAS/GRAPH Statements Using the BY Statement 143

Controlling BY Lines
By default, the BY statement prints a BY line above each graph that contains the
variable name followed by an equal sign and the variable value. For example, if you
specify BY SITE in the procedure, the default heading when the value of SITE is
London would be SITE=London.

Suppressing the BY line


To suppress the entire BY line, use the NOBYLINE option in an OPTION statement
or specify HBY=0 in the GOPTIONS statement. See “Example 7. Using BY-group
Processing to Generate a Series of Charts” on page 240.

Suppressing the name of the BY variable


To suppress the variable name and the equal sign in the heading and leave only the
BY value, use the LABEL statement to assign a null label (’00’X) to the BY variable.
For example, this statement assigns a null label to the SITE variable:
label site=’00’x;

See also GCHLEGNDExample 12 on page 877.

Controlling the appearance of the BY line


To control the color, font, and height of the BY lines, use the following graphics
options in a GOPTIONS statement:
CBY=BY-line-color
specifies the color for BY lines.
FBY=font
specifies the font for BY lines.
HBY=n<units>
specifies the height for BY lines.
See Chapter 8, “Graphics Options and Device Parameters Dictionary,” on page 261
for a complete description of each option.

Naming the Catalog Entries


The catalog entries generated with BY-group processing always use incremental
naming. This means that the first entry created by the procedure uses the base name
and subsequent entries increment that name. The base name is either the default entry
name for the procedure (for example, GPLOT) or the name specified with the NAME=
option in the action statement. Incrementing the base name automatically appends a
number to each subsequent entry (for example, GPLOT1, GPLOT2, and so forth). See
also “Names and Descriptions of Catalog Entries” on page 55 and “Using the default
output name” on page 63. For an example of incremented catalog names, see “Example
9. Combining Graphs and Reports in a Web Page” on page 248.

Using the BY Statement


This section describes the following:
144 Using the BY Statement Chapter 7

3 the effect of BY-group processing on the GCHART, GMAP, and GPLOT procedures
3 the interaction between BY-group and RUN-group processing
3 the requirements for using BY-group processing with the Annotate facility
3 how to include BY information in titles, notes, and footnotes
3 how patterns and symbols are assigned to BY-groups
3 the effect of using BY-group processing with the ODS HTML statement.
For additional information on any of these topics, refer to the appropriate chapter.

With the GCHART Procedure


When you use BY-group processing with the GCHART procedure, you can do the
following:
3 With the BLOCK, HBAR, and VBAR statements, you can use the
PATTERNID=BY option to assign patterns according to BY groups. With
PATTERNID=BY, each BY group uses a different PATTERN definition, but all
bars or blocks within a BY group use the same pattern.
3 With the BLOCK statement, you can use the BLOCKMAX= option to produce the
same block-height scaling in all block charts in a BY group.
3 With the HBAR or VBAR statement, you can use the RAXIS= option to produce the
same response axis scaling in all horizontal or vertical bar charts in a BY group.
With the PIE and STAR statements, the effect of a BY statement is similar to that of
the GROUP= option, except that the GROUP= option allows you to put more than one
graph on a single page while the BY statement does not. Do not use a BY variable as
the group variable in STAR or PIE statements.

With the GMAP Procedure


By default, BY-group processing affects both the map data set and the response data
set. This means that you get separate, individual output for each map area common to
both data sets. For example, if the map data set REGION contains six states and the
response data set contains the same six states, and you specify BY STATE in the GMAP
procedure, you get six graphs with one state on each graph.
If you use the ALL option in the PROC GMAP statement and you also use the BY
statement, you get one output for each map area in the response data set, but that
output displays all the map areas in the map data set. Only one map area per output
contains response data information; the others are empty. For example, if you create a
block map using the data sets REGION and SALES, specify BY STATE, and include the
ALL option in the PROC GMAP statement, you get six graphs with six states on each
graph. One state per graph has a block; the remaining five are empty.

With the GPLOT Procedure


You can use the UNIFORM option in the PROC GPLOT statement to produce the
same axis scaling for all graphs in a BY group. By default, the range of the axes may
vary from graph to graph, but UNIFORM forces the scaling to be the same for all
graphs generated by the procedure.

With the RUN Groups


If you use the BY statement with a procedure that processes data and supports
RUN-group processing (the GCHART, GMAP, and GPLOT procedures), then each time
you submit an action statement or a RUN statement you get a separate graph for each
SAS/GRAPH Statements Using the BY Statement 145

value of the BY variable. For example, each of these two RUN-groups produces a
separate plot for every value of the BY variable SITE:
/* first run group*/
proc gplot data=sales;
title1 ’Sales Summary’;
by site;
plot sales*model_a;
run;

/* second run group */


plot sales*model_b;
run;
quit;

The BY statement stays in effect for every subsequent RUN group until you submit
another BY statement or exit the procedure. Variables in subsequent BY statements
replace any previous BY variables.
You can also turn off BY-group processing by submitting a null BY statement (BY;) in
a RUN group, but when you do this, the null BY statement turns off BY-group
processing and the RUN group generates a graph.
For more information, see “RUN-Group Processing” on page 33.

With the Annotate Facility


If a procedure that is using BY-group processing also specifies annotation with the
ANNOTATE= option in the PROC statement, the same annotation is applied to every
graph generated by the procedure.
If you specify annotation with the ANNOTATE= option in the action statements for a
procedure, the BY-group processing is applied to the Annotate data set. In this way,
you can customize the annotation for the output from each BY group by including the
BY variable in the Annotate data set and by using each BY-variable value as a
condition for the annotation to be applied to the output for that value.

With TITLE, FOOTNOTE, and NOTE Statements


TITLE, FOOTNOTE, and NOTE statements can automatically include the BY
variable name, BY variable values, or BY lines in the text they produce. To insert BY
variable information into the text strings used by these statements, use the #BYVAR,
#BYVAL, and #BYLINE substitution options. For details, see the description of the
text-string argument on page 222. For an example, see “Example 7. Using BY-group
Processing to Generate a Series of Charts” on page 240.

With PATTERN and SYMBOL Definitions


Procedures that use SYMBOL or PATTERN definitions, assign the symbols or
patterns in order to each BY group. For example, if the BY variable REGION has four
values – East, North, South, and West – the patterns are assigned to the BY-groups in
this order:
PATTERN1 is assigned to East,
PATTERN2 is assigned to North,
PATTERN3 is assigned to South,
PATTERN4 is assigned to West.
If you create sets of graphs from several data sets containing the variable REGION,
and if you want the same pattern assigned to the same region each time, you must be
146 FOOTNOTE Statement Chapter 7

sure that REGION always has the same four values. Otherwise, the patterns may not
be the same across graphs. For example, if the value North is missing from the data,
the patterns are assigned as follows:
PATTERN1 is assigned to East,
PATTERN2 is assigned to South,
PATTERN3 is assigned to West.
In this case, South is assigned pattern 2 instead of pattern 3 and West is assigned
pattern 3 instead of pattern 4. To avoid this, include the value North for the variable
REGION, but assign it a missing value for all other variables.

FOOTNOTE Statement
See “TITLE, FOOTNOTE, and NOTE Statements” on page 210.

GOPTIONS Statement
The GOPTIONS statement temporarily sets default values for many graphics
attributes and device parameters used by SAS/GRAPH procedures.
Used by:
all statements and procedures in a SAS session

Description
The GOPTIONS statement specifies values for graphics options. Graphics options
control characteristics of the graph, such as size, colors, type fonts, fill patterns, and
symbols. In addition, they affect the settings of device parameters, which are defined in
the device entry. Device parameters control such characteristics as the appearance of
the display, the type of output produced, and the destination of the output.
The GOPTIONS statement allows you to change these settings temporarily, either for
a single graph or for the duration of your SAS session. You can use the GOPTIONS
statement to
3 override default values for graphics options that control either graphics attributes
or device parameters for a single graph or for an entire SAS session
3 reset individual graphics options or all graphics options to their default values
3 cancel definitions for AXIS, FOOTNOTE, PATTERN, SYMBOL, and TITLE
statements.
To change device parameters permanently, you must use the GDEVICE procedure to
modify the appropriate device entry or to create a new one. See Chapter 31, “The
GDEVICE Procedure,” on page 915 for details.
To review the current settings of all graphics options, use the GOPTIONS procedure.
See Chapter 36, “The GOPTIONS Procedure,” on page 1075 for details.

Syntax
GOPTIONS<options-list>;
options-list can be one or more options from any or all of the following categories:
3 reset option
SAS/GRAPH Statements GOPTIONS Statement 147

RESET=ALL | GLOBAL | statement-name | (statement-name(s))


3 options that affect the appearance of the display area and the graphics output
ASPECT=scaling-factor
AUTOSIZE=ON | OFF | DEFAULT
BORDER | NOBORDER
CELL | NOCELL
GSIZE=lines
HORIGIN=horizontal-offset <IN | CM>
HPOS=columns
HSIZE=horizontal-size <IN | CM>
IBACK= fileref | ’external-file’
IMAGESTYLE = TILE | FIT
IMAGEPRINT | NOIMAGEPRINT
ROTATE=LANDSCAPE | PORTRAIT
ROTATE | NOROTATE
SWAP | NOSWAP
TARGETDEVICE=target-device-entry
VORIGIN=vertical-offset <IN | CM>
VPOS=rows
VSIZE=vertical-size <IN | CM>
XMAX=width <IN | CM>
XPIXELS=width-in-pixels
YMAX=height <IN | CM>
YPIXELS=height-in-pixels
3 options that affect color
CBACK=background-color
CBY=BY-line-color
COLORS=<(colors-list | NONE)>
CPATTERN=pattern-color
CSYMBOL=symbol-color
CTEXT=text-color
CTITLE=title-color
PENMOUNTS=active-pen-mounts
PENSORT | NOPENSORT
3 options that control font selection or text appearance
CHARTYPE=hardware-font-chartype
FASTTEXT | NOFASTTEXT
FBY=BY-line-font
FCACHE=number-fonts-open
FONTRES=NORMAL | PRESENTATION
FTEXT=text-font
FTITLE=title-font
FTRACK=LOOSE | NONE | NORMAL | TIGHT | TOUCH | V5
HBY=BY-line-height <units>
HTEXT=text-height <units>
148 GOPTIONS Statement Chapter 7

HTITLE=title-height <units>
RENDER=APPEND | DISK | MEMORY | NONE | READ
RENDERLIB=libref
SIMFONT=software-font
3 options that set defaults for procedures and global statements
GUNIT=units
INTERPOL=interpolation-method
OFFSHADOW=(x <units>, y <units> | (x,y) <units>
V6COMP | NOV6COMP
3 image animation options
DELAY=delay-time
DISPOSAL=NONE | BACKGROUND | PREVIOUS | UNSPECIFIED
INTERLACED | NONINTERLACED
ITERATION=iteration-count
TRANSPARENCY | NOTRANSPARENCY
3 options that affect how your SAS/GRAPH program runs
DISPLAY | NODISPLAY
ERASE | NOERASE
GWAIT=seconds
GRAPHRC | NOGRAPHRC
IMAGEPRINT | NOIMAGEPRINT
PCLIP | NOPCLIP
POLYGONCLIP | NOPOLYGONCLIP
3 options that control how output is sent to devices or files
ADMGDF | NOADMGDF
DEVADDR=device-address
DEVICE=device-entry
DEVMAP=device-map-name | NONE
EXTENSION=’file-type’
FILECLOSE=DRIVERTERM | GRAPHEND
FILEONLY | NOFILEONLY
GACCESS=output-format | ’output-format > destination’
GEND=’string’ <...’string-n’>
GEPILOG=’string’ <...’string-n’>
GOUTMODE=APPEND | REPLACE
GPROLOG=’string’ <...’string-n’>
GPROTOCOL=module-name
GSFLEN=record-length
GSFMODE=APPEND | PORT | REPLACE
GSFNAME=fileref
GSFPROMPT | NOGSFPROMPT
GSTART=’string’ <...’string-n’>
HANDSHAKE=HARDWARE | NONE | SOFTWARE | XONXOFF
KEYMAP=map-name | NONE
POSTGEPILOG=’string’
SAS/GRAPH Statements GOPTIONS Statement 149

POSTGPROLOG=’string’
PREGEPILOG=’string’
PREGPROLOG=’string’
PROMPTCHARS=’prompt-chars-hex-string’X
3 options that specify hardware capabilities of the device
CHARACTERS | NOCHARACTERS
CIRCLEARC | NOCIRCLEARC
DASH | NODASH
DASHSCALE=scaling-factor
FILL | NOFILL
FILLINC=0...9999
LFACTOR=line-thickness-factor
PIEFILL | NOPIEFILL
POLYGONFILL | NOPOLYGONFILL
SYMBOL | NOSYMBOL
3 options that control printer hardware features
AUTOCOPY | NOAUTOCOPY
AUTOFEED | NOAUTOFEED
BINDING=DEFAULTEDGE | LONGEDGE | SHORTEDGE
COLLATE | NOCOLLATE
DUPLEX | NODUPLEX
GCOPIES=(<current-copies><,max-copies>)
PAPERDEST=bin
PAPERFEED=feed-increment <IN | CM>
PAPERLIMIT=width <IN | CM>
PAPERSIZE=’size-name’ | (width,height)
PAPERSOURCE=tray
PAPERTYPE=’type-name’
PPDFILE=fileref | ’external-file’
REPAINT=redraw-factor
REVERSE | NOREVERSE
SPEED=pen-speed
UCC=’control-characters-hex-string’X
3 options that interact with the operating environment
DRVINIT=’system-command(s)’
DRVTERM=’system-command(s)’
PREGRAPH=’system-command(s)’
POSTGRAPH=’system-command(s)’
PROMPT | NOPROMPT
3 options for mainframe systems
GCLASS=SYSOUT-class
GDDMCOPY=FSCOPY | GSCOPY
GDDMNICKNAME=nickname
GDDMTOKEN=token
GDEST=destination
150 Using the GOPTIONS Statement Chapter 7

GFORMS=’forms-code’
GWRITER=’writer-name’
TRANTAB=table | user-defined-table

Options
See Chapter 8, “Graphics Options and Device Parameters Dictionary,” on page 261
for a complete description of all graphics options used by the GOPTIONS statement.

Using the GOPTIONS Statement


GOPTIONS statements are global and can be located anywhere in your SAS
program. However, for the graphics options to affect the output from a procedure, the
GOPTIONS statement must execute before the procedure.
With the exception of RESET=, graphics options can be listed in any order in a
GOPTIONS statement. RESET= should be the first option in the GOPTIONS statement.
A graphics option remains in effect until you either specify the option in another
GOPTIONS statement, or use RESET= to reset the values, or end the SAS session.
When a session ends, the values of the graphics options return to their default values.
Graphics options are additive; that is, the value of a graphics option remains in effect
until the graphics option is explicitly changed or reset or until you end your SAS
session. Graphics options remain in effect even after you submit additional GOPTIONS
statements specifying different options.
To reset an individual option to its default value, submit the option without a value
(a null graphics option.) You can use a comma (but it is not required) to separate a null
graphics option from the next one. For example, this GOPTIONS statement sets the
values for background color, text height, and text font:
goptions cback=blue htext=6 pct ftext=zapf;

To reset only the background color specification to the default and keep the
remaining values, use this GOPTIONS statement:
goptions cback=;

To reset all graphic options to their default values, specify RESET=GOPTIONS:


goptions reset=goptions;

Alternatively, you can use RESET=ALL, but it also cancels any global statement
definitions in addition to resetting all graphics options to default values.

Graphics Option Processing


You can control many graphics attributes through statement options, graphics
options, device parameters, or a combination of these. SAS/GRAPH searches these
places to determine the value to use, stopping at the first place that gives it an explicit
value:
1 statement options
2 the value of the corresponding graphics option
3 the value of a device parameter found in the catalog entry for your device driver.

Note: Not every graphics attribute can be set in all three places. See the statement
and procedure chapters for the options that can be used with each. 4
SAS/GRAPH Statements LEGEND Statement 151

Some graphics options are supported for specific devices or operating environments
only. See the SAS Help facility for SAS/GRAPH or the SAS companion for your
operating environment for more information.

LEGEND Statement
The LEGEND statement controls the location and appearance of legends on
two-dimensional plots, contour plots, maps, and charts.
Used by:
GCHART, GCONTOUR, GMAP, GPLOT procedures
Global

Description
LEGEND statements specify the characteristics of a legend but do not create
legends. These characteristics are
3 the position and appearance of the legend box
3 the text and appearance of the legend label
3 the appearance of the legend entries, including the size and shape of the legend
values
3 the text of the labels for the legend values.
LEGEND definitions are not automatically applied when a procedure generates a
legend. Instead, they must be explicitly assigned with a LEGEND= option in the
appropriate procedure statement.
illustrates the terms associated with the various parts of a legend.

Figure 7.5 Parts of a Legend

legend legend legend


label value entry
Department Parts Repairs Tools
origin legend legend value
offset frame description
border of graph

Syntax
LEGEND<1...99>< options>;
option(s) can be one or more options from any or all of the following categories:
3 appearance options
ACROSS=number-of-columns
CBLOCK=block-color
CBORDER=frame-color
CFRAME=background-color
CSHADOW=shadow-color
DOWN=number-of-rows
FRAME
152 LEGEND Statement Chapter 7

FWIDTH=thickness-factor
SHAPE=BAR(width,height) <units> | LINE(length) <units> |
SYMBOL(width,height) <units>
3 position-options
MODE=PROTECT | RESERVE | SHARE
OFFSET=(<x ><,y >)<units > | (<x <units >><,y <units >>)
ORIGIN=(<x ><,y >)<units > | (<x <units >><,y <units >>)
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER | RIGHT>
<INSIDE | OUTSIDE>)
3 text-options
LABEL=(text-argument(s)) | NONE
ORDER=(value-list)
VALUE=(text-argument(s)) | NONE

Options
When the syntax of an option includes units, use one of these:
CELLS character cells
CM centimeters
IN inches
PT points
PCT percentage of the graphics output area
Note: The Java applet does not support CM, IN, or PT. 4
If you omit units, a unit specification is searched for in this order:
1 GUNIT= in a GOPTIONS statement
2 the default unit, CELLS.

ACROSS=number-of-columns
specifies the number of columns to use for legend entries.
Featured in: “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245.
CBLOCK=block-color
generates and colors a three-dimensional block effect behind the legend. The size
and position of the block are controlled by the graphics option OFFSHADOW=(x,y).
CBLOCK= and CSHADOW= are mutually exclusive. If both are present,
SAS/GRAPH software uses the last one specified. CBLOCK= is usually used in
conjunction with the FRAME, CFRAME=, or CBORDER= options.
The Java client treats the CBLOCK option like CSHADOW.
See also: the OFFSHADOW=“OFFSHADOW” on page 325 graphics option and
“Creating Drop Shadows and Block Effects” on page 163.
Not supported by: Java
CBORDER=frame-color
draws a colored frame around the legend. This option overrides the FRAME
option. CBORDER= can be used in conjunction with the CFRAME= option.
CFRAME=background-color
SAS/GRAPH Statements LEGEND Statement 153

specifies the background color of the legend. This option overrides the FRAME
option. If both CFRAME= and FRAME= are specified, only the solid background
produced by CFRAME= is displayed. CFRAME= can be used in conjunction with
the CBORDER= option.
CSHADOW=shadow-color
generates and colors a drop shadow behind the legend. The size and position of
the shadow is controlled by the graphics option OFFSHADOW=(x,y).
CSHADOW= and CBLOCK= are mutually exclusive. If both are present,
SAS/GRAPH uses the last one specified. CSHADOW= is usually specified in
conjunction with the FRAME, CFRAME=, or CBORDER= options.
See also: the OFFSHADOW=“OFFSHADOW” on page 325 graphics option and
“Creating Drop Shadows and Block Effects” on page 163.
DOWN=number-of-rows
specifies the number of rows to use for legend entries.
FRAME
draws a frame around the legend. The color of the frame is the first color in the
colors list.
FWIDTH=thickness-factor
specifies the thickness of the frame, where thickness-factor is a number. The
thickness of the line increases directly with thickness-factor. By default,
FWIDTH=1.
Not supported by: Java, ActiveX
LABEL=(text-argument(s)) | NONE
modifies a legend label. Text-argument(s) defines the appearance or the text of a
legend label, or both. NONE suppresses the legend label. By default, the text of
the legend label is either the variable name or a previously assigned variable label
(except in the case of GPLOT with OVERLAY, in which case the default label is
“PLOT”). Text-argument(s) can be one or more of these:
‘text-string’
provides up to 256 characters of label text. Enclose each string in quotes.
Separate multiple strings with blanks.
text-description-suboption
modifies a characteristic such as the font, color, or size of the text string(s)
that follows it. Text-description-suboption can be
COLOR=text-color
FONT=font | NONE
HEIGHT=text-height <units>
JUSTIFY=LEFT | CENTER | RIGHT
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER |
RIGHT>)
Note: The Java applet does not support the POSITION suboption—it
draws legend labels at the top-left of the legend. And, it does not support
multiple values for the JUSTIFY suboption (only the first is honored). The
ActiveX control supports POSITION= but does not support multiple values
for the JUSTIFY suboption (only the first is honored). 4
See “Text Description Suboptions” on page 158 for complete descriptions.
Specify as many text strings and text description suboptions as you want, but
enclose them all in one set of parentheses.
154 LEGEND Statement Chapter 7

Featured in: “Example 3. Rotating Plot Symbols through the Colors List” on
page 231 and “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245
Not supported by: Java (partial), ActiveX (partial)
MODE=PROTECT | RESERVE | SHARE
specifies whether or not the legend is drawn in the procedure output area or
whether legend elements can overlay other graphics elements. MODE= can take
one of these values:
PROTECT draws the legend in the procedure output area, but a blanking
area surrounds the legend, preventing other graphics elements
from being displayed in the legend. (A blanking area is a
protected area in which no other graphics elements are
displayed.)
RESERVE takes space for the legend from the procedure output area,
thereby reducing the amount of space available for the graph.
If MODE=RESERVE is specified in conjunction with
OFFSET=, the legend may push the graph off the graphics
output area. RESERVE is valid only when
POSITION=OUTSIDE. If POSITION=INSIDE is specified, a
warning is issued and MODE= is changed to PROTECT.
SHARE draws the legend in the procedure output area. If the legend is
positioned over elements of the graph itself, both graphics
elements and legend elements are displayed.
By default, MODE=RESERVE unless POSITION=INSIDE, in which case the
default changes to MODE=PROTECT.
See also: “Positioning the Legend” on page 162
Featured in: “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245.
Not supported by: Java, ActiveX
OFFSET=(<x><,y>)<units> | (<x <units>><,y <units>>)
specifies the distance to move the entire legend; x is the number of units to move
the legend right (positive numbers) or left (negative numbers), and y is the number
of units to move the legend up (positive numbers) or down (negative numbers).
To set only the x offset, specify one value, with or without a following comma:
offset=(4 cm,)

To set both the x and y offset, specify two values, with or without a comma
separating them:
offset=(2 pct, 4 pct)

To set only the y offset, specify one value preceded by a comma:


offset=(,-3 pct)

OFFSET= is usually used in conjunction with POSITION= to adjust the position


of the legend. Moves are relative to the location specified by POSITION=, with
OFFSET=(0,0) representing the initial position. You can also apply OFFSET= to
the default legend position.
OFFSET= is unnecessary with ORIGIN= since ORIGIN= explicitly positions the
legend and requires no further adjustment. However, if you specify both options,
the values of OFFSET= are added to the values of ORIGIN=, and the LEGEND is
positioned accordingly.
SAS/GRAPH Statements LEGEND Statement 155

See also: “Positioning the Legend” on page 162 and the option POSITION= on
page 155
Not supported by: Java, ActiveX
ORDER=(value-list)
selects or orders the legend values that appear in the legend. The way you specify
value-list depends on the type of variable that generates the legend:
3 For numeric variables, value-list is either an explicit list of values, or a
starting and an ending value with an interval increment, or a combination of
both forms:
n <...n>
n TO n <BY increment>
n <...n> TO n <BY increment> <n <...n>>
If a numeric variable has an associated format, the specified values must
be the unformatted values.
3 For character variables, value-list is a list of unique character values enclosed
in quotes and separated by blanks:
’value-1’ <...’value-n’>
If a character variable has an associated format, the specified values must
be the formatted values.
For a complete description of value-list, see the option ORDER= on page 130 in
the AXIS statement.
Even though ORDER= controls whether a legend value is displayed and where
it appears, the VALUE= option controls the text that the legend value displays.
Not supported by: ActiveX, Java
ORIGIN=(<x><,y>)<units> | (<x <units >><,y <units>>)
specifies the x coordinate and the y coordinate of the lower-left corner of the legend
box. ORIGIN= explicitly positions the legend anywhere on the graphics output
area. It is possible to run a legend off the page or overlay the graph.
To set only the x coordinate, specify one value, with or without a following
comma:
origin=(4 cm,)

To set both the x and y coordinates, specify two values, with or without a comma
separating them:
origin=(2 pct, 4 pct)

To set only the y coordinate, specify one value preceded by a comma:


origin=(,3 pct)

ORIGIN= overrides the POSITION= option if both are used. Although using the
OFFSET= option with the ORIGIN= option is unnecessary, if OFFSET= is also
specified, it is applied after the ORIGIN= request has been processed.
See also: “Positioning the Legend” on page 162
Featured in: “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245 .
Not supported by: Java, ActiveX
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER | RIGHT>
<OUTSIDE | INSIDE>)
positions the legend on the graph. Value for POSITION= are
156 LEGEND Statement Chapter 7

OUTSIDE or specifies the location of the legend in relation to the axis area.
INSIDE
BOTTOM or specifies the vertical position.
MIDDLE or
TOP
LEFT or specifies the horizontal position.
CENTER or
RIGHT
By default, POSITION=(BOTTOM CENTER OUTSIDE). You can change one or
more settings. If you supply only one value the parentheses are not required. If
you specify two or three values and omit the parentheses, SAS/GRAPH accepts the
first value and ignores the others.
Once you assign the initial legend position, you can adjust it with the OFFSET=
option.
The ORIGIN= options overrides POSITION=. The value of the MODE= option
can affect the behavior of POSITION=.

Note: The Java applet defaults to BOTTOM-CENTER and supports all


possible combinations of BOTTOM | MIDDLE | TOP with LEFT | CENTER |
RIGHT except for MIDDLE-CENTER (which would overwrite the map.) The Java
applet does not support INSIDE for positioning. 4
See also: information on positioning the Legend in the SAS/GRAPH Reference,
Volumes 1 and 2, the options OFFSET= on page 154, andMODE= on page 154.
Not supported by: Java (partial)
SHAPE=BAR(width<units>,height<units>) <units> | LINE(length) <units> |
SYMBOL(width<units>,height<units>) <units>
specifies the size and shape of the legend values displayed in each legend entry.
The value you specify for SHAPE= depends on which procedure generates the
legend.
BAR(width,height)<units>
is used with the GCHART and GMAP procedures, the GPLOT procedure if
you use the AREAS= option, and the GCONTOUR procedure if you use the
PATTERN option. Each legend value is a bar of the specified width and
height. By default, width is 5, height is 0.8, and units are CELLS. You can
specify units for the width,height pair or for the individual coordinates.
Featured in: “Example 3. Rotating Plot Symbols through the Colors List” on
page 231 and “Example 8. Creating a Simple Web Page with the ODS
HTML Statement” on page 245.
LINE(length) <units>
is used with the GPLOT and GCONTOUR procedures. Each legend value is a
line of the length you specify. Plotting symbols are omitted from the legend
values. By default, length is 5 and units are CELLS. You can specify units for
length.
SYMBOL(width<units>,height<units>) <units>
is used with the GPLOT procedure. Each legend value (not each symbol) is
the width and height you specify. For example, this specification produces
legend values like the ones in Figure 7.6 on page 157(a):
shape=symbol(.5,.5)

This specification produces legend values like the ones in Figure 7.6 on
page 157(b):
SAS/GRAPH Statements LEGEND Statement 157

shape=symbol(2,.5)

Figure 7.6 Legend Values Produced with SHAPE= SYMBOL

Minn Minn
CITY
CITY CITY
CITY

Phoenix Phoenix

Raleigh Raleigh

a. b.

By default, width is 5, height is 1, and units are CELLS. You can specify
units for the width,height pair or for the individual coordinates.
Featured in: “Example 3. Rotating Plot Symbols through the Colors List” on
page 231.
Not supported by: Java, ActiveX
VALUE=(text-argument(s) )| NONE
modifies the legend value descriptions. Text-argument(s) defines the appearance or
the text of the value descriptions. By default, value descriptions are the values of
the variable that generates the legend or an associated format value. Numeric
values are right justified and character values are left justified.
NONE suppresses the value descriptions although the legend values (bars,
lines, and so on) are still displayed. (NONE is not supported by Java or ActiveX).
Text-argument(s) can be one or more of these:
‘text-string’
provides up to 256 characters of text for the value description. Enclose each
string in quotes. Separate multiple strings with blanks.
Specified text strings are assigned to the legend values in order. If you
submit only one string, only the first legend entry uses the value of that
string. If you specify multiple strings, the first string is the text for the first
entry; the second string is the text for the second entry; and so forth. For
example, this specification produces legend entries like those shown in Figure
7.7 on page 157:
value=(’1986’ ’1987’ ’1988’)

Figure 7.7 Specifying Value Descriptions with the VALUE= Option

Year 1986 1987 1988

text-description-suboption
modifies a characteristic such as the font, color, or size of the text string(s)
that follows it. Text-description-suboption can be
158 LEGEND Statement Chapter 7

COLOR=text-color
FONT=font | NONE
HEIGHT=text-height <units >
JUSTIFY=LEFT | CENTER | RIGHT
TICK=n (not supported by Java or ActiveX)
See “Text Description Suboptions” on page 158 for complete descriptions.
Place text description suboptions before the text strings they modify.
Suboptions not followed by a text string affect the default values. To specify
and describe the text for individual values or to produce multi-line text, use
the TICK= suboption.
Specify as many text strings and text description suboptions as you want, but
enclose them all in one set of parentheses.
To order or select legend entries, use the ORDER= option.
See also: “Text Description Suboptions” on page 158 and the option ORDER= on
page 155
Not supported by: Java (partial), ActiveX (partial)

Text Description Suboptions


Text description suboptions are used by the LABEL= and VALUE= options to change
the color, height, justification, font, and angle of either default text or specified text
strings. See LABEL= on page 153 and VALUE= on page 157.
COLOR=text-color
C=text-color
specifies the color of the text. If you omit COLOR=, a color specification is
searched for in this order:
1 the CTEXT= option for the procedure
2 the CTEXT= option in a GOPTIONS statement
3 the default, the first color in the colors list.

FONT=font | NONE
F=font | NONE
specifies the font for the text. See Chapter 5, “SAS/GRAPH Fonts,” on page 75for
information on specifying fonts. If you omit FONT=, a font specification is
searched for in this order:
1 the FTEXT= option in a GOPTIONS statement
2 the default hardware font, NONE.

HEIGHT=text-height <units>
H=text-height <units>
specifies the height of the text characters in the number of units. By default,
HEIGHT=1 CELL. If you omit HEIGHT=, a text height specification is searched
for in this order:
1 the HTEXT= option in a GOPTIONS statement
2 the default value, 1.

JUSTIFY=LEFT | CENTER | RIGHT


J=L | C | R
specifies the alignment of the text. The default for character variables is
JUSTIFY=LEFT. The default for numeric variables is JUSTIFY=RIGHT.
Associating a character format with a numeric variable does not change the
default justification of the variable.
SAS/GRAPH Statements LEGEND Statement 159

You can use JUSTIFY= to print multiple lines of text by repeating JUSTIFY=
before the text string for each line. For example, this statement produces a legend
label and value descriptions like those shown in Figure 7.8 on page 159:
legend label=(justify=c ’Distribution’
justify=c ’Centers’)
value=(tick=1 justify=c ’Portland,’
justify=c ’Maine’
tick=2 justify=c ’Paris,’
justify=c ’France’
tick=3 justify=c ’Sydney,’
justify=c ’Australia’);

Figure 7.8 Specifying Multiple Lines of Text with the JUSTIFY= Suboption

Distribution Portland, Paris, Sydney,


Centers Main France Australia

Specify additional suboptions before any string.


See also: the suboption TICK= on page 160.
POSITION=(<BOTTOM | MIDDLE | TOP> <LEFT | CENTER | RIGHT>)
places the legend label in relation to the legend entries. The POSITION=
suboption is used only with the LABEL= option. By default, POSITION=LEFT.
The parentheses are not required if only one value is supplied. If you specify
two or three values and omit the parentheses, SAS/GRAPH accepts the first value
and ignores the others.
Figure 7.9 on page 160 shows some of the ways POSITION= affects a multi-line
legend label in which the entries are stacked in a column (ACROSS=1). This
figure uses a label specification such as
label=(’multi-’
justify=left ’line’
justify=left ’label’
position=left)

In this specification, POSITION= specifies the default value, LEFT, which is


represented by the first legend in the figure. The value of POSITION= is indicated
above each legend. The default justification is used unless you also use the
JUSTIFY= suboption.
160 LEGEND Statement Chapter 7

Figure 7.9 Using the POSITION= Suboption with Multi-line Legend Labels

POSITION=LEFT POSITION=(TOP)
(default) JUSTIFY=CENTER
multi-
multi- line
line label
label + + + ONE
● ● ● TWO + + + ONE
x x x THREE ● ● ● TWO
# # # FOUR x x x THREE
$ $ $ FIVE # # # FOUR
$ $ $ FIVE

POSITION=(TOP LEFT)
POSITION=TOP
multi- + + + ONE JUSTIFY=LEFT
line ● ● ● TWO
label x x x THREE multi-
# # # FOUR line
$ $ $ FIVE label
+ + + ONE
● ● ● TWO
x x x THREE
POSITION=(MIDDLE LEFT) # # # FOUR
$ $ $ FIVE
+ + + ONE
multi- ● ● ● TWO
line x x x THREE
label # # # FOUR POSITION=TOP
$ $ $ FIVE JUSTIFY=RIGHT

multi-
POSITION=(BOTTOM LEFT) line
label
+ + + ONE + + + ONE
● ● ● TWO ● ● ● TWO
multi- x x x THREE x x x THREE
line # # # FOUR # # # FOUR
label $ $ $ FIVE $ $ $ FIVE

In addition, specifying POSITION=RIGHT mirrors the effect of POSITION=LEFT,


and specifying POSITION=BOTTOM mirrors the effect of POSITION=TOP.
Not supported by: Java
TICK=n
T=n
specifies the nth legend entry. The TICK= suboption is used only with the
VALUE= option to designate the legend entry whose text and appearance you
want to modify. For example, to change the text of the third legend entry to
Minneapolis, specify
value=(tick=3 ’Minneapolis’)

The characteristics of all other value descriptions remain unchanged.


If you use TICK= when you designate text for one legend entry, you must also
use it when you designate text for any additional legend entries. For example, this
option changes the text of both the second and third legend entries:
SAS/GRAPH Statements Using the LEGEND Statement 161

value=(tick=2 ’Paris’ tick=3 ’Sydney’)

If you omitted TICK=3, the text of the second legend entry would be
ParisSydney.
Text description suboptions that precede TICK= affect all the value descriptions
for the legend unless the same suboption (with a different value) follows a TICK=
specification. Text description suboptions that follow TICK= affect only the
specified legend entry. For example, suppose you specify this option for a legend
with three entries:
value=(color=red font=swiss tick=2 color=blue)

The text of all three entries would use the Swiss font; the first and third entries
would be red and only the second entry would be blue.

Using Text Description Suboptions


Text description suboptions affect all the strings that follow them unless the
suboption is changed or turned off. If the value of a suboption is changed, the new
value affects all the text strings that follow it. Consider this example:
label=(font=swiss height=4 ’Weight’
justify=right height=3 ’(in tons)’)

FONT=SWISS applies to both Weight and (in tons). HEIGHT=4 affects Weight,
but is respecified as HEIGHT=3 for (in tons). JUSTIFY=RIGHT affects only (in
tons).

Using the LEGEND Statement


LEGEND statements can be located anywhere in your SAS program. They are global
and remain in effect until canceled or until you end your SAS session. LEGEND
statements are not applied automatically, and must be explicitly assigned by an option
in the procedure that uses them.
You can define up to 99 different LEGEND statements. If you define two LEGEND
statements of the same number, the most recently defined one replaces the previously
defined statement of the same number. A LEGEND statement without a number is
treated as a LEGEND1 statement.
Cancel individual LEGEND statements by defining a LEGEND statement of the
same number without options (a null statement):
legend4;

Canceling one LEGEND statement does not affect any other LEGEND definitions. To
cancel all current LEGEND statements, use RESET= in a GOPTIONS statement:
goptions reset=legend;

Specifying RESET=GLOBAL or RESET=ALL cancels all current LEGEND


definitions as well as other settings.
To display a list of current LEGEND definitions in the LOG window, use the
GOPTIONS procedure with the LEGEND option:
proc goptions legend nolist;
run;
162 Positioning the Legend Chapter 7

Positioning the Legend


By default, the legend shares the procedure output area with the procedure output,
such as a map or bar chart. (See “Placement of Graphic Elements in the Graphics
Output Area” on page 39.) However, several LEGEND statement options allow you to
position a legend anywhere on the graphics output area and even to overlay the
procedure output. This section describes these options and their effect on each other.

Positioning the Legend on the Graphics Output Area


There are two ways you can position the legend on the graphics output area:
3 Describe the general location of the legend with the POSITION= option. If
necessary, fine-tune the position with the OFFSET= option.
3 Position the legend explicitly with the ORIGIN=option.

Using POSITION= and OFFSET=


The values of the POSITION= option affect the legend in two ways:
3 OUTSIDE and INSIDE determine whether the legend is located outside or inside
the axis area.
3 BOTTOM or MIDDLE or TOP (vertical position) and LEFT or CENTER or RIGHT
(horizontal position) determine where the legend is located in relation to its
OUTSIDE or INSIDE position.
Figure 7.10 on page 162 shows the legend positions inside the axis area.

Figure 7.10 Legend Positions Inside the Axis Area

legend
axis positions

Figure 7.11 on page 162 shows legend positions outside the axis area.

Figure 7.11 Legend Positions Outside the Axis Area

legend axis frame


positions
axis area

The default combination is POSITION=(BOTTOM CENTER OUTSIDE). The


combination (OUTSIDE MIDDLE CENTER) is not valid.
SAS/GRAPH Statements Creating Drop Shadows and Block Effects 163

Use OFFSET=(x,y) to adjust the position of the legend specified by POSITION=. The
x value shifts the legend either left or right and the y value shifts the legend either up
or down.
The offset values are always applied after the POSITION= request. For example, if
POSITION=(TOP RIGHT OUTSIDE), the legend is located in the upper right corner of
the graphics output area. If OFFSET=(0,0) is specified, the legend does not move. If
OFFSET=(-5,-8)CM, the legend moves 5 centimeters to the left and 8 centimeters down.

Using ORIGIN=
Use ORIGIN=(x,y) to specify the coordinates of the exact location of the lower left
corner of the legend box. Because ORIGIN=(0,0) is the lower left corner of the graphics
output area, the values of x and y must be positive. If you specify negative values, a
warning is issued and the default value is used.

Relating Legends to Other Graphic Elements


By default, the legend is inside the procedure output area and the space it occupies
reduces the size of the graph itself. To control the way the legend relates to the other
elements of the graph, use the MODE= option. These are values for MODE=:
3 RESERVE reserve space for the legend outside the axis area and move the graph
to make room for the legend. This is the default setting and is valid only when
POSITION=OUTSIDE.
3 PROTECT prevents the legend from being overwritten by the procedure output.
PROTECT blanks out graphics elements, allowing only legend elements to be
displayed in the legend’s space.
3 SHARE displays both graphics elements and legend elements in the same space.
This setting is usually used when the legend is positioned inside the axis area.
SHARE is useful when the graph has a space that the legend can fit into. For an
example, see “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245.

Interactions Between POSITION= and MODE=


You cannot specify both POSITION=INSIDE and MODE=RESERVE because
MODE=RESERVE assumes the legend is outside the axis area, and
POSITION=INSIDE positions the legend inside the axis area. Therefore, when you
specify POSITION=INSIDE, change the value of MODE= to SHARE or PROTECT.
Otherwise, SAS/GRAPH issues a warning and automatically changes the value of
MODE= to PROTECT.

Creating Drop Shadows and Block Effects


To produce a drop shadow or a three-dimensional block effect behind the legend use
the CSHADOW= or CBLOCK= option in the LEGEND statement in conjunction with
the graphics option OFFSHADOW=(x,y).
The value of x determines how far the shadow or block extends to the right (positive
numbers) or to the left (negative numbers) of the legend. The value of y determines how
far the shadow or block extends above (positive numbers) or below (negative numbers)
the legend. If OFFSHADOW=(0,0) is specified, the shadow or block is not visible.
By default, OFFSHADOW=(0.0625, -0.0625) IN; that is, the shadow or block extends
1/16th of an inch to the right and 1/16th of an inch below the legend.
164 NOTE Statement Chapter 7

NOTE Statement
See “TITLE, FOOTNOTE, and NOTE Statements” on page 210.

ODS HTML Statement


The ODS HTML statement opens or closes the HTML destination.
Used by:
GANNO, GAREABAR, GBARLINE, GCHART, GCONTOUR, GFONT, GIMPORT,
GMAP, GPLOT, GPRINT, GRADAR, GREPLAY, GSLIDE, GTESTIT, G3D,
G3GRID procedures
Requirements:
If the HTML destination is open, the BODY= argument is required.
Operating Environment Information: On mainframes, either GPATH= or PATH=
is also required. 4

Description
This section describes the ODS HTML statement as it relates to SAS/GRAPH
procedures.
The ODS HTML statement opens or closes the HTML destination. If the destination
is open, it produces output that is written in Hyper Text Markup Language (HTML). If
DEVICE=GIF, graphics output is produced as GIF files, and the HTML files display the
GIF files that are created by the SAS/GRAPH procedures. If DEVICE=JAVAMETA,
graphics output is produced as metagraphics data, which provides graphs that are exact
replicas of their corresponding GRSEG graphs but that are interactive in a Web page.
Procedures GCHART, GCONTOUR, GMAP, GPLOT, and G3D can also be used with the
JAVA and ACTIVEX drivers, both of which generate JavaScript in the output HTML
file. If DEVICE=JAVA, then a Java-enabled browser can use the script to render graphs
as a SAS/GRAPH Applet for Java. If DEVICE=ACTIVEX, then an ActiveX-enabled
browser can use the script to render graphs as a SAS/GRAPH Control for ActiveX.

Syntax
ODS HTML HTML-file-specification(s) | action
<ANCHOR=’string’>
<ARCHIVE=’string’>
<ATTRIBUTES=(’attribute-name1’=’attribute-value-1’ ...
’attribute-name-n’=’attribute-value=n’)>
<CODEBASE=file-location <(URL=’Uniform-Resource-Locator’)>>
<BASE=’base-text’>
<GFOOTNOTE | NOGFOOTNOTE>
<GPATH=graphics-location <(URL=’Uniform-Resource-Locator’ | NONE )>>
<GTITLE | NOGTITLE>
<HEADTEXT=’HTML-for-document-head’>
<METATEXT=’HTML-for-document-head’>
<NEWFILE=starting-point>
<PARAMETERS=(’parameter-name1’=’parameter-value-1’ ...
’parameter-name-n’=’parameter-value=n’)>
<PATH=file-location <(URL=’Uniform-Resource-Locator’ | NONE )>>
SAS/GRAPH Statements ODS HTML Statement 165

<RECORD_SEPARATOR=’string’ | NONE>
<STYLE=style-definition>
<TRANTAB=’translation-table’>;

3 action can be one of


CLOSE
EXCLUDE
SELECT
SHOW
Note: For information on EXCLUDE, SELECT, and SHOW, see SAS Output
Delivery System: User’s Guide. 4
3 HTML-file-specification(s) can be one or more of
BODY=file-specification
CONTENTS=file-specification
FRAME=file-specification
PAGE=file-specification

Note: BODY= is required. If you use FRAME=, you must also use
CONTENTS= or PAGE=. 4

Required Arguments
One of these arguments is required.
CLOSE
closes the HTML destination and closes any HTML files that are currently open.
Featured in: “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245.
EXCLUDE
excludes output objects from the HTML destination.
SELECT
selects output objects to send to the HTML destination.
SHOW
writes to the SAS log the current selection or exclusion list for the HTML
destination.
HTML-file-specification
opens the HTML destination and specifies the HTML file or files to write to. You
can open up to four HTML files; the file designated by BODY= is required.
Whenever you open one of these files, it remains open until you either
3 close the HTML destination with ODS HTML CLOSE
3 open a different file for the same HTML file specification.
HTML-file-specification can be one or more of the following arguments. Values
for file-specification follow the arguments.
BODY=file-specification
FILE=file-specification
identifies the file that contains the HTML version of the procedure output.
With SAS/GRAPH, the body file contains references to the graphs. If
166 ODS HTML Statement Chapter 7

DEVICE=GIF, the graphs are stored in separate GIF files. When you view
the body file on a browser, the graphs are automatically displayed.
Featured in: “Example 8. Creating a Simple Web Page with the ODS HTML
Statement” on page 245 and “Example 10. Creating a Bar Chart with
Drill-down for the Web” on page 255.

CONTENTS=file-specification
identifies the file that contains a table of contents to the ODS output that is
produced while the HTML destination is open. The contents file contains
links to the body file(s).
The text of links to graphics output is taken from the description field of
the GRSEG catalog entry. Use the DESCRIPTION= option in the procedure
to change the link text.
You can display a contents file alone or in conjunction with a frame file. If
you display a contents file directly (without using a frame file), selecting a
link opens the associated body file, and the contents file is no longer
displayed. If you display a contents file with a frame file, the contents file
always remains available in the left frame, and selecting a link opens the
associated body file in the right frame.

FRAME=file-specification
identifies a file that points to the body file and to either the table of contents
file or the page file, or both. If you specify FRAME=, you must also specify
either CONTENTS= or PAGE= or both.
When you open the frame file in the browser, it displays the Table of
Contents or the Table of Pages or both in the left frame, and the body file in
the right frame.

PAGE=file-specification
identifies the file that contains a table of pages to the ODS output that is
produced while the HTML destination is open.The pages file contains links to
the body file(s). ODS produces a new page of output whenever a procedure
explicitly specifies for a new page. The SAS system option PAGESIZE= has
no effect on pages in HTML output.
File-specification identifies the file or SAS catalog to write to and can be one of
the following:
3 fileref (<URL=’Uniform-Resource-Locator’> <NO_BOTTOM_MATTER>
<NO_TOP_MATTER> <DYNAMIC>)
3 external-file (<URL=’Uniform-Resource-Locator’> <NO_BOTTOM_MATTER>
<NO_TOP_MATTER> <DYNAMIC> )
3 entry.HTML (<URL=’Uniform-Resource-Locator’> <NO_BOTTOM_MATTER>
<NO_TOP_MATTER> <DYNAMIC> )

where

external-file
is the physical name of an external file to write to. For information on
specifying external files, see the SAS companion for your operating
environment.

fileref
is a fileref that has been assigned to an external file. The fileref must refer to
a single file; it cannot point to an aggregate file storage location. Use a
FILENAME statement to assign a fileref. See also “FILENAME Statement”
on page 28.
SAS/GRAPH Statements ODS HTML Statement 167

entry.HTML
specifies an entry in a SAS catalog to write to.You must also specify a library
and catalog. See the discussion on PATH=“ODS HTML Statement” on page
164.
URL=’Uniform-Resource-Locator’
provides a URL for file-specification. ODS uses this URL instead of the file
name in all the links and references that it creates that point to the file.
This option is useful for building HTML files that may be moved from one
location to another. If the links from the contents and page files are
constructed with a simple URL (one name), they work as long as the
contents, page, and body files are all in the same location.
NO_BOTTOM_MATTER
NOBOT
omits the bottom matter for the file. By default, when you close a file that
was open for HTML output of any kind, ODS writes some HTML to the
bottom of the file. This HTML ends the file so that it can be viewed cleanly in
a browser.
If you wish to leave a file in a state that you can append to, use
NO_BOTTOM_MATTER on the BODY= option on the ODS HTML statement
that opens the file. This option, in conjunction with NO_TOP_MATTER
makes it possible for you to add output to a file that already exists and to put
your own HTML code in the file between pieces of output.
To use NO_BOTTOM_MATTER, you must use a fileref for file-specification.
The FILENAME statement that defines the fileref must include the
host-specific option that opens the file for appending.
When you are opening a file that ODS has previously written to, you must
use ANCHOR= to specify a new base name for the anchors to avoid
duplicating anchors that already exist in the file. See the discussion “About
Anchors” on page 168.
NO_TOP_MATTER
NOTOP
omits the opening matter for the file. By default, when you open a file for
HTML output of any kind, ODS writes some HTML to the top of the file.
If you wish to append ODS output to an existing file, you must open the file
with NO_TOP_MATTER on the BODY= option on the ODS HTML statement
that opens the file. This option, in conjunction with NO_BOTTOM_MATTER
makes it possible for you to add output to a file that already exists and to put
your own HTML code in the file between pieces of output.
To use NO_TOP_MATTER, you must use a fileref for file-specification. The
FILENAME statement that defines the fileref must include the host-specific
option that opens the file for appending.
When you are opening a file that ODS has previously written to, you must
use ANCHOR= to specify a new base name for the anchors to avoid
duplicating anchors that already exist in the file. See the discussion“About
Anchors” on page 168.
DYNAMIC
enables you to send HTML output directly to a web server instead of writing
it to a file. This option sets the value of the HTMLContentType= attribute.
By default, if you do not specify DYNAMIC, ODS sets the value of
HTMLContentType= for writing to a file.
Note: If you specify the DYNAMIC suboption with any file specification in
the ODS HTML statement, you must specify it for all the file specifications in
the statement. 4
168 Using the ODS HTML Statement Chapter 7

Note: Regardless of how you specify the file, you may need to include the extension
.HTML or .HTM on the file name. Some browsers require one of these extensions in
order to read the file. 4

Note: For additional information, refer to the Output Delivery System. 4

Using the ODS HTML Statement


While the ODS HTML destination is open, you can submit as many ODS HTML
statements as you like, and you can place them anywhere in your SAS/GRAPH
program. This enables you to open new files, change anchor names, or specify a new
location for graphics output whenever you like. At the end of your ODS HTML
processing step, submit ODS HTML CLOSE to close the destination and all open files.

Specifying a Destination for ODS HTML Output


When you use the ODS HTML statement for SAS/GRAPH, you must do the following:
3 assign a body file with the ODS HTML BODY= option
3 specify DEVICE=GIF (or TARGET=GIF) in a GOPTIONS statement to create the
GIF files. By default with ODS processing, the GIF files are stored in the current
directory. To specify a destination for all the HTML and GIF files, use the PATH=
option. To store the GIF files in a different location than the HTML files, use the
GPATH= option to specify a location for the GIF files, and PATH= to specify the
location of the HTML files. In both cases,the destination must be an aggregate
storage location. With procedures GCHART, GCONTOUR, GMAP, GPLOT, and
G3D, you can also use DEVICE=ACTIVEX to create graphs as ActiveX controls, or
DEVICE=JAVA to create graphs as Java applets. The controls or applets are
defined within the body file.
Note: For more information, see SAS Output Delivery System: User’s Guide. 4
For more information about the output files generated for use with the Web, see
“Types of Web Presentations Available” on page 370.

About Anchors
ODS HTML automatically creates an anchor for every piece of output generated by
the SAS procedures. An anchor specifies a particular location within an HTML file. In
SAS/GRAPH, an anchor usually defines a link target such as a graph whose location is
defined in an IMG element.

Note: For additional information, refer to the Output Delivery System 4


In order for the links from the contents, page, or frame file to work, each piece of
output in the body files must have a unique anchor to link to. The anchor for the first
piece of output in a body file acts as the anchor for that file. These anchors are used by
the frame and contents files, if they are created, to identify the targets for the links that
ODS HTML automatically generates.
By default, the first anchor is named IDX and all subsequent anchors generated
while the HTML destinations remain open increment that name. Anchor values
increment while the ODS HTML destinations remain open unless you use ANCHOR=
to assign a new value. Anchor values continue to increment when you open new body
files, start new procedures, or produce different types of output.
SAS/GRAPH Statements PATTERN Statement 169

Controlling the anchor name is useful when you create a graph with drill-down
capability. In this case, you must create a variable that contains the names of the
anchors that are the targets for the different areas of the graph that the user may click
on.

PATTERN Statement
The PATTERN statement defines the characteristics of patterns used in graphs.
Used by:
GCHART, GCONTOUR, GMAP, GPLOT procedures; SYMBOL statement;
Annotate facility
Global
Assigned by default

Description
PATTERN statements create PATTERN definitions that define the color and type of
area fill for patterns used in graphs. These are the procedures and the graphics areas
that they create that use PATTERN definitions:
GCHART color, fill pattern, or image for the bars in 2D bar charts; color and
fill pattern for the segments of 3D bar charts, pie charts, and star
charts.
GCONTOUR contour levels in contour plots
GMAP map areas in choropleth, block, and prism maps; blocks in block
maps
GPLOT areas beneath or between plotted lines.
In addition, the SYMBOL statement and certain Annotate facility functions and
macros can use pattern specifications. For details see the “SYMBOL Statement” on
page 183 and Chapter 24, “Using Annotate Data Sets,” on page 587.
You can use the PATTERN statement to control the fill and color of a pattern, and
whether the pattern is repeated. There are three types of patterns:
3 bar and block patterns
3 map and plot patterns
3 pie and star patterns
Pattern fills can be solid or empty, or composed of parallel or crosshatched lines. For
two-dimensional bar charts, the PATTERN statement can specify images to fill
horizontal or vertical bars. In addition, you can specify device-dependent hardware
patterns for rectangle, polygon, and pie fills on devices that support hardware patterns.
If you do not create PATTERN definitions, SAS/GRAPH software generates them as
needed and assigns them to your graphs by default. Generally, the default behavior is
to rotate a solid pattern through the current colors list. For details, see “About Default
Patterns” on page 177.

Syntax
PATTERN<1...255>
<COLOR=pattern-color>
<REPEAT=number-of-times>
170 PATTERN Statement Chapter 7

<VALUE=bar/block-pattern
| map/plot-pattern
| pie/star-pattern
| hardware-pattern>;

3 bar/block-pattern can be one of these:


EMPTY
SOLID
style <density>
3 map/plot-pattern can be one of these:
MEMPTY
MSOLID
Mdensity <style <angle>>
3 pie/star-pattern can be one of these:
PEMPTY
PSOLID
Pdensity <style <angle>>
3 hardware-pattern has this form:
HWxxxnnn

Options

COLOR=pattern-color
C=pattern-color
specifies the color of the fill. Pattern-color is any SAS/GRAPH color name. See
Chapter 6, “SAS/GRAPH Colors and Images,” on page 91 .
Note: ActiveX assigns colors in a different order from Java, so the same data
can appear differently with those two drivers. 4
Using COLOR= with a null value cancels the color specified in a previous
PATTERN statement of the same number without affecting the values of other
options.
COLOR= overrides the CPATTERN= graphics option.
The CFILL= option in the PIE and STAR statements overrides COLOR=. For
details, see “Controlling Slice Patterns and Colors” on page 831.
CAUTION:
Omitting COLOR= in a PATTERN statement may cause the PATTERN statement to
generate multiple PATTERN definitions. 4
If no color is specified for a PATTERN statement, that is, if neither COLOR=
nor CPATTERN= is used, the PATTERN statement rotates the specified fill
through each color in the colors list before the next PATTERN statement is used.
For details, see “Understanding Pattern Sequences” on page 182.
See also: “Working with PATTERN Statements” on page 179.
Featured in: “Example 7. Using BY-group Processing to Generate a Series of
Charts” on page 240.
Not supported by: Java (partial), ActiveX (partial)
SAS/GRAPH Statements PATTERN Statement 171

IMAGE= fileref | ’external-file’


specifies an image file that will be used to fill one or more bars of a
two-dimensional bar chart, as generated by the HBAR and VBAR statements of
the GCHART procedure. The format of the external file specification varies across
operating environments. See also the IMAGESTYLE= option.
Note: When you specify an image file to fill a bar, the bar is not outlined. 4
Note: If an image is specified on a PATTERN statement that is used with
another type of chart, then the PATTERN statement is ignored and default pattern
rotation is affected. For example, if you submit a PIE statement when an image
has been specified in a PATTERN statement, the default fill pattern is used for the
pie slices, with each slice in the pie displaying the fill pattern in the same color.
In the Java applet, IMAGE= only works on 2–dimensional rectangular bars.
The Java applet does not support images on arbitrary polygons. 4
See also: For related information, see “Placing Images on the Bars of
Two-Dimensional Bar Charts” on page 116.
Not supported by: Java (partial), ActiveX (partial)
IMAGESTYLE = TILE | FIT
specifies how the image specified in the IMAGE= option is to be applied to fill a
bar in a two-dimensional bar chart. The TILE value, which is the default, copies
the image as needed to fill the bar. The FIT value stretches a single instance of
the image to fill the bar.
See also: For related information, see “Placing Images on the Bars of
Two-Dimensional Bar Charts” on page 116.
Not supported by: Java (partial), ActiveX (partial)
REPEAT=number-of-times
R=number-of-times
specifies the number of times that a PATTERN definition is applied before the next
PATTERN definition is used. By default, REPEAT=1.
The behavior of REPEAT= depends on the color specification:
3 If you use both COLOR= and REPEAT= in a PATTERN statement, the
pattern is repeated the specified number of times in the specified color. The
fill can be either the default solid or a fill specified with VALUE=.
3 If you use CPATTERN= in a GOPTIONS statement to specify a single
pattern color, and use REPEAT= either alone or with VALUE= in a
PATTERN statement, the resulting hatch pattern is repeated the specified
number of times.
3 If you omit both COLOR= and CPATTERN=, and use REPEAT= either alone
(generates default solids) or with VALUE= in a PATTERN statement, the
resulting pattern is rotated through each color in the colors list, and then the
entire group generated by this cycle is repeated the number of times specified
in REPEAT=. Thus, the total number of patterns produced depends on the
number of colors in the current colors list.
Using REPEAT= with a null value cancels the repetition specified in a previous
PATTERN statement of the same number without affecting the values of other
options.
See also: “Understanding Pattern Sequences” on page 182.
Not supported by: Java (partial), ActiveX (partial)
VALUE=bar/block-pattern
V=bar/block-pattern
specifies patterns for:
172 PATTERN Statement Chapter 7

3 bar charts produced by the HBAR, HBAR3D, VBAR, and VBAR3D


statements in the GCHART procedure including 2D and 3D bar shapes.
3 the front surface of blocks in block charts produced by the BLOCK statement
in the GCHART procedure.
3 the blocks in block maps produced by the BLOCK statement in the GMAP
procedure. (The map area from which the block rises takes a map pattern as
described on the option VALUE= on page 173). See also “About Block Maps
and Patterns” on page 1016.
Values for bar/block-pattern are
EMPTY an empty pattern. Neither the Java applet nor the ActiveX
E control supports EMPTY.
SOLID a solid pattern (the only valid value for 3D charts).
S
style<density> a shaded pattern.
Note: style<density> is not supported by the Java or
ActiveX clients. 4
Style specifies the direction of the lines:
L left-slanting lines.
R right-slanting lines.
X crosshatched lines.
Density specifies the density of the pattern’s shading:
1...5 1 produces the lightest shading and 5
produces the heaviest shading.
Figure 7.12 on page 172 shows all of the patterns available for bars and blocks.

Figure 7.12 Bar and Block Patterns

If no valid patterns are available, default bar and block fill patterns are selected
in this order:
1 SOLID
SAS/GRAPH Statements PATTERN Statement 173

2 X1– X5
3 L1– L5
4 R1– R5
Each fill is used once with every color in the colors list unless a pattern color is
specified. The entire sequence is repeated as many times as required to provide
the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color is limited to a
single color with the CPATTERN= or COLORS= graphics options, the order is X1–
X5, L1– L5, R1– R5, S, and E. 4
Not supported by: Java (partial), ActiveX (partial)

VALUE=map/plot-pattern
V=map/plot-pattern
specifies patterns for:
3 contour levels in contour plots produced by the GCONTOUR procedure
3 map area surfaces in block, choropleth, and prism maps produced by the
BLOCK, CHORO, AND PRISM statements in the GMAP procedure.
3 areas under curves in plots produced by the AREAS= option in the PLOT
statement in the GPLOT procedure.
Values for map/plot-pattern are
MEMPTY an empty pattern. EMPTY or E are also valid aliases, except
ME when used with the map areas in block maps created by the
GMAP procedure.
MSOLID a solid pattern. SOLID or S are also valid aliases, except when
MS used with the map areas in block maps created by the GMAP
procedure.
Mdensity<style<angle>> a shaded pattern.
Note: Mdensity<style<angle>> is not supported by the Java
or ActiveX clients. 4

Density specifies the density of the pattern’s shading:


1...5 1 produces the lightest shading and 5
produces the heaviest shading.
Style specifies the type of the pattern lines:
N parallel lines (the default).
X crosshatched lines.
Angle specifies the angle of the pattern lines:
0...360 the degrees at which the parallel lines are
drawn, measured from the horizontal. By
default, angle is 0 (lines are horizontal).
Figure 7.13 on page 174 shows some typical map and plot patterns.
174 PATTERN Statement Chapter 7

Figure 7.13 Map and Plot Patterns

0o

M3N0 M3X0

o
45

M3N45 M3X45

90o

M3N90 M3X90

135o

M3N135 M3X135

If no valid patterns are available, default map and plot fill patterns are selected
in this order:
1 MSOLID
2 M2N0
3 M2N90
4 M2X45
5 M4N0
6 M4N90
7 M4X90
Each fill is used once with every color in the colors list unless a pattern color is
specified. The entire sequence is repeated as many times as required to provide
the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color is limited to a
single color with the CPATTERN= or COLORS= graphics options, MSOLID is not
used and the default fill list starts with M2N0. 4
Not supported by: Java (partial), ActiveX (partial)

VALUE=pie/star-pattern
V=pie/star-pattern
specifies patterns for pie and star charts produced by the PIE and STAR
statements in the GCHART procedure. Values for pie/star-pattern are
PEMPTY an empty pattern. EMPTY or E are also valid aliases.
PE
PSOLID a solid pattern. SOLID or S are also valid aliases.
PS
Pdensity<style<angle>> a shaded pattern.
SAS/GRAPH Statements PATTERN Statement 175

Note: Pdensity<style<angle>> is not supported by the Java


or ActiveX clients. 4
Density specifies the density of the pattern’s shading:
1...5 1 produces the lightest shading and 5
produces the heaviest shading.
Style specifies the type of the pattern lines:
N parallel lines (the default).
X crosshatched lines.
Angle specifies the angle of the pattern lines:
0...360 the angle of the lines, measured in degrees
from perpendicular to the radius of the
slice. By default, angle is 0.
The FILL= option in the PIE and STAR statements in the GCHART procedure
overrides VALUE=.
Figure 7.14 on page 175 shows some typical pie and star patterns.

Figure 7.14 Pie and Star Patterns

o
0

P3N0 P3X0

o
45

P3N45 P3X45

o
90

P3N90 P3X90

o
135

P3N135 P3X135

If no valid patterns are available, default pie and star fill patterns are selected
in this order:
1 PSOLID
2 P2N0
3 P2N90
176 Using the PATTERN Statement Chapter 7

4 P2X45
5 P4N0
6 P4N90
7 P4X90
Each fill is used once with every color in the colors list unless a pattern color is
specified. The entire sequence is repeated as many times as required to provide
the necessary number of patterns.
Note: If the V6COMP graphics option is in effect, or if color is limited to a
single color with the CPATTERN= or COLORS= graphic options, PSOLID is not
used and the default fill list starts with P2N0. 4

Note: If you use hatch patterns and request a legend instead of slice labels, the
patterns in the slices are oriented to be visually equivalent to the legend. 4
Not supported by: Java (partial), ActiveX (partial)

VALUE=HWxxxnnn
specifies a hardware pattern where
HW identifies the pattern as a hardware pattern. The pattern name
must begin with the characters HW.
xxx the last two or three characters of the module name in the
Module field in the Detail window of your device entry. If the
module name has eight characters (SASGDPSL, for example),
use the last three characters (PSL). If the module name has
only seven characters (SASGDVT, for example), use the last
two characters (VT).
nnn the number the driver uses to identify the device-dependent
pattern. Patterns and associated pattern numbers vary from
device to device. See the documentation for your device for
valid pattern numbers. For a brief description of some device
specific pattern values, see “Specifying Device-Dependent
Hardware Patterns” on page 181.
If you specify a hardware pattern for a device that does not support hardware
patterns, or if you specify an invalid pattern number, a solid rectangle, polygon, or
pie fill is substituted. A solid fill will also be used in place of a hardware pattern
in certain types of clipped polygons. See the PCLIP and POLYGONCLIP options
in Chapter 8, “Graphics Options and Device Parameters Dictionary,” on page 261
for more information on using hardware patterns with clipped polygons.
See also: “Specifying Device-Dependent Hardware Patterns” on page 181.
Not supported by: Java (partial), ActiveX (partial)

Using the PATTERN Statement


PATTERN statements can be located anywhere in your SAS program. They are global
and remain in effect until redefined, canceled, or until the end of your SAS session.
You can define up to 255 different PATTERN statements. A PATTERN statement
without a number is treated as a PATTERN1 statement.
PATTERN statements generate one or more PATTERN definitions, depending on how
the COLOR=, VALUE=, and IMAGE= options are used. For information on PATTERN
definitions, see “Working with PATTERN Statements” on page 179, as well as the
SAS/GRAPH Statements About Default Patterns 177

description of COLOR= on page 170, VALUE= on page 173, and IMAGE= on page 171
options.
PATTERN definitions are generated in the order in which the statements are
numbered, regardless of gaps in the numbering or the statement’s position in the
program. Although it is common practice, you do not have to start with PATTERN1,
and you do not have to use sequential statement numbers.
PATTERN definitions are applied automatically to all areas of the graphics output
that require patterns. When assigning PATTERN definitions, SAS/GRAPH starts with
the lowest-numbered definition with an appropriate fill specification or with no fill
specification. It continues to use the specified patterns until all valid PATTERN
definitions have been used. Then, if more patterns are required, SAS/GRAPH returns
to the default pattern rotation, but continues to outline the areas in the same color as
the fill.

Altering or Canceling PATTERN Statements


PATTERN statements are additive. If you define a PATTERN statement and later
submit another PATTERN statement with the same number, the new PATTERN
statement redefines or cancels only the options that are included in the new statement.
Options not included in the new statement are not changed and remain in effect. For
example, assume you define PATTERN4 as
pattern4 value=x3 color=red repeat=2;

This statement cancels only REPEAT= without affecting the rest of the definition:
pattern4 repeat=;

Add or change options in the same way. This statement changes the color of the
pattern from red to blue:
pattern4 color=blue;

After all these modifications, PATTERN4 has these characteristics:


pattern4 value=x3 color=blue;

Cancel individual PATTERN statements by defining a PATTERN statement of the


same number without options (a null statement):
pattern4;

Canceling one PATTERN statement does not affect any other PATTERN definitions.
To cancel all current PATTERN statements, use the RESET= option in a GOPTIONS
statement:
goptions reset=pattern;

Specifying RESET=GLOBAL or RESET=ALL cancels all current PATTERN


definitions as well as other settings.
To display a list of current PATTERN definitions in the LOG window, use the
GOPTIONS procedure with the PATTERN option:
proc goptions pattern nolist;
run;

About Default Patterns


When a procedure produces a graph that needs one or more patterns, SAS/GRAPH
either
178 About Default Patterns Chapter 7

3 automatically generates the appropriate default patterns and outlines to fill the
areas, or
3 uses patterns, colors, and outlines that are defined by PATTERN statements,
graphics options, and procedure options.
In order to understand how SAS/GRAPH generates and assigns patterns defined
with PATTERN statements it is helpful to understand how it generates and assigns
default patterns. The following sections describe the default pattern behavior for all
procedures. See “Working with PATTERN Statements” on page 179 for details about
defining patterns.

How Default Patterns and Outlines Are Generated


In general, SAS/GRAPH uses default patterns when no PATTERN statements are
defined. Typically, the default pattern that SAS/GRAPH uses is a solid fill that it
rotates once through the colors list, skipping the foreground color. By default,
SAS/GRAPH also outlines all areas in the foreground color. (Typically, the foreground
color is the first color in the device’s colors list.)
Specifically, SAS/GRAPH uses default patterns and outlines when you
3 do not specify any PATTERN statements, and
3 do not use the CPATTERN= graphics option, and
3 do not use the COLORS= graphics options (that is, you use the device’s default
colors list and it has more than one color), and
3 do not use the COUTLINE= option in the action statement.
If all of these conditions are true, then SAS/GRAPH
3 selects the first default fill for the appropriate pattern, which is always solid, and
rotates it once through the colors list, generating one solid pattern for each color.
If the first color in the device’s colors list is black (or white), SAS/GRAPH skips
that color and begins generating patterns with the next color.
Note: The one exception to the default solid pattern is the map area pattern in
a block map produced by the GMAP procedure, which uses a hatch fill by default.
By default the map areas and their outlines use the first color in the colors list,
regardless of whether the list is the default device list or one specified with
COLORS= in the GOPTIONS statement. 4
3 uses the foreground color to outline every patterned area.
For example, the default colors list for the PSCOLOR device contains BLACK, RED,
GREEN, BLUE, CYAN, MAGENTA, YELLOW, and GRAY. Therefore, for this device,
the first five default patterns are solid red, solid green, solid blue, solid cyan, and solid
magenta. These patterns are all outlined in black, the first color in the colors list.
If a procedure needs additional patterns, SAS/GRAPH selects the next default
pattern fill appropriate to the graph and rotates it through the colors list, skipping the
foreground color as before. SAS/GRAPH continues in this fashion until it has generated
enough patterns for the chart.

Things That Affect Default Patterns


Changing any of these conditions may change or override the default behavior:
3 If you specify a colors list with the COLORS= option in a GOPTIONS statement
and the list contains more than one color, SAS/GRAPH rotates the default fills,
beginning with SOLID, through that list. In this case, it uses every color, even if
the foreground color is black (or white). The default outline color remains the
foreground color.
SAS/GRAPH Statements Working with PATTERN Statements 179

3 If you specify either COLORS=(one-color) or the CPATTERN= graphics option, the


default fill changes from SOLID to the appropriate list of hatch patterns.
SAS/GRAPH uses the specified color to generate one pattern definition for each
hatch pattern in the list. The default outline color remains the foreground color.
3 Whenever you specify PATTERN statements, whether or not the procedure can use
them, the default outline color for all patterns changes from foreground to SAME.
Therefore, when a procedure runs out of specified patterns and returns to the
default pattern rotation, the outline color is SAME, not foreground.
For a description of these graphics options, see Chapter 8, “Graphics Options and
Device Parameters Dictionary,” on page 261.

Working with PATTERN Statements


With PATTERN statements, you can specify
3 the type of fill (VALUE=)
3 the color of the fill (COLOR=)
3 the images used to fill the bars in a 2D chart (IMAGE=)
3 how many times to apply the statement before using the next one (REPEAT=).
See “Placing Images on the Bars of Two-Dimensional Bar Charts” on page 116 for
information on filling the bars of two–dimensional bar charts with images using the
PATTERN statement.
You can also use procedure options to specify the pattern outline color and the
CPATTERN= graphics option to specify a default color for all patterns.
Whether you use PATTERN statement options alone or with each other affects the
number and kind of patterns your PATTERN statements generate. Depending on the
options you use, you can explicitly specify every pattern used by your graphs or you can
let the PATTERN statement generate a series of pattern definitions using either the
colors list or the list of default fills.

Explicitly Specifying Patterns


To explicitly specify all the patterns in your graph, you need to do one of the
following for every pattern your graph requires:
3 Provide a PATTERN statement that uses the COLOR= option to specify the
pattern color, for example
pattern1 color=red;

By default, the fill type SOLID.


3 Provide a PATTERN statement that uses both the COLOR= option and the
VALUE= option to specify the fill, for example
pattern1 color=blue value=r3;
Including COLOR= in the PATTERN statement is the simplest way to assure that
you get exactly the patterns you want. When you use the COLOR= option, the
PATTERN statement generates exactly one PATTERN definition for that statement. If
you also use the REPEAT= option, the PATTERN definition is repeated the specified
number of times.

Generating Multiple Pattern Definitions


You can also use PATTERN statements to generate multiple PATTERN definitions.
To do this use the VALUE= option to specify the type of fill you want but omit the
COLOR= option – for example
180 Working with PATTERN Statements Chapter 7

pattern1 value=r3;

In this case, the PATTERN statement rotates the R3 fill through all the colors in the
colors list. For more information on pattern rotation, see “Understanding Pattern
Sequences” on page 182.

Selecting an Appropriate Pattern


The type of fill you specify depends on the type of graph you are producing:

With... Use...

bar and block charts (PROC VALUE= bar/block-pattern on page


GCHART), block maps (PROC GMAP) 171
contour plots (PROC GCONTOUR), VALUE=map/plot-pattern on page 173
map area surfaces (PROC GMAP)
pie and star charts (PROC GCHART) VALUE=pie/star-pattern on page 174

Note: If you specify a fill that is inappropriate for the type of graph you are
generating (for example, if you specify VALUE=L1 in a PATTERN statement for a
choropleth map), SAS/GRAPH ignores the PATTERN statement and continues
searching for a valid pattern. If it does not find a definition with a valid fill
specification, it uses default patterns instead. 4

Controlling Outline Colors


Whenever you use PATTERN statements, the default outline color is the same as the
fill color, for example, a blue bar has a blue outline. The effect is the same as specifying
COUTLINE=SAME. Even when the procedure runs out of user-defined patterns and
generates default patterns, the outlines continue to match the interior fill color.
To change the outline color of any pattern, whether default or user-defined, use the
COUTLINE= option in the action statement that generates the chart.

The Effect of the CPATTERN= Graphics Option


Although the CPATTERN= graphics option is used most often with default patterns,
it does affect the PATTERN statement. With default patterns (no PATTERN statements
specified) it
3 specifies the color for all patterns
3 causes default patterns to use hatched fills instead of the default SOLID.
In conjunction with the PATTERN statement it does the following:
3 With a PATTERN statement that only specifies a fill (VALUE=), CPATTERN=
determines the color of that fill. For example, these statements produce two green,
hatched patterns:
goptions cpattern=green;
pattern1 value=x3;
pattern2 value=x1;

3 With a PATTERN statement that only specifies a color (COLOR=), the COLOR=
option overrides the CPATTERN= color, but CPATTERN= causes the fill to be
SAS/GRAPH Statements Specifying Device-Dependent Hardware Patterns 181

hatched, not the default SOLID. For example, these statements produce one red,
hatched pattern:
goptions cpattern=green;
pattern1 color=red;

See also the description of CPATTERN=“CPATTERN” on page 274.

Specifying Version 6 Patterns


If you specify the V6COMP graphics option, SAS/GRAPH generates patterns by
rotating the appropriate Version 6 default patterns through all the colors in the colors
list. With V6COMP, all patterns are outlined in the same color as the fill.

Specifying Device-Dependent Hardware Patterns


You can specify device-dependent hardware patterns with the types of device drivers
described in this section.

GDDM Drivers
GDDM drivers include several sets of hardware patterns. These patterns include both
predefined and user-defined (device-dependent) fill patterns. When you use a hardware
pattern with a GDDM driver, specify the name of the device-dependent pattern set you
want the driver to use. This name will be stored in the GPROLOG string in the device
entry for the driver. Specify the name of the pattern set in either of these ways:
3 Use the GPROLOG= graphics option to assign the pattern set name to the
GPROLOG string.
3 Enter the pattern set name in the Gprolog window of the device entry for the
GDDM device driver.
If you do not specify a pattern set name, the device uses a predefined pattern.
Values for nnn for predefined patterns are 1 through 16. Values for nnn for
device-dependent patterns are 65 through 128.
Information regarding both types of fill patterns can be found in GDDM Application
Programming Guide. For additional information on specifying hardware patterns with
GDDM drivers, see also the GDDM Base Programming Reference.

TEK42xx Series Terminal Drivers


TEK42xx series terminal drivers support the predefined fill patterns found in the
Technical Reference Guide for each terminal. These drivers can also support
user-defined fill patterns. Values for nnn for these drivers are numbers less than 175.

HPLJxxxx Drivers
HPLJxxxx drivers for the HP LaserJet support the predefined shading levels and
predefined fill patterns for rectangle fill only. These patterns are documented in the
appropriate HP LaserJet technical manual. Values for nnn for shading levels are 001
through 008. Values for fill patterns are 009 through 014.

Metagraphics Drivers
Metagraphics drivers can use the hardware patterns supported by the device for
which they are written. When you specify hardware patterns for a metagraphics driver,
values of nnn can range from 0 through 999.
182 Understanding Pattern Sequences Chapter 7

Understanding Pattern Sequences


Pattern sequences are sets of PATTERN definitions that SAS/GRAPH automatically
generates when a PATTERN statement specifies a fill but not a color. In this case, the
specified fill is used once with every color in the colors list. If REPEAT= is also used,
the resulting PATTERN definitions are repeated the specified number of times.

Generating Pattern Sequences


SAS/GRAPH generates pattern sequences when a PATTERN statement uses
VALUE= to specify a fill and all of the following conditions are also true:
3 the COLOR= option is not used in the PATTERN statement
3 the CPATTERN= graphics option is not used
3 the colors list, either default or user-specified, contains more than one color.
In this case, the PATTERN statement rotates the fill specified by VALUE= through
every color in the colors list, generating one PATTERN definition for every color in the
list. After every color has been used once, SAS/GRAPH goes to the next PATTERN
statement. For example, suppose you specified the following colors list and PATTERN
statements for bar/block patterns:
goptions colors=(blue red green) ctext=black;
pattern1 color=red value=x3;
pattern2 value=r3;
pattern3 color=blue value=l3;

Here, PATTERN1 generates the first PATTERN definition. PATTERN2 omits COLOR=,
so the specified fill is rotated through all three colors in the colors list before the
PATTERN3 statement is used. This table shows the color and fill of the PATTERN
definitions that would be generated if nine patterns were required:

Definition Characteristics:
Number Source Color Fill
1 PATTERN1 red x3

2 PATTERN2 blue r3
3 PATTERN2 red r3

4 PATTERN2 green r3
5 PATTERN3 blue l3

6 first default blue solid


7 first default red solid

8 first default green solid


9 second default blue x1

Notice that after all the PATTERN statements are exhausted, the procedure begins
using the default bar and block patterns, beginning with SOLID. Each fill from the
default list is rotated through all three colors in the colors list before the next default
fill is used.
SAS/GRAPH Statements SYMBOL Statement 183

Repeating Pattern Sequences


If you use REPEAT= but not COLOR=, the sequence generated by cycling the
definition through the colors list is repeated the number of times specified by
REPEAT=. For example, these statements illustrate the effect of REPEAT= on
PATTERN statements both with and without explicit color specifications:
goptions colors=(red blue green);
pattern1 color=gold repeat=2;
pattern2 value=x1 repeat=2;

Here, PATTERN1 is used twice and PATTERN2 cycles through the list of three colors
and then repeats this cycle a second time:

Sequence Number Source Characteristics: Color Fill

1 PATTERN1 gold solid (first default)


2 PATTERN1 gold solid (first default)

3 PATTERN2 red x1
4 PATTERN2 blue x1

5 PATTERN2 green x1
6 PATTERN2 red x1

7 PATTERN2 blue x1
8 PATTERN2 green x1

SYMBOL Statement
The SYMBOL statement defines the characteristics of symbols that display the data
plotted by a PLOT statement used by PROC GBARLINE, PROC GCONTOUR, and
PROC GPLOT.
Used by:
GBARLINE, GCONTOUR, GPLOT procedures
Global
Assigned by default

Description
SYMBOL statements create SYMBOL definitions, which are used by the GPLOT and
GCONTOUR procedures. For the GPLOT procedure, SYMBOL definitions control
3 the appearance of plot symbols and plot lines, including bars, boxes, confidence
limit lines, and area fills
3 interpolation methods
3 how plots handle data out of range.
For the GCONTOUR procedure, SYMBOL definitions control
3 the appearance and text of contour labels
3 the appearance of contour lines.
184 SYMBOL Statement Chapter 7

If you create SYMBOL definitions, they are automatically applied to a graph by the
procedure. If you do not create SYMBOL definitions, these procedures generate default
definitions and apply them as needed to your plots.

Syntax
SYMBOL<1...255>
<COLOR=symbol-color>
<MODE=EXCLUDE | INCLUDE>
<REPEAT=number-of-times>
<STEP=distance<units>>
<appearance-option(s)>
<interpolation-option>
<SINGULAR=n>;
appearance-options can be one or more of these:
BWIDTH=box-width
CI=line-color
CO=color
CV=value-color
FONT=font
HEIGHT=symbol-height<units>
LINE=line-type
POINTLABEL<=(label-description(s)) | NONE>
VALUE=special-symbol | text-string | NONE
WIDTH=thickness-factor
interpolation-option can be one of these:
3 general methods
INTERPOL=JOIN
INTERPOL=map/plot-pattern
INTERPOL=NEEDLE
INTERPOL=NONE
INTERPOL=STEP<placement><J><S>
3 high-low interpolation methods
INTERPOL=BOX<option(s)><00...25>
INTERPOL=HILO<C><option(s)>
INTERPOL=STD<1 | 2 | 3><variance><option(s)>
3 regression interpolation methods
INTERPOL=R<type><0><CLM | CLI<50...99>>
3 spline interpolation methods
INTERPOL=L<degree><P><S>
INTERPOL=SM<nn><P><S>
INTERPOL=SPLINE<P><S>

Options
When the syntax of an option includes units, use one of these:
CELLS character cells
SAS/GRAPH Statements SYMBOL Statement 185

CM centimeters
IN inches
PCT percentage of the graphics output area
PT points.
If you omit units, a unit specification is searched for in this order:
1 the GUNIT= option in a GOPTIONS statement
2 the default unit, CELLS.

BWIDTH=box-width
specifies the width of the box generated by either the INTERPOL=BOX or
INTERPOL=HILOB option. Box-width can be any number greater than 0. By
default, the value of box-width is the same as the value of the WIDTH= option,
whose default value is 1. Therefore, if you specify a value for WIDTH= and omit
BWDITH=, the width of the box changes accordingly.
Featured in: “Example 4. Creating and Modifying Box Plots” on page 233.
CI=line-color
specifies a color for an interpolation line (GPLOT) or a contour line (GCONTOUR).
If you omit CI= but specify CV=, CI= assumes the value of CV=. In this case, CI=
and CV= specify the same color, which is the same as specifying COLOR= alone.
If you omit CI=, the color specification is searched for in this order:
1 the CV= option
2 the COLOR= option
3 the CSYMBOL= option in a GOPTIONS statement
4 each color in the colors list sequentially before the next SYMBOL definition is
used.
See also: “Using Color” on page 206
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226
CO=color
specifies a color for
3 outlines of filled areas generated by the INTERPOL=map/plot-pattern option
3 confidence limit lines generated by the INTERPOL=R series option
3 staffs, boxes, and bars generated by the high-low interpolation methods:
INTERPOL=HILO, INTERPOL=BOX, and INTERPOL=STD.
If you omit the CO= option, the search order for a color specification depends on
the interpolation method being used.
See also: “Using Color” on page 206
Featured in: “Example 5. Filling the Area between Plot Lines” on page 236 and
“Example 4. Creating and Modifying Box Plots” on page 233.
COLOR=symbol-color
C=symbol-color
specifies a color for the entire definition, unless it is followed by a more explicit
specification. For the GPLOT procedure, this includes plot symbols, the plot line,
confidence limit lines, and outlines. For the GCONTOUR procedure, this includes
contour lines and labels.
Using the COLOR= option is exactly the same as specifying the same color for
both the CI= and CV= options.
186 SYMBOL Statement Chapter 7

If COLOR= precedes CI= or CV= in the same statement, CI= or CV= is used
instead.
If you do not use COLOR= or CI=, CV=, and CO=, the color specification is
searched for in this order:
1 the CSYMBOL= option in a GOPTIONS statement
2 each color in the colors list sequentially before the next SYMBOL definition is
used.
If you do not use a SYMBOL statement to specify a color for each symbol, but
you do specify a colors list in a GOPTIONS statement, then Java and ActiveX
assign colors to symbols differently than does the SAS server. To ensure
consistency on all devices, you should specify the desired color of each symbol. The
SAS server restarts at the first color in the colors list and rotates through all of
the colors in the color list for the first default symbol before going to the next
symbol in the default symbol list where it again rotates through all of the colors in
the color list before picking up the next symbol.
Note: Neither the Java applet nor the ActiveX control supports using COLOR=
with PROC GCONTOUR. 4
See also: “Using Color” on page 206
Not supported by: Java (partial), ActiveX (partial)
CV=value-color
specifies a color for
3 plot symbols in the GPLOT procedure
3 the filled areas generated by the INTERPOL=map/plot-pattern option
3 contour labels in the GCONTOUR procedure.
If you omit CV= but specify CI=, CV= assumes the value of CI=. In this case,
CV= and CI= specify the same color, which is the same as specifying COLOR=
alone.
If you omit CV=, the color specification is searched for in this order:
1 the CI= option
2 the COLOR= option
3 the CSYMBOL= option in a GOPTIONS statement
4 each color in the colors list sequentially before the next SYMBOL definition is
used.
Note: Neither the Java applet nor the ActiveX control supports using CV= with
PROC GCONTOUR. 4
See also: “Using Color” on page 206
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226, “Example 5. Filling the Area between Plot Lines” on page 236, and
“Example 4. Creating and Modifying Box Plots” on page 233.
Not supported by: Java (partial), ActiveX (partial)
FONT=font
F=font
specifies the font for the plot symbol (GPLOT) or contour-label text (GCONTOUR)
specified by VALUE=. The font specification can be
3 the name of a software font. For example, FONT=MARKER specifies a
software font that is stored in the catalog SASHELP.FONTS.
3 a hardware font specification of the form HWxxxnnn or hardware-font-name:
HWxxxnnn
SAS/GRAPH Statements SYMBOL Statement 187

HW identifies the font as a hardware font, xxx are the last two or three
characters of the module name as listed in the Module field in the device
entry’s Detail window, and nnn is the Chartype number of the hardware
font as listed in the device entry’s Chartype window (for example,
FONT=HWDMX001).
hardware-font-name
specifies the name of a hardware font as shown in the device entry’s
Chartype window (for example, FONT="Palatino-Italic"). The name
must be enclosed in double quotation marks.
By default, no font is specified. The symbol specified by VALUE= is taken from
the special symbol table shown in Figure 7.21 on page 202. To use symbols from
the special symbol table, omit FONT=.
You can use FONT= to specify a symbol font, such as Marker, that contains a
symbol that you want to use in your plot. In this case, the string specified by
VALUE= is the character code for the symbol. For example, this definition
specifies a heart:
symbol font=marker value=N;

You can also use FONT= to specify a text font, such as Swiss. In this case, the
string specified by VALUE= appears in the plot:
symbol font=swiss value=star;

Here, the word "star" is displayed in the plot.


To cancel a font specification and return to the default special symbol table,
enter a null value:
symbol font=, value=star;

See also: the VALUE= on page 199 option , “Specifying Plot Symbols” on page
205, and Chapter 5, “SAS/GRAPH Fonts,” on page 75.
Featured in: Example 2 on page 906
Not supported by: Java, ActiveX
HEIGHT=symbol-height<units>
H=symbol-height<units>
specifies the height in number of units of plot symbols (GPLOT) or contour labels
(GCONTOUR).
Note: HEIGHT= affects only the height of the symbols and labels on the plot;
it does not affect the height of any symbols that may appear in a legend.
The HEIGHT option overrides the MarkerSize attribute in graph styles. For
more information on graph styles, see SAS Output Delivery System: User’s
Guide. 4
Note: With client-side rendering using Java, the minimum height is 2 pixels;
with ActiveX a symbol may be so small as to be invisible.
Neither the Java applet nor the ActiveX control supports HEIGHT= with PROC
GCONTOUR. 4
See also: the option SHAPE= on page 156 in the LEGEND statement
Featured in: “Example 4. Creating and Modifying Box Plots” on page 233,
“Example 3. Rotating Plot Symbols through the Colors List” on page 231, and
Example 2 on page 906.
Not supported by: Java (partial), ActiveX (partial)
INTERPOL=BOX<option(s)><00...25>
I=BOX<option(s)><00...25>
188 SYMBOL Statement Chapter 7

produces box and whisker plots. The bottom and top edges of the box are located
at the sample 25th and 75th percentiles. The center horizontal line is drawn at
the 50th percentile (median). By default, INTERPOL=BOX, in which case the
vertical lines, or whiskers, are drawn from the box to the most extreme point
within 1.5 interquartile ranges. (An interquartile range is the distance between
the 25th and the 75th sample percentiles.) Any value more extreme than this is
marked with a plot symbol.
Values for option(s) are one or more of these:
F fills the box with the color specified by CV= and outlines the
box with the color specified by CO=
J joins the median points of the boxes with a line
T draws tops and bottoms on the whiskers.
In addition, you can specify a percentile to control the length of the whiskers
within the range 00 through 25. These are examples of percentile specifications
and their effect:
00 high/low extremes. INTERPOL=BOX00 is not the same as the
default, INTERPOL=BOX.
01 1st percentile low, 99th high
05 5th percentile low, 95th high
10 10th percentile low, 90th high
25 25th percentile low, 75th high; since the box extends from the
25th to the 75th percentile, no whiskers are produced.
Figure 7.15 on page 188 shows the type of plot INTERPOL=BOX produces.

Figure 7.15 Box Plot

Y
50
40
30
20
10
0

A B C
X

Note: If you use HAXIS= or VAXIS= in the PLOT statement or ORDER= in an


AXIS definition to restrict the range of axis values, by default any observations
that fall outside the axis range are excluded from the interpolation calculation.
See the MODE= option on page 197 4
You cannot use the GPLOT procedure PLOT statement option AREAS= with
INTERPOL=BOX.
To increase the thickness of all box plot lines, including the box, whiskers, join
line, and top and bottom ticks, use the WIDTH= option.
SAS/GRAPH Statements SYMBOL Statement 189

To increase the width of the box itself, use the BWIDTH= option. By default the
value of BWIDTH= is the same as the value of WIDTH=. Therefore, if you specify
a value for WIDTH= and omit BWIDTH=, the width of the box changes.
For a scatter effect with the box, use a multiple plot request, as in this example:
symbol1 i=none v=star color=green;
symbol2 i=box v=none color=blue;
proc gplot data=test;
plot (y y)*x / overlay;

This option cannot be used in a symbol definition that is named in the GPLOT
procedure, when that procedure is generating output for the Web using a Java
device driver. This applies only when the PLOT statement is used with the
OVERLAY option, or when the PLOT2 statement is used, with or without the
OVERLAY option.
Featured in: “Example 4. Creating and Modifying Box Plots” on page 233.
Not supported by: Java (partial)
INTERPOL=HILO<C><option>
I=HILO<C><option>
specifies that a solid vertical line connect the minimum and maximum Y values for
each X value. The data should have at least two values of Y for every value of X;
otherwise, the single value is displayed without the vertical line.
By default, for each X value, the mean Y value is marked with a tick. This is
shown in Figure 7.16 on page 190.
To specify high, low, close stock market data, include this option:
C draws tick marks at the close value instead of at the mean
value. Specifying C assumes that there are three values of Y
(HIGH, LOW, and CLOSE) for every value of X. If more or
fewer than three Y values are specified, the mean is ticked.
The Y values can be in any order in the input data set.
In addition, you can specify one of these values for option:
B connects the minimum and maximum Y values with bars
instead of lines. Use the BWIDTH= option to increase the
width of the bars.
J joins the mean values or the close values (if HILOC is
specified) with a line. This point is not marked with a tick
mark. You cannot use the PLOT statement option AREAS=
with INTERPOL=HILOJ.
T adds tops and bottoms to each line.
BJ connects maximum and minimum values with a bar and joins
the mean or close values.
TJ adds tops and bottoms to the lines and joins the mean or close
values.
Figure 7.16 on page 190 shows the type of plot INTERPOL=HILO produces.
Plot symbols in the form of dots have been added to this figure.
190 SYMBOL Statement Chapter 7

Figure 7.16 High-Low Plot

Y
50
40
30
20
10
0

A B C
X

To increase the thickness of all lines generated by the INTERPOL=HILO option,


use the WIDTH= option.
Note: If you use HAXIS= or VAXIS= in the PLOT statement or ORDER= in an
AXIS definition to restrict the range of axis values, by default any observations
that fall outside the axis range are excluded from the interpolation calculation.
See the option MODE= on page 197. 4
This option cannot be used in a symbol definition that is named in the GPLOT
procedure, when that procedure is generating output for the Web using a Java
device driver. This applies only when the PLOT statement is used with the
OVERLAY option, or when the PLOT2 statement is used, with or without the
OVERLAY option.
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226.
Not supported by: Java (partial)
INTERPOL=JOIN
I=JOIN
connects data points with straight lines. Points are connected in the order they
occur in the input data set. Therefore, the data should be sorted by the
independent (horizontal axis) variable.
If the data contain missing values, the observations are omitted. However, the
plot line is not broken at missing values unless the SKIPMISS option is used.
See also: the SKIPMISS on page 1112 option and “Missing Values” on page 1087.
INTERPOL=L<degree><P><S>
I=L<degree><P><S>
specifies a Lagrange interpolation to smooth the plot line. Specify one of these
values for degree:
1|3|5 specifies the degree of the Lagrange interpolation polynomial.
By default, degree is 1.
In addition, you can specify one or both of these:
P specifies a parametric interpolation
S sorts a data set by the independent variable before plotting its
data.
The Lagrange methods are useful chiefly when data consist of tabulated, precise
values. A polynomial of the specified degree (1, 3, or 5) is fitted through the
nearest 2, 4, or 6 points. In general, the first derivative is not continuous. If the
SAS/GRAPH Statements SYMBOL Statement 191

values of the horizontal variable are not strictly increasing, the corresponding
parametric method (L1P, L3P, or L5P) is used.
Specifying INTERPOL=L1P, INTERPOL=L3P, or INTERPOL=L5P results in a
parametric Lagrange interpolation of degree 1, 3, or 5, respectively. Both the
horizontal and vertical variables are processed with the Lagrange method and a
parametric interpolation of degree 1, 3, or 5, using the distance between points as
a parameter.
INTERPOL=map/plot-pattern
I=map/plot-pattern
specifies that a pattern fill the polygon that has been defined by the data points.
Values for map/plot-pattern are
MEMPTY
ME
an empty pattern. EMPTY and E are valid aliases.
The Java applet does not support this option.
MSOLID
MS
a solid pattern. SOLID and S are valid aliases
Mdensity<style<angle>>
a shaded pattern. (The Java applet does not support this option.)
Density specifies the density of the pattern’s shading:
1...5 1 produces the lightest shading and 5 produces the
heaviest.
Style specifies the direction of pattern lines:
N parallel lines (the default)
X crosshatched lines.
Angle specifies the starting angle for parallel or crosshatched lines:
0...360 the degree at which the parallel lines are drawn. By
default, angle is 0 (lines are parallel to the horizontal
axis).
The INTERPOL=map/plot-pattern option only works if the data are structured
so that the data points and, consequently, the plot lines form an enclosed area.
The plot lines should not cross each other.
See also: the “PATTERN Statement” on page 169
Featured in: “Example 5. Filling the Area between Plot Lines” on page 236
Not supported by: Java (partial)
INTERPOL=NEEDLE
I=NEEDLE
draws a vertical line from each data point to a horizontal line at the 0 value on the
vertical axis or the minimum value on the vertical axis if it is greater than 0. The
horizontal line is drawn automatically.
Figure 7.17 on page 192 shows the type of plot INTERPOL=NEEDLE produces.
Plot symbols are not displayed in this figure.
192 SYMBOL Statement Chapter 7

Figure 7.17 Needle Plot

Y
20

10

10

20
1 2 3 4 5 6
X

You cannot use the PLOT statement option AREAS= with


INTERPOL=NEEDLE.
INTERPOL=NONE
I=NONE
suppresses any interpolation and, if VALUE= is not specified, also suppresses plot
points. If no interpolation method is specified in a SYMBOL statement and if the
graphics option INTERPOL= is not used, INTERPOL=NONE is the default.
You cannot use the PLOT statement option AREAS= with INTERPOL=NONE.
INTERPOL=R<type><0><CLM | CLI<50...99>>
I=R<type><0><CLM | CLI<50...99>>
specifies that a plot is a regression analysis. By default, regression lines are not
forced through plot origins and confidence limits are not displayed.
Type specifies the type of regression. Specify one of these values for type:
L requests linear regression representing the regression equation
Y= 0 + 1 X
Q requests quadratic regression representing the regression
equation
Y= 0 + 1 X + 2 X
2

C requests cubic regression representing the regression equation


Y= 0 + 1 X+ 2 X + 3 X
2 3

Note: When least-square solutions for the parameters are


not unique, the SAS/GRAPH server defaults to a quadratic
equation for the interpolation whereas the Java client and
ActiveX client might pick a cubic solution to use. 4
By default, type is L. The regression line is drawn in the line type specified in
the LINE= option. By default, the type of the regression line is 1.
Note: You must specify type if you use either 0, or CLI, or CLM. 4
To force the regression line through a (0,0) origin, specify:
0 eliminates the 0 parameter, or intercept, from the regression
equation. If the origin is at (0,0), also forces the regression line
through the origin. For example, if you specify 0 for a linear
regression, the plot line represents the equation
Y= 1 X
SAS/GRAPH Statements SYMBOL Statement 193

Note: To force the regression line through the origin (0,0)


when the data ranges do not place the origin at (0,0), use the
GPLOT procedure options HZERO and VZERO (ignored if the
data contain negative values), or use HAXIS and VAXIS to
specify axes ranges from 0 to maximum data value. If the data
ranges contain negative values and HAXIS and VAXIS specify
ranges starting at 0, only values within the displayed range are
used in the interpolation calculations. 4
To display confidence limits, specify one of these:
CLM displays confidence limits for mean predicted values
CLI displays confidence limits for individual predicted values.
You can specify confidence levels from 50% to 99%. By default, the confidence
level is 95%. Include a confidence level specification only if you use CLM or CLI.
The line type used for the confidence limit lines is determined by adding 1 to
the values of LINE=. By default, the line type of confidence limit lines is 2.
Figure 7.18 on page 193 shows the type of plot INTERPOL=RCCLM95 produces
(cubic regression analysis with 95% confidence limits).

Figure 7.18 Plot of Regression Analysis and Confidence Limits

Y
30

*
20 *
** * *
*
** * *
10 * *
* ***
0 *

40 60 80 100 120 140 160


X

Featured in: Example 4 on page 1126.


Not supported by: Java (partial)
INTERPOL=SM<nn><P><S>
I=SM<nn><P><S>
specifies that a smooth line is fit to data using a spline routine. INTERPOL=SM is
a method for smoothing noisy data. The points on the plot do not necessarily fall
on the line.
The relative importance of plot values versus smoothness is controlled by nn.
Values for nn are
0...99 produces a cubic spline that minimizes a linear combination of
the sum of squares of the residuals of fit and the integral of the
square of the second derivative (Reinsch 1967)*. The greater
the nn value, the smoother the fitted curve. By default, the
value of nn is 0.

* Reinsch, C.H. (1967), “Smoothing by Spline Functions,” Numerische Mathematik, 10, 177–183.
194 SYMBOL Statement Chapter 7

In addition, specify one or both of these:


P specifies a parametric cubic spline
S sorts data by the independent variable before plotting.
Not supported by: Java
INTERPOL=SPLINE<P><S>
I=SPLINE<P><S>
specifies that the interpolation for the plot line use a spline routine.
INTERPOL=SPLINE produces the smoothest line and is the most efficient of the
nontrivial spline interpolation methods.
Spline interpolation smoothes a plot line using a cubic spline method with
continuous second derivatives (Pizer 1975)**This method uses a piecewise
third-degree polynomial for each set of two adjacent points. The polynomial passes
through the plotted points and matches the first and second derivatives of
neighboring segments at the points.
Specify one or both of these:
P specifies a parametric spline interpolation method. This
interpolation uses a parametric spline method with continuous
second derivatives. Using the method described earlier for the
spline interpolation, a parametric spline is fitted to both the
horizontal and vertical values. The parameter used is the
distance between points

t = (x2 + y2)
If two points are so close together that the computations
overflow, the second point is not used.
S sorts a data set by the independent variable before plotting its
data.

Note: When points on the graph are out of range of the axis values, the curve is
clipped. If an end point is out of range, no curve is drawn. Out-of-range conditions
may be caused by restricting the range of axis values with the HAXIS= or VAXIS=
option in the PLOT statement or the ORDER= option in an AXIS definition.
Note: When points on the graph are close together and a spline interpolation is
used, the Java applet is unable to draw some line types correctly. 4
4
INTERPOL=STD<1 | 2 | 3><variance><option(s)>
I=STD<1 | 2 | 3><variance><option(s)>
specifies that a solid line connect the mean Y value with ± 1, 2, or 3 standard
deviations for each X.
Note: By default, 2 standard deviations are used. 4

** Pizer, Stephen M. (1975), Numerical Computing and Mathematical Analysis, Chicago: Science Research Associates, Inc.,
Chapter 4.
SAS/GRAPH Statements SYMBOL Statement 195

The sample variance is computed about each mean, and from it, the standard
deviation sy is computed. Variance can be one or both of these:
M computes sy ,
P computes sample variances using a pooled estimate, as in a
one-way ANOVA model.
In addition, specify one of these values for option(s):
B connects the minimum and maximum Y values with bars
instead of lines.
J connects the means from bar to bar with a line.
T adds tops and bottoms to each line.
BJ connects maximum and minimum values with a bar and joins
the mean values.
TJ adds tops and bottoms to the lines and joins the mean values.
Figure 7.19 on page 195 shows the type of plot INTERPOL=STD produces. A
horizontal tick is drawn at the mean. Plot symbols in the form of dots have been
added to this figure.

Figure 7.19 Plot of Standard Deviations

Y
60
50 ●


40 ●
● ●

30 ●


● ●
20 ●

10
0
A B C
X

Note: By default, the vertical axis ranges from the minimum to the maximum
Y value in the data. If the requested number of standard deviations from the
mean covers a range of values that exceeds the maximum or is less than the
minimum, the STD lines are cut off at the minimum and maximum Y values.
When this cutoff occurs, rescale the axis using VAXIS= in the PLOT statement or
ORDER= in an AXIS definition so that the STD lines are shown. 4
If you restrict the range of axis values by using HAXIS= or VAXIS= in a PLOT
statement or ORDER= in an AXIS definition, by default any observations that fall
outside the axis range are excluded from the interpolation calculation. See the
MODE= on page 197 option.
To increase the thickness of all lines generated by the INTERPOL=STD option,
use the WIDTH= option.
You cannot use the PLOT statement option AREAS= with INTERPOL=STD.
This option cannot be used in a symbol definition that is named in the GPLOT
procedure, when that procedure is generating output for the Web using a Java
device driver. This applies only when the PLOT statement is used with the
196 SYMBOL Statement Chapter 7

OVERLAY option, or when the PLOT2 statement is used, with or without the
OVERLAY option.
Not supported by: Java (partial)
INTERPOL=STEP<placement><J><S>
I=STEP<placement><J><S>
specifies that the data are plotted with a step function. By default, the data point
is on the left of the step, the steps are not joined with a vertical line, and the data
are not sorted before processing.
Specify one of these values for placement:
L displays the data point on the left of the step.
R displays the data point on the right of the step.
C displays the data point in the center of the step.
Note: When a step is retraced in order to locate its center
point, both the server and Java treat this as effectively not
drawing that part of the step at all. ActiveX, however, draws
each part of the step—resulting in a somewhat differently
appearing graph. 4
In addition, specify one or both of these:
J produces steps joined with a vertical line.
S sorts unordered data by the independent variable before
plotting.
Figure 7.20 on page 196 shows the type of plot INTERPOL=STEPJR produces.
Plot symbols in the form of dots have been added to this figure.

Figure 7.20 Step Plot

Y
100 ●


75

50 ●

25 ●

0 ● ●

1 2 3 4 5 6 7
X

LINE=line-type
L=line-type
specifies the line type of the plot line in the GPLOT procedure, or the contour line
in the GCONTOUR procedure:
1 a solid line.
2...46 a dashed line.
Line types are shown in Figure 7.22 on page 208. By default, LINE=1.
Note: This option overrides the LineStyle attribute in graph styles. For more
information on graph styles, see SAS Output Delivery System: User’s Guide.
SAS/GRAPH Statements SYMBOL Statement 197

Neither the Java applet nor ActiveX control supports client-side rendering for
GCONTOUR. 4
Not supported by: Java (partial), ActiveX (partial)
MODE=EXCLUDE | INCLUDE
specifies that interpolation calculations exclude or include data values that are
outside the range of plot axes. By default, MODE=EXCLUDE, which excludes
values outside the axis range from any calculations.
If you control the range of values displayed on an axis by using HAXIS= and
VAXIS= in the GPLOT procedure, or ORDER= in an AXIS definition, any data
points that lie outside of the range of the axes are discarded before the
calculations are done for interpolation lines. This has a particularly noticeable
effect on the high-low interpolation methods, which include INTERPOL=HILO,
INTERPOL=BOX, and INTERPOL=STD. Regression analysis also represents only
part of the original data.
See also: “Values Out of Range” on page 1087.
POINTLABEL<=(label-description(s)) | NONE>
labels plot points. The labels always use the format that is assigned to the
variable(s) whose values are used for the labels. POINTLABEL without any
specified descriptions labels points with the Y value. NONE suppresses the point
labels. Label-description(s) can be used to change the variable whose values are
used to label points, and/or to change features of the label text, such as the color,
font, or size of the text.
Note: If you do not specify a color on a SYMBOL statement, the symbol
definition is rotated through the colors list before the next SYMBOL statement is
used. Thus, if your plot contains multiple plot lines and you want to limit your
POINTLABEL specification to a single line, you must specify a color on the
SYMBOL statement that contains the POINTLABEL description. 4
Label-description(s) can be one or more of these:
COLOR=text-color
C=text-color
specifies the color of the label text. The default is the first color from the
colors list.
FONT=font | NONE
F=font | NONE
specifies the font for the text. See Chapter 5, “SAS/GRAPH Fonts,” on page
75 for details on specifying font. If you omit FONT=, a font specification is
searched for in this order:
1 the FTEXT= option in a GOPTIONS statement
2 the default hardware font, NONE.
HEIGHT=text-height <units >
H=text-height <units >
specifies the height of the text characters in number of units. By default,
HEIGHT=1 CELL. If you omit HEIGHT=, a text height specification is
searched for in this order:
1 the HTEXT= option in a GOPTIONS statement
2 the default value, 1.
JUSTIFY=CENTER | LEFT | RIGHT
J=C | L | R
specifies the horizontal alignment of the label text. The default is CENTER.
The location of the point label is relative to the location of the corresponding
data point.
198 SYMBOL Statement Chapter 7

POSITION=TOP | MIDDLE | BOTTOM


specifies the vertical placement of the label text. The default is TOP. The
location of the point label is relative to the location of the corresponding data
point.
“#var” | “#x:#y <$char>” | “#y:#x <$char>”
specifies the variable(s) whose values will label the plot points. The variable
specification must be enclosed in either single or double quotation marks. The
first specified variable must be prefixed with a pound sign (#). If a second
variable is specified, it must be prefixed with a colon and a pound sign (:#).
Optionally, when you specify both the X and Y variables, you can specify the
character to display as the delimiter between variable values in the plot label.
By default if POINTLABEL is specified without naming a label variable,
the Y values label the plot points. You can change the default by using “#var”
to specify a different variable whose values should label the points. For
example, you might specify the name of the X variable. The following option
specifies the variable SALES as the variable whose values will label plot
points:
POINTLABEL=("#sales")

Alternatively, you can label the plot points with the values of the X and Y
variables, in either order. The order that you specify X and Y in the variable
specification determines the order that the values are displayed in the label.
The following option specifies variables HEIGHT and WEIGHT; in the label,
the value for HEIGHT will be displayed, followed by the value for WEIGHT:
POINTLABEL=("#height:#weight")

The variables that you specify must be the plot’s X and Y variables.
Specifying any other variables will cause unexpected labeling.
By default when you specify both the X and Y variables, a colon (:) displays
in the label to separate the values in each label. To change the character that
displays as the delimiter, use the $ syntax to specify an alternative character.
The following option specifies a vertical bar (|) as the delimiter in the label:
POINTLABEL=("#height:#weight $|")

The $ syntax must be within the same quotation marks as the variable
specification. The $ specification can precede or follow the variable
specification, but it must be separated from the variable specification by at
least one space.
Note: Specifying a delimiting character with the $ only changes the
character that displays in the label. It does not change the syntax of the
variable specification, which requires a colon and pound sign (:#) to precede
the second variable. 4
Note: There is a sixteen character length limit for each variable. A
maximum character length limit of thirty-three characters is possible. This
can be composed of X and Y variables, any other valid data set variable, and
a separator as required. 4
Specify as many label-description suboptions as you want. Enclose them all
within a single set of parentheses, and separate each suboption from the others by
at least one space.
Not supported by: Java (partial), ActiveX (partial)

REPEAT=number-of-times
R=number-of-times
SAS/GRAPH Statements SYMBOL Statement 199

specifies the number of times that a SYMBOL definition is applied before the next
SYMBOL definition is used. By default, REPEAT=1.
The behavior of REPEAT= depends on whether any of the SYMBOL color options
(CI=, CV=, CO=, and COLOR=) or the CSYMBOL= graphics option also is used:
3 If any SYMBOL color option also is used in the SYMBOL definition, that
SYMBOL definition is repeated the specified number of times in the specified
color.
3 If no SYMBOL color option is used but the CSYMBOL= graphics option is
currently in effect, the SYMBOL definition is repeated the specified number
of times in the specified color.
3 If no SYMBOL statement color options are used and the CSYMBOL=
graphics option is not used, the SYMBOL definition is cycled through each
color in the colors list, and then the entire group generated by this cycle
repeats the number of times specified by REPEAT=. Thus, the total number
of iterations of the SYMBOL definition depends on the number of colors in
the current colors list.
Neither the Java applet nor ActiveX control supports client-side rendering
for GCONTOUR.
See also: “Using the SYMBOL Statement” on page 202.
Not supported by: Java (partial), ActiveX (partial)
SINGULAR=n
tunes the algorithm used to check for singularities. The default value is machine
dependent but is approximately 1E-7 on most machines. This option is rarely
needed.
STEP=distance<units>
specifies the minimum distance between labels on contour lines. The value of
distance must be greater than zero. By default, STEP=65PCT.
Note: If you specify units of PCT or CELLS, STEP= calculates the distance
between the labels based on the width of the graphics output area, not the height.
For example, if you specify STEP=50PCT and if the graphics output area is 9
inches wide, the distance specified is 4.5 inches. A value less than 10 percent is
ignored and 10 percent is used instead. 4
When you use STEP=, specify the minimum distance that you want between
labels. The option then calculates how many labels it can fit on the contour line,
taking into account the length of the labels and the minimum distance you
specified. Once it has calculated how many labels it can fit while retaining the
minimum distance between them, it places the labels, evenly spaced, along the
line. Consequently, the space between labels may be greater than what you
specify, although it will never be less.
In general, to increase the number of labels from the default, reduce the value
of distance.
If the procedure cannot write the label at a particular location on the contour,
for example because the contour line makes a sharp turn, the label may be placed
farther along the line or omitted. If labels are omitted, a note appears in the log.
Specifying a low value for the GCONTOUR procedure’s TOLANGLE= option may
also cause labels to be omitted, since this forces the procedure to select smoother
labeling locations, which may not be available on some contours.
Featured in: Example 2 on page 906.
Not supported by: Java, ActiveX
VALUE=special-symbol | text-string | NONE
V=special-symbol | text-string | NONE
200 SYMBOL Statement Chapter 7

3 specifies a plot symbol for the data points (GPLOT and GBARLINE). If you
omit the SYMBOL statement, plot points are generated using the default plot
symbol. The default symbol is a square if you use the ActiveX or Java devices
and a PLUS sign for other devices. If you specify a SYMBOL statement, but
do not specify the VALUE= option, plot symbols are suppressed.
Note: For ActiveX output, the VALUE= option is not supported when
INTERPOL=HILO or INTERPOL=STD. You can use the OVERLAY option
with GPLOT to get symbols to appear on the data points. 4
3 specifies contour-label text in a contour plot (GCONTOUR). By default with
the AUTOLABEL option, GCONTOUR labels contour lines with the contour
variable’s value at that contour level.
3 VALUE=NONE suppresses plot symbols at the data points, or labels on the
contour lines. You can set the VALUE=NONE option independent of the
INTERPOL= option.
Values for special-symbol are the names and characters shown in Figure 7.21 on
page 202. The special symbol table can be used only if the FONT= option is not
used or a null value is specified:
font=,

Note: To specify a single quotation mark, you must enclose it in double


quotation marks: 4

value="’"

To specify a double quotation mark, you must enclose it in single quotation


marks:
value=’"’

In some operating environments, punctuation characters may require single


quotes.
If you use VALUE=text-string to specify a plot symbol, you must also use the
FONT= option to specify a symbol font or a text font. If you specify a symbol font,
the characters in the string are character codes for the symbols in the font. If you
specify a text font, the characters in the string are displayed. If you specify a text
string containing quotes or blanks, enclose the string in single quotes.
For example, if you specify this statement, the plot symbol is the word "plus"
instead of the symbol +:
symbol font=swiss value=plus;

Java and ActiveX support the following characters from the marker font for
special-symbol:

Character Aliases

Marker Cone, Pyramid, Default


Square Cube

Star
Circle Sphere, Dot, Balloon

Plus Cross
Flag Y
SAS/GRAPH Statements SYMBOL Statement 201

Character Aliases

X
Prism Z

Spade “
Heart #

Diamond $
Club %

Hexagon Paw
Cylinder Hash

Note: If you do not use a SYMBOL statement to specify a color for each
symbol, but you do specify a colors list in a GOPTIONS statement, then Java and
ActiveX assign colors to symbols differently than does the SAS server. To ensure
consistency on all devices, you should specify the desired color of each symbol.The
SAS server restarts at the first color in the colors list and rotates through all of
the colors in the color list for the first default symbol before going to the next
symbol in the default symbol list where it again rotates through all of the colors in
the color list before picking up the next symbol. 4
Note: The VALUE option overrides the MarkerSymbol attribute in graph
styles. For more information on graph styles, see SAS Output Delivery System:
User’s Guide. 4
See also: the option FONT= on page 186 and “Specifying Plot Symbols” on page
205.
Featured in: “Example 3. Rotating Plot Symbols through the Colors List” on
page 231, “Example 4. Creating and Modifying Box Plots” on page 233, and
Example 2 on page 906.
Not supported by: Java (partial), ActiveX (partial)
WIDTH=thickness-factor
W=thickness-factor
specifies the thickness of interpolated lines (GPLOT) or contour lines
(GCONTOUR), where thickness-factor is a number. The thickness of the line
increases directly with thickness-factor. By default, WIDTH=1.
WIDTH= also affects all the lines in box plots (INTERPOL=BOX), high-low
plots with bars (INTERPOL=HILOB), and standard deviation plots
(INTERPOL=STD). It also affects the outlines of the area generated by the
AREAS= option in the PLOT statement of the GPLOT procedure.
Note: By default, the value specified by WIDTH= is used as the default value
for the BWIDTH= option. For example, specifying WIDTH=6 also sets BWIDTH=
to 6 unless you explicitly assign a value to BWIDTH=.
Java and ActiveX do not provide the same measure of control for width as SAS/
GRAPH on the server. Measurements are translated to pixels rather than a
percentage. 4
Featured in: “Example 1. Ordering Axis Tick Marks with SAS Datetime Values”
on page 226 and “Example 4. Creating and Modifying Box Plots” on page 233.
Not supported by: Java (partial) and ActiveX (partial)
202 Using the SYMBOL Statement Chapter 7

Figure 7.21 Special Symbols for Plotting Data Points

Note: The words or special characters in the VALUE= column are entered exactly as
shown. 4

Using the SYMBOL Statement


A SYMBOL statement specifies one or more options that indicate the color and other
attributes used by the GPLOT procedure or the GCONTOUR procedure. For GPLOT,
the main attributes include the plot symbol, interpolation method, and type of plot line.
For GCONTOUR, the main attributes include the type of contour lines used and the
text used to label those lines.
Note: SYMBOL statements can only be applied to contour plots when the
AUTOLABEL option is specified on GCONTOUR. 4
You can define up to 99 different SYMBOL statements. A SYMBOL statement
without a number is treated as a SYMBOL1 statement.
SYMBOL definitions can be defined anywhere in your SAS program. They are global
and remain in effect until canceled or until you end your SAS session. Once defined,
SYMBOL definitions can be
3 assigned by default by GPLOT or explicitly selected with the plot request
3 used by GCONTOUR to control the labels and attributes of contour lines.
SYMBOL statements generate one or more symbol definitions, depending on how
color is used and whether a plot symbol or type of contour line is specified. For more
SAS/GRAPH Statements Controlling Consecutive SYMBOL Statements 203

information, see “Controlling Consecutive SYMBOL Statements” on page 203 and


“Using Generated Symbol Sequences” on page 208.
Although it is common practice, you do not have to start with SYMBOL1, and you do
not have to use sequential statement numbers. When assigning SYMBOL definitions,
SAS/GRAPH software starts with the lowest-numbered definition and works upward,
ignoring gaps in the numbering.

Altering or Canceling SYMBOL Statements


SYMBOL statements are additive. If you define a SYMBOL statement and later
submit another SYMBOL statement with the same number, the new SYMBOL
statement defines or cancels only the options that are included in the new statement.
Options that are not included in the new statement are not changed and remain in
effect.
Assume you define SYMBOL4 as:
symbol4 value=star cv=red height=4;

The following statement cancels only HEIGHT= without affecting the rest of the
definition:
symbol4 height=;

Add or change options in the same way. This statement adds an interpolation
method to SYMBOL4:
symbol4 interpol=join;

This statement changes the color of the plot symbol from red to blue:
symbol4 cv=blue;

After all these modifications, SYMBOL4 has these characteristics:


symbol4 value=star cv=blue interpol=join;

Cancel individual SYMBOL statements by defining a SYMBOL statement of the


same number without options (a null statement):
symbol4;

Canceling one SYMBOL statement does not affect any other SYMBOL definitions. To
cancel all current SYMBOL statements, use RESET= in a GOPTIONS statement:
goptions reset=symbol;

Specifying RESET=GLOBAL or RESET=ALL cancels all current SYMBOL


definitions as well as other settings.
To display current SYMBOL definitions in the LOG window, use the GOPTIONS
procedure with the SYMBOL option:
proc goptions symbol nolist;
run;

Controlling Consecutive SYMBOL Statements


If you specify consecutively numbered SYMBOL statements and you want
SAS/GRAPH to use each definition only once, use color specifications to ensure each
SYMBOL statement generates only one symbol definition. You can
3 specify colors on each SYMBOL statement, using the COLOR=, CI=, CV=, or CO=
options. This method lets you explicitly assign colors for each definition. For
example, these statements generate two definitions:
204 Setting Definitions for PROC GPLOT Chapter 7

symbol1 value=star color=green;


symbol2 value=square color=yellow;

3 specify a default color for all SYMBOL statements using the CSYMBOL= option
on the GOPTIONS statement. This method makes it easy to specify the same color
for each definition when you do not need more explicit color specifications.
3 limit the colors list to a single color using the COLORS= option on the GOPTIONS
statement. This method makes it easy to specify the same color for each definition
when you want the color to apply to other definitions also, such as PATTERN
definitions.

For more information on specifying colors for symbol definitions, see “Using Color” on
page 206.
If you do not use color to limit a SYMBOL statement to a single symbol definition,
SAS/GRAPH generates multiple symbol definitions from that statement by rotating the
current definition through the colors list (for more details, see “Using Generated Symbol
Sequences” on page 208). Because SAS/GRAPH uses symbol definitions in the order
they are generated, this means that the nth symbol definition applied to a graph does
not necessarily correspond to the SYMBOLn statement.
For example, assuming no color is specified on the CSYMBOL= graphics option,
these statements generate four definitions:
goptions colors=(red blue green);
symbol1 value=star;
symbol2 value=square color=yellow;

Because no color is specified on SYMBOL1, SAS/GRAPH rotates the symbol


definition through the colors list, which has three colors. Thus, SYMBOL1 defines the
first three applied symbol definitions, and SYMBOL2 defines the 4th:

Sequence Number Source Characteristics: Color Symbol

1 SYMBOL1 red star


2 SYMBOL1 blue star

3 SYMBOL1 green star


4 SYMBOL2 yellow square

In this case, if a graph needs only three symbols, the SYMBOL2 definition is not used.
To make the nth applied symbol definition correspond to the SYMBOLn statement,
limit each SYMBOL statement to a single color, using one of the techniques listed at
the beginning of this section.

Setting Definitions for PROC GPLOT


The following topics apply only for SYMBOL statements used with PROC GPLOT:
3 specifying plot symbols
3 specifying default interpolation methods
3 sorting data with spline interpolation.
SAS/GRAPH Statements Setting Definitions for PROC GPLOT 205

Specifying Plot Symbols


The VALUE= option specifies the plot symbols that PROC GPLOT uses to mark the
data points on a plot. Plot symbols can be
3 special symbols from Figure 7.21 on page 202
3 characters from symbol fonts
3 text strings.
By default, the plot symbol is the + symbol. To specify a special symbol, use VALUE=
to specify a name or a character from Figure 7.21 on page 202:
symbol1 value=hash color=green;
symbol2 value=) color=blue;

This example uses color to ensure each SYMBOL statement generates only one
definition. You can omit color specifications to let SAS/GRAPH rotate symbol definitions
through the colors list. For details, see “Using Generated Symbol Sequences” on page
208.
To use plot symbols other than those in Figure 7.21 on page 202, use the FONT=
option to specify a font for the plot symbol. If the font is a symbol font, such as Marker,
the string specified with the VALUE= option is the character code for the symbol to be
displayed. If the font is a text font, the string specified with VALUE= is displayed as
the plot symbol. (See VALUE= on page 199 and FONT= on page 186.)
This table illustrates some of the ways you can define a plot symbol:

Plot
Definition Symbol
symbol1 value=plus;

symbol2 value=+;

symbol3 font=swiss value=plus;

symbol4 font=marker value=U;

symbol5value="’";

Specifying a Default Interpolation Method


The INTERPOL= option in a GOPTIONS statement specifies a default interpolation
method to be used with all SYMBOL definitions. This default interpolation method is in
effect unless you specify a different interpolation in a SYMBOL statement. If the
GOPTIONS statement does not specify an interpolation method, the default for each
SYMBOL statement is NONE.

Sorting Data with Spline Interpolation


If you want the GPLOT procedure to sort by the horizontal axis variable before
plotting, add the letter S to the end of any of the spline interpolation methods
(INTERPOL=L, INTERPOL=SM, and INTERPOL=SPLINE). For example, suppose you
want to overlay three plots (Y1*X1, Y2*X2, and Y3*X3) and for each plot, you want the
X variable sorted in ascending order. Use these statements:
symbol1 i=splines c=red;
symbol2 i=splines c=blue;
206 Using Color Chapter 7

symbol3 i=splines c=green;

proc gplot;
plot y1*x1 y2*x2 y3*x3 / overlay;
run;

Using Color
Generally, there are two ways to explicitly specify color for SYMBOL statements:
3 specify colors on the SYMBOL statements
3 specify a color on the CSYMBOL= graphics option.
You can also let SAS/GRAPH rotate symbol definitions through the colors list. For
details, see “Using Generated Symbol Sequences” on page 208.

Specifying Colors with SYMBOL Statements


The SYMBOL statement has these options for specifying color:
3 The CV= option specifies color for plot symbols in GPLOT, or for contour labels in
GCONTOUR.
3 The CO= option specifies color for confidence limit lines and area outlines in
GPLOT.
3 The CI= option specifies color for plot lines in GPLOT, or contour lines in
GCONTOUR.
3 The COLOR= option specifies color for the entire symbol. For GPLOT, this
includes plot symbols, plot lines, and outlines. For GCONTOUR, this includes
contour lines and labels.
CV= and CI= have the same effect as using COLOR= when they are used in these
ways:
3 Only CV= or CI= option is used. (The option that is not used is assigned the value
of the option used.)
3 Both CV= and CI= specify the same color.
In general, CI=, CV=, and CO= color specific areas of the symbol. Use these options
to produce symbols and plot lines of different colors without having to overlay multiple
plot pairs. For example, if you request regression analysis with confidence limits, use
this statement to assign red to the plot symbol, blue to the regression lines, and green
to the confidence limit lines:
symbol cv=red ci=blue co=green;

The COLOR= option colors the entire symbol or those portions of it not colored by
one of the other color options. If COLOR= precedes CI= or CV=, the CI= or CV=
specification is used instead. If none of the SYMBOL color options is used, color
specifications are searched for in this order:
1 the CSYMBOL= option in a GOPTIONS statement
2 each color in the colors list sequentially before the next SYMBOL definition is used.

CAUTION:
If no color options are used, the SYMBOL definition cycles through each color in the colors
list. 4
SAS/GRAPH Statements Specifying Line Types 207

If the SYMBOL color options and the CSYMBOL= graphics option are not used, the
SYMBOL definition cycles through each color in the colors list before the next definition
is used. For details, see “Using Generated Symbol Sequences” on page 208.

Specifying Color with CSYMBOL=


The CSYMBOL= option on the GOPTIONS statement specifies the default color to be
used by all SYMBOL definitions:
goptions csymbol=green;
symbol1 value=star;
symbol2 value=square;

In this example, both SYMBOL statements use green.


CSYMBOL= is overridden by any of the SYMBOL statement color options. See
“Using Color” on page 206 for details.
If more SYMBOL definitions are needed, SAS/GRAPH returns to generating default
symbol sequences.

Specifying Line Types


To specify the type of line for plot or contour lines, use the LINE= option to specify a
number from 1 through 46. Figure 7.22 on page 208 shows the line types represented
by these numbers. By default, the line type is 1 for plot and contour lines, and 2 for
confidence limit lines.
208 Using Generated Symbol Sequences Chapter 7

Figure 7.22 Line Types

Note: These line types are also used by other statements and procedures. Some
options accept a line type of 0, which produces no line. 4

Using Generated Symbol Sequences


Symbol sequences are sets of SYMBOL definitions that are automatically generated
by SAS/GRAPH software if any of these conditions is true:
3 no valid SYMBOL definition is available. In this case, default symbol sequences
are generated by rotating symbol definitions through the color specified on the
GOPTIONS statement’s CSYMBOL= option. If a CSYMBOL= color is not in effect,
the definitions are rotated through the colors list.
3 a SYMBOL statement specifies color but not a plot symbol for the GPLOT
procedure, or a line type for the GCONTOUR procedure (assuming GCONTOUR
does not specify the needed line types). In this case, a default plot symbol or line
type is used with the specified color and only one definition is generated.
3 a SYMBOL statement specifies a plot symbol for GPLOT or a line type for
GCONTOUR, but no color options. In this case, the specified plot symbol or line
type is used once with the color specified by the CSYMBOL= graphics option. If a
SAS/GRAPH Statements Using Generated Symbol Sequences 209

CSYMBOL= color is not in effect, the specified plot symbol or line type is rotated
through the colors list.
If REPEAT= is also used, the resulting SYMBOL definition is repeated the specified
number of times.

Default Symbol Sequences


Default symbol sequences are generated by rotating symbol definitions through the
current colors list.
3 Definitions used for GPLOT rotate plot symbols through the colors list; the first
default plot symbol is a plus sign (+).
3 Definitions used for GCONTOUR rotate line types; the first default line type is a
solid line (line type 1).
Each time a default definition is required, SAS/GRAPH takes the first default plot
symbol or line type and uses it with the first color in the colors list. If more than one
definition is required, it uses the same plot symbol or line type with the next color in
the colors list and continues until all the colors have been used once. If more definitions
are needed, SAS/GRAPH selects the second default plot symbol or line type and rotates
it through the colors list. It continues in this fashion, selecting default plot symbols or
line types and cycling them through the colors list until all the required definitions are
generated.
If a color has been specified with the CSYMBOL= option on the GOPTIONS
statement, each default plot symbol or line type is used once with the specified color,
and the colors in the colors list are ignored.

Symbol Sequences Generated from SYMBOL Statements


If a SYMBOL statement does not specify color, and if the CSYMBOL= graphics
option is not used, the symbol definition is rotated through every color in the colors list
before the next SYMBOL definition is used:
goptions colors=(blue red green);
symbol1 cv=red i=join;
symbol2 i=spline v=dot;
symbol3 cv=green v=star;

Here, the SYMBOL1 statement generates the first SYMBOL definition. The
SYMBOL2 statement does not include color, so the first default plot symbol is rotated
through all colors in the colors list before the SYMBOL3 statement is used. This table
shows the colors and symbols that would be used if nine symbol definitions were
required for PROC GPLOT:

Sequence Characteristics:
Number Source Color Symbol Interpolation

1 SYMBOL1 cv=red first default join

2 SYMBOL2 color=blue dot spline


3 SYMBOL2 color=red dot spline

4 SYMBOL2 color=green dot spline


5 SYMBOL3 cv=green star NONE

6 first default color=blue first default default


7 first default color=red first default default
210 TITLE, FOOTNOTE, and NOTE Statements Chapter 7

Sequence Characteristics:
Number Source Color Symbol Interpolation
8 first default color=green first default default

9 second color=blue second default


default default

Notice that after the SYMBOL statements are exhausted, the procedure begins using
the default definitions (sequences 6 through 9). Each plot symbol from the default list is
rotated through all colors in the colors list before the next plot symbol is used. Also,
SYMBOL1 does not specify a plot symbol, so the default sequencing provides the first
default symbol (a + sign). When sequencing resumes in sequence number 6, it starts at
the beginning again, selecting the first default plot symbol and rotating it through the
colors list.
If you use REPEAT= but no color, the sequence generated by cycling the definition
through the colors list is repeated the number of times specified by REPEAT=. For
example, these statements define a colors list and illustrate the effect of REPEAT= on
SYMBOL statements both with and without explicit color specifications:
goptions colors=(blue red green);
symbol1 color=gold repeat=2;
symbol2 value=star color=cyan;
symbol3 value=square repeat=2;

Here, SYMBOL1 is used twice, SYMBOL2 is used once, and SYMBOL3 rotates
through the list of three colors and then repeats this cycle a second time:

Sequence Characteristics:
Number Source Color Symbol Interpolation

1 SYMBOL1 gold first default default


2 SYMBOL1 gold first default default

3 SYMBOL2 cyan star default


4 SYMBOL3 blue square default

5 SYMBOL3 red square default


6 SYMBOL3 green square default

7 SYMBOL3 blue square default


8 SYMBOL3 red square default

9 SYMBOL3 green square default

TITLE, FOOTNOTE, and NOTE Statements


The TITLE, FOOTNOTE, and NOTE statements control the content, appearance,
and placement of text.
Used by:
SAS/GRAPH Statements TITLE, FOOTNOTE, and NOTE Statements 211

GBARLINE, GCHART, GCONTOUR, GFONT, GMAP, GPLOT, GPRINT,


GRADAR, GSLIDE, G3D procedures
Global: TITLE and FOOTNOTE

Description
TITLE, FOOTNOTE, and NOTE statements add text to maps, plots, charts, and text
slides. With these statements you can
3 control the content, appearance, and placement of the text, including color, size,
font, and alignment
3 underline or draw boxes around the text
3 draw straight lines on the output.
Figure 7.23 on page 211 shows the default appearance and placement of titles,
footnotes, and notes on the graphics output area.

Figure 7.23 Default Placement of Titles, Footnotes, and Notes

(This is the Title Area)


Default position for the NOTE statement.
By default the text is left justified at
the top left of the procedure output area.

Default position for FOOTNOTE1


(This is the Footnote Area)

Titles are centered at the top of the graphics output in the title area. They are
positioned in numeric order with the lowest-numbered TITLE at the top of the title
area and the highest-numbered TITLE at the bottom of the title area.
TITLE statements have these default characteristics:
3 TITLE1 is twice the height of all other titles and uses the SWISS font.
3 All other TITLE statements are one unit high and use the default hardware font.
Footnotes are positioned similarly in the footnote area at the bottom of the graphics
output area, with the lowest numbered FOOTNOTE at the top of the footnote area.
Unless otherwise specified, they use the default hardware font and are one unit high.
Space for the title area and the footnote area is taken from the procedure output
area. The more titles and footnotes you specify and the bigger they are, the smaller the
procedure output area will be.
Notes are positioned at the top of the procedure output area and are left justified.
The statements appear one below another in the order they appear in the program.
Unless otherwise specified, they use the default hardware font and are one unit high.
For more information on titles, footnotes, and notes in the graphics output area, see
“Placement of Graphic Elements in the Graphics Output Area” on page 39.
212 TITLE, FOOTNOTE, and NOTE Statements Chapter 7

Syntax
TITLE<1...10>< text-argument(s)>;
FOOTNOTE<1...10>< text-argument(s)>;
NOTE< text-arguments(s)>;

text-argument(s) can be one or more of these:


’text-string’
text-options (text options must precede text-str