DBARCHART procedure

Produces barcharts for one or two-way tables (Ruth Butler).


Options

TITLE = text
Title for the chart; no default

WINDOW = scalar
Window for the chart (1...8); default 1

KEYWINDOW = scalar
Window for the key, no key is produced for one-way tables (1...8); default 2

LABELS = text
Labels for clusters of bars; by default the labels or levels of the first classifying factor of TABLE are used

APPEND = string
Whether to append bars (no, yes); default no

SCREEN = string
Whether to clear screen before displaying chart (keep, clear); default clea

KEYDESCRIPTION = text
Title for key; default is the name of the second factor of TABLE

YSCALE = expression
Defines a transformation of the data, the expression must be a function of either Y or X, for example !e(log(X)), and should be valid for the range of the data in TABLE; default no transformation

BELOWORIGIN = string
Whether to include or values in TABLE less than ORIGIN (omit, include); default omit

ORIENTATION = string
Direction of the plot (horizontal, vertical); default vert


Parameters

TABLE = tables
One or two-way table of data

ORIGIN = scalars
Origin for y-axis; default 0

PEN = variates or scalars
Pen (or pens) to use; default is !(1 ... nlevel(last_classifying_factor))

DESCRIPTION = texts
Annotation for Key for two-way tables; by default the labels or levels of the last classifying factor of TABLE are used

YMARKS = variates
Position of the tick-marks on the y-axis


Description

DBARCHART produces barcharts for one or two-way tables. A transformation can be specified by the option YSCALE, in which case the data and y-axis are rescaled, but the y-axis is labelled on the original scale of the data. Bar charts of two-way tables are produced with the first factor defining the groups of bars in the chart, and the second the bars within each group. The table is specified by the TABLE parameter and the origin of the y-axis, which need not be zero, can be set with the ORIGIN parameter or with XAXIS. The PEN parameter specifies a pen, or pens, for the bars of the histogram. This can be input as a scalar if the same pen is to be used for the whole plot, or as a variate to allow the groups to be drawn in different pens; by default pens 1, 2 ... are used for the successive bars. Labelling for the key can be supplied by the DESCRIPTION parameter; if this is not set, DBARCHART uses the labels of the first classifying factor. Positions of the tick-marks on the y-axis can be specified with the YMARKS parameter or with YAXIS. Upper and lower limits for the y-axis can be defined as normal with an AXIS or YAXIS statement before DBARCHART is used.

   The options of the procedure mainly control the plotting: the windows that are used for the plot (WINDOW) and for the key (KEYWINDOW), titles for the graph (TITLE) and for the key (KEYDESCRIPTION), whether the groups of bars are appended or placed side-by-side (APPEND), and whether or not to clear the screen before plotting (SCREEN). Normally values in TABLE less than ORIGIN are omitted but, if you set BELOWORIGIN=include, bars will be drawn for these values extending below the x-axis. The ORIENTATION option controls whether the bars of the histogram are plotted vertically (the default) or horizontally. When ORIENTATION=horizontal, the horizontal axis is taken to be the y-axis, so the same XAXIS and YAXIS settings can be used however the histogram is oriented.

 

Options: TITLE, WINDOW, KEYWINDOW, LABELS, APPEND, SCREEN, KEYDESCRIPTION, YSCALE, BELOWORIGIN, ORIENTATION.

Parameters: TABLE, ORIGIN, PEN, DESCRIPTION, YMARKS.


Method

If YSCALE is set, the expression is used to transform TABLE and ORIGIN. Any YMARKS are also transformed to find the position of the tick-marks. TABLE is then rescaled so that the ORIGIN is zero. The y-axis is set up with the labelling on the original scale of TABLE. Two-way tables are first split into one-way tables classified by the second factor of TABLE. One sub-table is produced for each level of the first factor of TABLE. The chart is then produced with a single DHISTOGRAM statement for all sub-tables. YSCALE is imported into the program by setting Y or X as a dummy, and printing the expression into a text. A new expression is then set up using this text with the EXECUTE directive. Y (or X) is then set to ORIGIN, TABLE and YMARKS in turn before the expression is calculated.