ComputeStatistics()

Summary

Creates a table with summary statistics for records in a view.

Syntax

new_view_name = ComputeStatistics(string view_set_name, string new_view_name, string output_filename, string output_type, array options)

Argument Contents
view_set_name The set of input records to be processed
new_view_name The name you want to use for the new result view
output_filename The name of the output table
output_type The type of the output table (CSV, dBASE, FFA or FFB).
Option Type Contents
Strings Boolean Whether to include output records for string input fields; defaults to "True"

Returns

A string containing the actual name of the new view.

Notes

  • The file types include FFA for fixed-format text (ASCII), FFB for fixed-format binary, and CSV for comma-separated text (values).

  • ComputeStatistics() creates a new table containing summary statistics for the records in an input view. The new table is then opened as a view. The table contains one record for each field in the original view, and seven columns as follows:

Output field name Type Contents
Field String Name of the field in the original input view
Count Integer Number of records in the input set with non-missing values for that input field
Sum Real Sum of all non-missing data values for that input field
Minimum Real Minimum of all non-missing data values for that input field
Maximum Real Maximum of all non-missing data values for that input field
Mean Real Mean of all non-missing data values for that input field
Std. Dev. Real Standard deviation of all non-missing data values for that input field
  • For string-type input data fields, only the count of non-missing values is defined. The sum, minimum, maximum, mean or std. dev. all have missing values.

  • There must be at least one input field, and at least one numeric field if string fields are excluded.

  • The width and number of decimals for all output fields is automatically determined.

  • ComputeStatistics() displays a progress bar. To add a Cancel button to the progress bar, precede the function call with an "on escape" clause. For more information, see Error Handling.

Example

summary = ComputeStatistics("U.S. States|High Population",
"High Population", "Summary.CSV", "CSV", )

Error Codes

Error Type Meaning
Error One or more of the following input variables are null or invalid: new_view_name, output_type, output_filename; or a file I/O error occurred (e.g., out of disk space)
NotFound The input view or set does not exist; or there are no data fields in the input view (or string fields are excluded and there are no numeric fields)
Escape The user clicked Cancel

See Also

Function Summary
AggregateTable() Groups records in a view and computes summary statistics