Chapter 14
Creating Graphs With No Axis
Using the REGION Layout
The LAYOUT REGION Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Examples: Region Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Example 1: Pie Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Example 2: Bar Chart and Pie Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Example 3: Mosaic Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
The LAYOUT REGION Statement
The LAYOUT REGION statement supports plots that have no axes, such as pie charts. It
also supports annotations such as text, lines, arrows, images, and geometric shapes, that
are generated with the draw statements. For information about adding annotations, see
Chapter 18, “Adding Code-Driven Graphics Elements to Your Graph,” on page 381.
The LAYOUT REGION statement allows only one plot statement. If you include more
than one, the additional plot statements are ignored. You can include
DISCRETELEGEND, CONTINUOUSLEGEND, and ENTRY statements with your
region plot statement. You can use a LAYOUT REGION statement to define a top-level
region container or to define a region container for a single cell in a LAYOUT
GRIDDED or LAYOUT LATTICE statement. You can also nest a REGION layout in
other layouts, such as GRIDDED, LATTICE, and overlay-type layouts. However, the
REGION layout cannot be nested in DATAPANEL and DATALATTICE layouts.
Note: When you nest a REGION layout in an overlay-type layout, you must include the
HEIGHT=, WIDTH=, VALIGN=, and HALIGN= options in your LAYOUT
REGION statement to specify the size and alignment of the plot.
Examples: Region Layout
Example 1: Pie Chart
This example uses a LAYOUT REGION statement to create the pie chart that is shown
in the following figure.
273
Here is the SAS code that generates this chart.
/* Define the template for the chart */
proc template;
define statgraph region;
begingraph;
entrytitle "Sales By State";
layout region;
piechart category=state response=actual /
dataskin=pressed datalabellocation=outside;
endlayout;
endgraph;
end;
run;
quit;
/* Set the antialias maximum to 15000 */
ods graphics on / reset antialiasmax=15000;
/* Render the chart */
proc sgrender data=sashelp.prdsal2 template=region;
where country eq "U.S.A.";
format actual dollar12.0;
run;
quit;
274 Chapter 14 Creating Graphs With No Axis Using the REGION Layout
Example 2: Bar Chart and Pie Chart
This example nests a LAYOUT OVERLAY and a LAYOUT REGION statement in a
LAYOUT LATTICE block to create the charts shown in the following figure.
Here is the SAS code that generates these charts.
/* Get sales data in millions from SASHELP.PRDSAL2 */
data sales;
set sashelp.prdsal2;
actualmils=(actual / 1000000);
run;
/* Define the template for the graph */
proc template;
define statgraph region;
begingraph;
entrytitle "Sales By State";
layout gridded / columns=1 rows=2;
layout lattice / columns=2 rows=1;
cell;
/* Generate a bar chart of sales in millions. */
cellheader;
entry "Sales in Millions";
endcellheader;
layout overlay / width=250px
xaxisopts=(display=none)
yaxisopts=(griddisplay=on display=(ticks tickvalues));
barchart category=state response=actualmils /
group=state
orient=vertical
Examples: Region Layout 275

Get SAS 9.4 Graph Template Language, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.