1. Home
  2. TABLE directive

TABLE directive

Declares one or more table data structures.

Options

CLASSIFICATION = factors Factors classifying the tables; default *
MARGINS = string token Whether to add margins (yes, no); default no
VALUES = numbers Values for all the tables; default *
MODIFY = string token Whether to modify (instead of redefining) existing structures (yes, no); default no
IPRINT = string tokens Information to be used by default to identify the tables in output (identifier, extra, associatedidentifier); if this is not set, they will be identified in the standard way for each type of output

Parameters

IDENTIFIER = identifiers Identifiers of the tables
VALUES = identifiers Values for each table
DECIMALS = scalars Number of decimal places for printing
EXTRA = texts Extra text associated with each identifier
UNKNOWN = identifiers Identifier for scalar to hold summary of unclassified data associated with each table
MINIMUM = scalars Minimum value for the contents of each structure
MAXIMUM = scalars Maximum value for the contents of each structure
DREPRESENTATION = scalars or texts Default format to use when the contents represent dates and times
DATAVARIATE = variates Records the identifier of the variate whose summaries are in the table
SUMMARYTYPE = string tokens Records the type of summary that the table contains (counts, totals, nobservations, means, minima, maxima, variances, quantiles, sds, skewness, kurtosis, semeans, seskewness, sekurtosis); default * i.e. not recorded
PERCENTQUANTILE = scalars Records the percentage points for which quantiles have been formed; default * i.e. not recorded
%MARGIN = pointers Records the factors defining the margin over which the table has been converted to percentages

Description

Tables are used to store numerical summaries of data that are classified into groups. With Genstat, the classification into groups is specified by a set of factors. The table contains an element, called a cell, for each combination of the levels of the factors that classify it.

Tables are declared using the TABLE directive. The CLASSIFICATION option specifies the factors classifying the table.

Values can be assigned to the tables by either the VALUES option or the VALUES parameter. The option defines a common value for all the tables in the declaration, while the parameter allows them each to be given a different value. If both the option and the parameter are specified, the parameter takes precedence.

If the MODIFY option is set to yes any existing attributes and values of the tables are retained (if still appropriate); otherwise these are lost.

The DECIMALS parameter allows you to define a number of decimal places to be used by default when each table is printed. You can associate a text of extra annotation with each table using the EXTRA parameter. The MINIMUM and MAXIMUM parameters allow you to define lower and upper limits on the values in each table. Genstat then prints warnings if values outside that range are allocated to the table. The DREPRESENTATION parameter allows a scalar or a single-valued text to be specified for each table to indicate that the table stores dates and times, and to define a format to be used for these, by default, when they are printed; details are given in the description of the PRINT directive.

A table can also have margins. There is then a margin for each classifying factor; this contains some sort of summary over the levels of that factor. For example, if you have a table in which the cells contain totals of the observations, you would want the marginal cells to contain totals across the levels of the factor. You can define a table to have margins when you declare it, by setting the MARGINS option of the TABLE directive to yes. Alternatively you can add margins later by the MARGIN directive.

Tables also have an associated scalar which collects a summary of all the observations for which any of the classifying factors has a missing value; these observations cannot be assigned to any cell of the table itself. This scalar is known as the unknown cell of the table. It can be given an identifier, so that you can refer to it, using the UNKNOWN parameter of the TABLE directive.

The IPRINT option can be set to specify how the tables will be identified in output:

    identifier uses the identifier;
    extra uses the EXTRA text;
    associatedidentifier uses the “associated identifier”, if available; this is the identifier of the data variate from which the summaries in the table have been formed.

If IPRINT is not set, the tables will be identified in whatever way is usual for the section of output concerned.

The attribute of the table that records its data variate is set automatically when a table of summaries is formed by the TABULATE directive. If you have formed the summaries in some other way, you can use the DATAVARIATE parameter to record the relevant variate yourself. The SUMMARYTYPE parameter can set an attribute recording the type of summary that the table contains, and the PERCENTQUANTILE parameter can set an attribute recording the corresponding percentage if the table contains quantiles. (These are alse set automatically for tables formed by TABULATE.) The %MARGIN parameter can be set to a pointer of factors defining the margin of the table over which it has been converted to percentages. The pointer may contain just a scalar if the percentages have been formed over the “grand” margin (e.g. the grand total or grand mean). See the PERCENT procedure (which will set this attribute automatically) for further details. If any of these parameters is not set, the default is to leave the corresponding attribute of the table unchanged. To clear the existing value of one of these attributes, you can put a missing value into the corresponding parameter setting. For example

TABLE Tab; DATAVARIATE=*; SUMMARYTYPE=*; PERCENTQUANTILE=*;\

      %MARGIN=*

clears all these attributes for the table Tab.

Options: CLASSIFICATION, MARGINS, VALUES, MODIFY, IPRINT.

Parameters: IDENTIFIER, VALUES, DECIMALS, EXTRA, UNKNOWN, MINIMUM, MAXIMUM, DREPRESENTATION, DATAVARIATE, SUMMARYTYPE, PERCENTQUANTILE, %MARGIN.

See also

Directives: FACTOR, TABULATE, MARGIN, COMBINE.

Procedures: DTABLE, MTABULATE, PERCENT, SVSTRATIFIED, SVTABULATE, TABMODE, TABINSERT, TABSORT, T%CONTROL.

Commands for: Data structures.

Example

" Example TABL-1: declaring a table"
FACTOR [LABELS=!T(boy,girl)] Sex
FACTOR [LEVELS=5] Class
TABLE [CLASSIFICATION=Class,Sex; VALUES=15,17,29,31,34,30,33,35,28,27]\ 
  Classnum 
PRINT Classnum; DECIMALS=0

" Now a three-way table"
FACTOR [LEVELS=2] School 
TABLE [CLASSIFICATION=School,Class,Sex;\ 
  VALUES=15,17,29,31,34,30,33,35,28,27,18,16,33,31,35,36,34,33,31,32]\ 
  Schoolnm 
PRINT Schoolnm; DECIMALS=0

" Add margins to both tables"
MARGIN Classnum,Schoolnm
PRINT Classnum; DECIMALS=0
PRINT Schoolnm; DECIMALS=0
Updated on February 9, 2022

Was this article helpful?