BENFORD command
Concept Information
Counts the number of times each leading digit (1–9) or leading digit combination occurs in a field, and compares the actual count to the expected count. The expected count is calculated using the Benford formula.
Syntax
BENFORD <ON> numeric_field <LEADING n> <IF test> <BOUNDS> <TO {SCREEN|table_name|GRAPH|PRINT}> <LOCAL> <HEADER header_text> <FOOTER footer_text> <WHILE test> <FIRST range|NEXT range> <APPEND> <OPEN>
Parameters
Name | Description |
---|---|
ON numeric_field |
The numeric field to analyze. Note Select a field that contains "naturally occurring numbers", such as transaction amounts. Benford analysis is not suitable for numeric data that is constrained in any way. For more information, see What data can I test using Benford analysis? |
LEADING n optional |
The number of leading digits to analyze. The value of n must be from 1 to 6. If LEADING is omitted, the default value of 1 is used. |
IF test optional |
A conditional expression that must be true in order to process each record. The command is executed on only those records that satisfy the condition. Note The IF parameter is evaluated against only the records remaining in a table after any scope parameters have been applied (WHILE, FIRST, NEXT). |
BOUNDS optional |
Includes computed upper and lower bound values in the output results. If two or more counts in the output results exceed either of the bounds, the data may have been manipulated and should be investigated. |
TO SCREEN | table_name | GRAPH | PRINT optional |
The location to send the results of the command to:
|
LOCAL optional |
Saves the output file in the same location as the Analytics project. Note Applicable only when running the command against a server table with an output file that is an Analytics table. The LOCAL parameter must immediately follow the TO parameter. |
HEADER header_text optional |
The text to insert at the top of each page of a report. header_text must be specified as a quoted string. The value overrides the Analytics HEADER system variable. |
FOOTER footer_text optional |
The text to insert at the bottom of each page of a report. footer_text must be specified as a quoted string. The value overrides the Analytics FOOTER system variable. |
WHILE test optional |
A conditional expression that must be true in order to process each record. The command is executed until the condition evaluates as false, or the end of the table is reached. Note If you use WHILE in conjunction with FIRST or NEXT, record processing stops as soon as one limit is reached. |
FIRST range | NEXT range optional |
The number of records to process:
Use range to specify the number of records to process. If you omit FIRST and NEXT, all records are processed by default. |
APPEND optional |
Appends the command output to the end of an existing file instead of overwriting it. Note You must ensure that the structure of the command output and the existing file are identical:
Analytics appends output to an existing file regardless of its structure. If the structure of the output and the existing file do not match, jumbled, missing, or inaccurate data can result. |
OPEN optional |
Opens the table created by the command after the command executes. Only valid if the command creates an output table. |
Examples
Outputting results to graph
You run the BENFORD command against the Amount field and output the results to a graph:
BENFORD ON Amount LEADING 2 BOUNDS TO GRAPH
Remarks
For more information about how this command works, see Performing Benford analysis.
What data can I test using Benford analysis?
You should only use Benford analysis for testing numeric data composed of "naturally occurring numbers", such as accounting amounts, transaction amounts, expenses, or address numbers. Benford analysis is not suitable for numeric data that is constrained in any way.
Follow these guidelines for identifying numeric data that is suitable for Benford analysis:
- Size of the data set The data set must be large enough to support a valid distribution. Benford analysis may not give reliable results for fewer than 500 records.
- Leading digit requirement All numbers from 1 to 9 must have the possibility of occurring as the leading digit.
- Leading digit combination requirement All numbers from 0 to 9 must have the possibility of occurring as the second leading digit, and as any additional digits being analyzed.
- Constrained data Numeric data that is assigned or generated according to a pre-ordained pattern is not suitable for Benford analysis. For example, do not use Benford to analyze:
- sequential check or invoice numbers
- social security numbers or telephone numbers that map to a specific pattern
- any numbering scheme with a range that prevents certain numbers from appearing
- Random numbers Numbers generated by a random number generator are not suitable for Benford analysis.