ACL Scripting Guide 14.1

SAMPLE command

Draws a sample of records using either the record sampling or monetary unit sampling method.

Syntax

Note

The syntax does not include filtering (IF statements) or scope parameters because applying these options compromises the validity of a sample.

Fixed interval selection method

SAMPLE <ON> RECORD INTERVAL interval_value <FIXED initial_value> {RECORD|FIELDS field_name <...n>} TO table_name <OPEN> <APPEND> <LOCAL> 

Cell selection method

SAMPLE <ON> RECORD CELL INTERVAL interval_value <RANDOM seed_value> {RECORD|FIELDS field_name <...n>} TO table_name <OPEN> <APPEND> <MERSENNE_TWISTER> <LOCAL> 

Random selection method

SAMPLE <ON> RECORD NUMBER sample_size <RANDOM seed_value> <ORDER> {RECORD|FIELDS field_name <...n>} TO table_name <OPEN> <APPEND> <MERSENNE_TWISTER> <LOCAL>

Parameters

Note

Do not include thousands separators when you specify values.

Name Description
ON RECORD Use record sampling.
INTERVAL interval_value FIXED initial_value | CELL INTERVAL interval_value | NUMBER sample_size

INTERVAL interval_value FIXED initial_value

Use the fixed interval selection method.

An initial record is selected and all subsequent selections are a fixed interval or distance apart – for example, every 20th record after the initial selection.

  • INTERVAL interval_value specify the interval value that was generated by calculating the sample size
  • FIXED initial_value specify the initial record number selected

    If you specify an initial_value of zero ('0'), or omit FIXED, Analytics randomly selects the initial record.

CELL INTERVAL interval_value

Use the cell selection method.

The data set is divided into multiple equal-sized cells or groups, and one record is randomly selected from each cell.

The interval_value dictates the size of each cell. Specify the interval value that was generated by calculating the sample size.

NUMBER sample_size

Use the random selection method.

All records are randomly selected from the entire data set.

Specify the sample size that was generated by calculating the sample size.

RANDOM seed_value

optional

Note

Cell and random selection methods only.

The seed value to use to initialize the random number generator in Analytics.

If you specify a value of zero ('0'), or omit RANDOM, Analytics randomly selects the seed value.

ORDER

optional

Note

Random selection method only.

You can only use ORDER when specify FIELDS.

Adds the ORDER field to the output results.

This field displays the order in which each record is randomly selected.

RECORD | FIELDS field_name <...n>
  • RECORD the entire record is included in the output table
  • FIELDS individual fields, rather than the entire record, are included in the output table

    Specify the field(s) or expressions to include. If you specify multiple fields, they must be separated by spaces.

TO table_name

The location to send the results of the command to:

  • table_name saves the results to an Analytics table

    Specify table_name as a quoted string with a .FIL file extension. For example: TO "Output.FIL"

    By default, the table data file (.FIL) is saved to the folder containing the Analytics project.

    Use either an absolute or relative file path to save the data file to a different, existing folder:

    • TO "C:\Output.FIL"
    • TO "Results\Output.FIL"

    Note

    Table names are limited to 64 alphanumeric characters, not including the .FIL extension. The name can include the underscore character ( _ ), but no other special characters, or any spaces. The name cannot start with a number.

OPEN

optional

Opens the table created by the command after the command executes. Only valid if the command creates an output table.

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:

  • the same fields
  • the same field order
  • matching fields are the same length
  • matching fields are the same data type

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.

MERSENNE_TWISTER

optional

Note

Cell and random selection methods only.

The random number generator in Analytics uses the Mersenne-Twister algorithm.

If you omit MERSENNE_TWISTER, the default Analytics algorithm is used.

Note

You should only use the default Analytics algorithm if you require backward compatibility with Analytics scripts or sampling results created prior to Analytics version 12.

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.

Examples

Draw a record sample

You are going to use record sampling to estimate the rate of deviation from a prescribed control in an account containing invoices.

After calculating a statistically valid sample size, you are ready to draw the sample. You are going to use the random selection method.

The example below:

  • Samples the open Analytics table
  • Uses the random selection method with a seed value of 123456
  • Specifies a sample size of 95 records
  • Includes only specified fields in the output table
  • Specifies that the random number generator in Analytics uses the Mersenne-Twister algorithm
SAMPLE ON RECORD RANDOM 123456 NUMBER 95 FIELDS RefNum CustNum Amount Date Type TO "Ar_record_sample" OPEN MERSENNE_TWISTER

Remarks

Note

For more information about how this command works, see the Analytics Help.