Previous Page | Next Page

The SGPLOT Procedure

XAXIS, X2AXIS, YAXIS, Y2AXIS Statements


specify the axis options for each plot axis.


Description

The XAXIS, X2AXIS, YAXIS, and Y2AXIS statements specify options for the plot axes. You can control the features of the axis (for example, the axis label, grid lines, and minor tick marks) and you can also control the structure of the axis (for example, the data range, data type, and tick mark values).

The XAXIS, X2AXIS, YAXIS, and Y2AXIS statements correspond to the axes as follows:

XAXIS

specifies options for the X axis.

X2AXIS

specifies options for the X2 axis.

YAXIS

specifies options for the Y axis.

Y2AXIS

specifies options for the Y2 axis.


Syntax

XAXIS option(s);
X2AXIS option(s);
YAXIS option(s);
Y2AXIS option(s);

option(s) can be one or more options from the following:

DISCRETEORDER= DATA | FORMATTED | UNFORMATTED

DISPLAY= ALL | NONE | (options)

FITPOLICY= policy-value

GRID

INTEGER

INTERVAL= interval-value

LABEL= "text-string "

LOGBASE= 2 | 10 | e

LOGSTYLE= LINEAR | LOGEXPAND | LOGEXPONENT

MAX= numeric-value

MIN= numeric-value

MINOR

NOTIMESPLIT

OFFSETMAX= numeric-value

OFFSETMIN= numeric-value

REFTICKS

TICKVALUEFORMAT= DATA | sas-format

TYPE= DISCRETE | LINEAR | LOG | TIME

VALUES= ( value-1 < ... value-n > )

VALUESHINT


Options

DISCRETEORDER= DATA | FORMATTED | UNFORMATTED

specifies the order in which discrete tick values are placed on the axis. Specify one of the following values:

DATA

places the values in the order in which they appear in the data.

FORMATTED

sorts the formatted values in ascending character order.

UNFORMATTED

sorts the unformatted values in ascending character order.

Default: UNFORMATTED
Restriction: This option affects only box plots, dot plots, bar charts, and line plots, or for any axis where TYPE=DISCRETE.
DISPLAY= ALL | NONE | (options)

specifies which features of the axis are displayed. ALL displays all of the features of the axis. NONE specifies that none of the features of the axis are displayed. You can also hide specific features:

NOLABEL

hides the axis label

NOLINE

hides the axis line

NOTICKS

hides the tick marks on the axis

NOVALUES

hides the tick mark values on the axis

Default: ALL
FITPOLICY= policy-value

specifies the method that is used to fit tick mark values on a horizontal axis when there is not enough room to draw them normally. Select one of the following values:

ROTATE

rotates the value text 45 degrees. This is the default for discrete axes.

ROTATETHIN

attempts to use ROTATE, and then THIN to fit the values.

STAGGER

shifts the values up and down.

STAGGERROTATE

attempts to use STAGGER, and then ROTATE to fit the values.

STAGGERTHIN

attempts to use STAGGER, and then THIN to fit the values.

THIN

removes some of the values from the axis. This is the default for linear and time axes.

Note:   This option does not affect vertical axes; only the THIN fit policy is used for vertical axes.  [cautionend]

GRID

creates grid lines at each tick on the axis.

INTEGER

specifies that only integers are used for tick mark values. This option affects only linear axes.

INTERVAL= interval-value

specifies the tick interval for a time axis. Specify one of the following values:

AUTO

determines the tick interval automatically based on the data.

SECOND

places ticks one second apart. The default tick value format is TIME8.

MINUTE

places ticks one minute apart. The default tick value format is TIME8.

HOUR

places ticks one hour apart. The default tick value format is TIME8.

DAY

places ticks one day apart. The default tick value format is DATE9.

WEEK

places ticks one week apart. The default tick value format is DATE9.

TENDAY

places ticks ten days apart. The default tick value format is DATE9.

SEMIMONTH

places ticks at the first and sixteenth day of each month. The default tick value format is DATE9.

MONTH

places ticks one month apart. The default tick value format is MONYY7.

QUARTER

places ticks three months apart. The default tick value format is YYQC6.

SEMIYEAR

places ticks six months apart. The default tick value format is MONYY7.

YEAR

places ticks one year apart. The default tick value format is YEAR4.

Default: AUTO
Restriction: This options is available with SAS 9.2 Phase 2 and later.
LABEL= "text-string"

specifies a label for the axis.

LOGBASE= 2 | 10 | e

specifies the base value for the logarithmic scale.

Default: 10
Interaction: This option has no effect unless you also specify TYPE=LOG.
LOGSTYLE= LINEAR | LOGEXPAND | LOGEXPONENT

specifies how to scale and format the values for the major tick marks for logarithmic axes. Specify one of the following values:

LOGEXPAND

places the tick marks at integer powers of the base. For example, if you specified LOGBASE=2, the tick marks might be at 1, 2, 4, 8, 16. See Graph Axes with LOGEXPAND.

Graph Axes with LOGEXPAND

[Example of an Axis with LOGEXPAND]

LOGEXPONENT

places the tick marks at integer powers of the base, but identifies the values by the exponent. For example, if you specified LOGBASE=10, the tick marks might be at 1, 10, 100, 1000, but the tick values would read 0, 1, 2, 3. See An Axis with LOGEXPONENT.

An Axis with LOGEXPONENT

[Example of an Axis with LOGEXPONENT]

LINEAR

places the tick marks at uniform linear intervals, but spaces them logarithmically. In some cases an intermediate tick mark is placed between the first and second marks.

For example, if the data on this axis range from 14 to 1154, and you specify LOGBASE=10, then the tick marks might be at 10, 40, 200, 400, 600, 800, 1000, 1200. See An Axis with LINEAR.

An Axis with LINEAR

[Example of an Axis with LINEAR]

Default: LOGEXPAND
Interaction: This option has no effect unless you also specify TYPE=LOG.
MAX= numeric-value

specifies the maximum value for the axis.

Interaction: This option has no effect if you specify the VALUES= option and you do not also specify the VALUESHINT option.
Restriction: This option affects linear and time axes only .
MIN= numeric-value

specifies the minimum value for the axis.

Interaction: This option has no effect if you specify the VALUES= option and you do not also specify the VALUESHINT option.
Restriction: This option affects linear and time axes only .
MINOR

adds minor tick marks to the axis.

Interaction: This option has no effect if you specify the VALUES= option.
Restriction: This option has no effect on discrete axes.
NOTIMESPLIT

prevents a time axis from splitting the time, date, or datetime values into two rows.

Restriction: This option applies to time axes only.
OFFSETMAX= numeric-value

specifies the amount of offset space between the last tick mark on the axis and the edge of the plot area. Specify a value between 0 and 1. The value represents the offset as a proportion to the total length of the axis. For example, .12 specifies that the offset space for the last tick mark is 12% of the total axis length.

By default, the offset space is determined automatically based on the tick mark values, markers, and labels that are inside of the plot area.

Restriction: This option is available with SAS 9.2 Phase 2 and later.
OFFSETMIN= numeric-value

specifies the amount of offset space between the first tick mark on the axis and the edge of the plot area. Specify a value between 0 and 1. The value represents the offset as a proportion to the total length of the axis. For example, .12 specifies that the offset space for the first tick mark is 12% of the total axis length.

By default, the offset space is determined automatically based on the tick mark values, markers, and labels that are inside of the plot area.

Restriction: This option is available with SAS 9.2 Phase 2 and later.
REFTICKS

adds tick marks to axis that is opposite from the specified axis. For example, if you specify the REFTICKS option in the XAXIS statement, then tick marks are added to the X2 axis.

Note:   This option has no effect if the target axis already contains data.  [cautionend]

TICKVALUEFORMAT= DATA | SAS-format

specifies the format for the axis tick values. You can either specify a SAS format or specify DATA, which indicates that the format from the axis variable is used.

Restriction: This option is available with SAS 9.2 Phase 2 and later.
TYPE= DISCRETE | LINEAR | LOG | TIME

specifies the type of axis. Specify one of the following values:

DISCRETE

specifies an axis with discrete values. If a character variable is assigned to an axis, then the default type for that axis is discrete. Additionally, all categorization plots use a discrete axis for the category variable.

LINEAR

specifies a linear scale for the axis. This is the default axis type for numeric variables that do not have date or time formats.

LOG

specifies a logarithmic scale for the axis. This axis type is never a default.

Interaction: A logarithmic scale cannot be used with linear regression plots (REG statement where DEGREE=1).
TIME

specifies a time scale for the axis. If the variable assigned to an axis has a time, date, or datetime format associated with it, then time is the default axis type.

VALUES= ( values-list )

specifies the values for the ticks on the axis.

For values on a numeric axis, the values list can be one of the following:

value <...value-n>

creates ticks for specific values. For example, VALUES= (0 50 100) places tick marks at 0, 50, and 100.

value-1 TO value-2 BY increment-value

creates ticks for a range of values. The start of the value range is specified by value-1 and the end of the range is specified by value-2. The increment-value specifies the interval between the ticks. For example, VALUES= (0 to 100 by 50) creates tick marks at 0, 50, and 100.

You can also create ticks in descending order by using a negative increment value. For example, VALUES= (100 to 0 by -25) creates tick marks at 100, 75, 50, 25, and 0.

<value ... value-n> value-1 TO value-2 BY increment-value <value ... value-n>

creates ticks for specific values, and additionally creates ticks for a range of values. The start of the value range is specified by value-1 and the end of the range is specified by value-2. The increment-value specifies the interval between the ticks.

For example, VALUES= (-5 10 to 50 by 20 75) creates tick marks a -5, 10, 30, 50, and 75.

For values on a time axis, the values list can be one of the following:

value <...value-n>

creates ticks for specific values. For example, VALUES= ("25MAY08"d "04JUL08"d "23AUG08"d) places tick marks at 25MAY08, 04JUL08, and 23AUG08.

value-1 TO value-2 BY increment-value

creates ticks for a range of values. The start of the value range is specified by value-1 and the end of the range is specified by value-2. The increment-value specifies the interval between the ticks. For example, VALUES= ("01JAN08"d to "01MAY08"d by month) creates tick marks at 01JAN08, 01FEB08, 01MAR08, 01APR08, and 01MAY08.

For a list of the interval values that you can specify, see the INTERVAL= option.

Restrictions: This option has no effect on discrete and logarithmic axes.

If your VALUES= option creates more than 1000 values, then the option has no effect.

VALUESHINT

specifies that the minimum and maximum axis values are determined independently of the values you specify in the VALUES= option. The values from the VALUES= option are displayed only if they are located between the minimum and maximum values.

Note:   This option has no effect unless you also specify the VALUES= option.  [cautionend]

Previous Page | Next Page | Top of Page