1. Home
  2. TALLY procedure

TALLY procedure

Forms a simple tally table of the distinct values in a vector (D.B. Baird & R.D. Stern).

Options

PRINT = string tokens What to print out for each vector (frequencies, percentages, cumfrequencies, cumpercentages, cumgraph, all); default freq, perc
GRAPH = string tokens What to display as graphs (cumulative, %cumulative); default * i.e. no graphs
NGROUPS = scalar Number of groups to form from a DATA variate or factor (ignored for texts); default * forms a group for each distinct value allowing for rounding (see DECIMALS)
DECIMALS = scalar Number of decimal places to which to round the DATA before forming the groups; default * i.e. no rounding
BOUNDARIES = string token Whether to interpret the LIMITS as upper or lower boundaries (upper, lower); default lowe
DIRECTION = string token Order in which to sort (ascending, descending); default asce
OMITEMPTY = string token Whether empty groups are omitted (yes, no); default no
WEIGHTS = variate Weights to be used in the tabulations; default * indicates that all units have weight 1
PQUANTILES = string token Whether to include quantiles on the plot (yes, no); default no
WINDOW = scalar Window in which to plot the graphs; default 1 if GROUPS is set, or 3 otherwise
KEYWINDOW = scalar Window in which to display the key when GROUPS is set; default 2
SCREEN = string token Whether to clear screen before the plot (clear, keep); default clea

Parameters

DATA = variates, factors or texts Data to be tallied
GROUPS = factors Defines groupings of the data, to be tallied into separate tables; default * i.e. none
LIMITS = variates or texts Limits to define the groups within the tally tables
FREPRESENTATION = string tokens Specifies the representation used to define the sort order of a DATA factor (ordinals, levels, labels); default leve
VALUES = variates, texts or pointers Saves the distinct groups formed for the tally tables
FREQUENCIES = variates or pointers Saves the frequencies of the groups in the tally tables
PERCENTAGES = variates or pointers Saves the percentage occurrences of the groups
CUMFREQUENCIES = variates or pointers Saves the cumulative frequencies of the groups
CUMPERCENTAGES = variates or pointers Saves the cumulative percentages of the groups
TITLE = texts Title for plot; default automatically forms a title containing the identifiers of the DATA vector and any GROUPS factor
XTITLE = texts Title for the axis representing data values; default uses the identifier of the DATA vector

Description

TALLY forms and displays simple tally tables of a vector, giving the counts, percentages, and cumulative counts and percentages of each distinct value. The data values are specified by the DATA parameter, in either a variate, a factor or a text. You can also define groups, by specifying a factor using the GROUPS parameter. Separate tables are then formed for each group.

By default, the factor classifying the groups within the tally tables contains a level for each distinct data value. You can decrease the number of groups formed from a DATA variate or text by specifying the NGROUPS and DECIMALS options, or the LIMITS parameter. These work exactly as in the GROUPS directive. If limits are specified, the BOUNDARIES option controls whether these are interpreted as upper or lower boundaries of the groups; by default they are lower limits. The value that is used to represent each group is the median of the units in the group.

The WEIGHTS option can supply a variate of weights for the units of the vector, to be used when calculating the table. If this is not set, the units are all assumed to have weights equal to one.

The PRINT option controls which summaries are printed. The DIRECTION option controls the order of the tally table (ascending or descending). For a DATA factor, the FREPRESENTATION parameter controls which attribute is used to sort the groups (ordinals, levels or labels); by default the levels are used. The OMITEMPTY option can be used to omit empty groups.

The GRAPH option may be set to cumulative to produce a cumulative frequency graph, or %cumulative to produce a percentage graph. The PQUANTILES option controls whether or not the graphs include quantiles. The WINDOW and KEYWINDOW options specify the numbers of the windows to use for the plot and key respectively, and the SCREEN option controls whether the screen is cleared first, in the usual way. The TITLE parameter allows you to define an overall title for the graphs, and the XTITLE parameter allows you to define a title for their x-axes. If these are not set, suitable titles are defined automatically.

The VALUES, FREQUENCIES, PERCENTAGES, CUMFREQUENCIES, CUMPERCENTAGES parameters can be used to save the information. This is in variates or texts, if there are no GROUPS; otherwise it is in pointers, containing a variate or text for each group.

Options: PRINT, GRAPH, NGROUPS, DECIMALS, BOUNDARIES, DIRECTION, OMITEMPTY, WEIGHTS, PQUANTILES, WINDOW, KEYWINDOW, SCREEN.

Parameters: DATA, GROUPS, LIMITS, FREPRESENTATION, VALUES, FREQUENCIES, PERCENTAGES, CUMFREQUENCIES, CUMPERCENTAGES, TITLE, XTITLE.

Method

The GROUPS directive is called for a DATA variate or text, to form the grouping factor within the tally tables. TABULATE then forms the counts for each group.

Action with RESTRICT

Restricted units are left out of the tally results.

See also

Directive: TABULATE.

Procedures: DESCRIBE, MTABULATE, SVSTRATIFIED, SVTABULATE, TABMODE.

Commands for: Basic and nonparametric statistics, Calculations and manipulation, Survey analysis.

Example

CAPTION 'TALLY example'; STYLE=meta
CALC    [SEED=971064] X = GRNORMAL(200;10;3.3)
 &      IntX   = ROUND(X)
 &      Limits = !(-8...8) + 10
TEXT    Txt; !T((A,2(B,2(C)),3(D))3,A,B,E)
GROUPS  X; FacX; LIMITS=Limits
TEXT    Labs; !t(S,R,Q,P,N,M,L,K,J,I,H,G,F,E,D,C,B,A)
FACTOR  [MODIFY=yes;labels=Labs] FacX
TALLY   IntX,Txt,FacX
TALLY   [PRINT=frequencies,cumfrequencies;DIRECTION=descending] IntX
TALLY   [BOUNDARIES=upper;OMITEMPTY=yes] X; LIMITS=Limits
TALLY   [NGROUPS=10] X
TALLY   FacX; FREPRESENTATION=labels
TALLY   [PRINT=*;GRAPH=cumulative] X; VALUES=V; CUMPERCENTAGES=C
TALLY   [PRINT=*;DIRECTION=descending;GRAPH=%cumulative] IntX
Updated on June 18, 2019

Was this article helpful?