Aggregate functions (REPORT command)

Use the aggregate functions to request descriptive statistics for report variables.

  • If no variable names are specified as arguments to an aggregate function, the statistic is calculated for all variables named on VARIABLES (all report variables).
  • To request an aggregate function for a subset of report variables, specify the variables in parentheses after the function keyword.
  • All variables specified for an aggregate function must have been named on VARIABLES.
  • Keyword TO cannot be used to specify a list of variables for an aggregate function.
  • The result of an aggregate function is always displayed in the report column reserved for the variable for which the function was calculated.
  • To use several aggregate functions for the same report variable, specify multiple SUMMARY subcommands. The results are displayed on different summary lines.
  • The aggregate functions FREQUENCY and PERCENT have special display formats and cannot be placed on the same summary line with other aggregate or composite functions. They can be specified only once per SUMMARY subcommand.
  • Aggregate functions use only cases with valid values.

VALIDN. Valid number of cases. This is the only function available for string variables.

SUM. Sum of values.

MIN. Minimum value.

MAX. Maximum value.

MEAN. Mean.

STDDEV. Standard deviation. Aliases are SD and STDEV.

VARIANCE. Variance.

KURTOSIS. Kurtosis.

SKEWNESS. Skewness.

MEDIAN(min,max) . Median value for values within the range. MEDIAN sets up integer-valued bins for counting all values in the specified range. Noninteger values are truncated when the median is calculated.

MODE(min,max) . Modal value for values within the range. MODE sets up integer-valued bins for counting all values in the specified range. Noninteger values are truncated when the mode is calculated.

PGT(n). Percentage of cases with values greater than n. Alias PCGT.

PLT(n). Percentage of cases with values less than n. Alias PCLT.

PIN(min,max) . Percentage of cases within the inclusive value range specified. Alias PCIN.

FREQUENCY(min,max) . Frequency counts for values within the inclusive range. FREQUENCY sets up integer-valued bins for counting all values in the specified range. Noninteger values are truncated when the frequency is computed. FREQUENCY cannot be mixed with other aggregate statistics on a summary line.

PERCENT(min,max) . Percentages for values within the inclusive range. PERCENT sets up integer-valued bins for counting all values in the specified range. Noninteger values are truncated when the percentages are computed. PERCENT cannot be mixed with other aggregate statistics on a summary line.

Example

SORT CASES BY BVAR AVAR.
REPORT FORMAT=AUTOMATIC LIST /VARIABLES=XVAR YVAR ZVAR

  /BREAK=BVAR
    /SUMMARY=SUM
    /SUMMARY=MEAN (XVAR YVAR ZVAR)
    /SUMMARY=VALIDN(XVAR)

  /BREAK=AVAR
    /SUMMARY=PREVIOUS.
  • FORMAT requests a case listing, and VARIABLES establishes a report column for variables XVAR, YVAR, and ZVAR. The report columns have default widths and titles.
  • Both break variables, BVAR and AVAR, have default widths and headings.
  • Every time the value of BVAR changes, three summary lines are displayed. The first line contains the sums for variables XVAR, YVAR, and ZVAR. The second line contains the means of all three variables. The third line displays the number of valid cases for XVAR in the report column for XVAR.
  • Every time the value of AVAR changes within each value of BVAR, the three summary lines requested for BVAR are displayed. These summary lines are based on cases with the current values of BVAR and AVAR.

Example

SORT CASES BY DEPT.
REPORT FORMAT=AUTOMATIC
  /VARIABLES=WAGE BONUS TENURE
  /BREAK=DEPT (23)
  /SUMMARY=SUM(WAGE BONUS) MEAN(TENURE) 'Sum Income: Mean Tenure'.
  • SUMMARY defines a summary line consisting of the sums of WAGE and BONUS and the mean of TENURE. The result of each aggregate function is displayed in the report column of the variable for which the function is calculated.
  • A title is assigned to the summary line. A width of 23 is defined for the break column to accommodate the title for the summary line.