The SAMPLE command creates a temporary select-list of the first n items in a file that match the specified criteria. This command is useful when you want to test a small number of items. For example, you might want to test 100 items in a file rather than the entire file.
Format
SAMPLE [DICT] filename [item-list] [selection] [output] (n) |
Parameter(s)
DICT |
Specifies the file dictionary. |
filename |
Name of the file. |
item-list |
List of individual item-IDs that you want to select or compare against specified criteria. Enclose each item-ID in single quotes. This parameter overrides n. |
selection |
Specifies the conditions that an item must meet to be included in the select-list. For a complete description of selection expression syntax, see the LIST Command. |
output |
Name of an attribute whose values are to be selected. Each value becomes a separate item-ID in the select-list. |
n |
Number of items to sample. |
Description
The SAMPLE command creates a temporary select-list containing the first n item-IDs of the items specified in the item-list or the selection criteria. The items referenced by the select-list are processed by the next command you execute.
NOTE |
Only the statement immediately following the SAMPLE statement has access to the select-list. In other words, you must use the select-list immediately, or you will lose it! |
To permanently save the select-list, use the SAVE-LIST command. Once a select-list is saved, you can retrieve it at any time with the GET-LIST command.
A select-list can reference data in any file, not just the file specified in the original SAMPLE statement. If two files have similar items with the same item-IDs, you can create a select-list from one file, then use it to operate on items from the other file.
Selecting a Specified Number of Items
The following example creates a select-list containing the first 4 items in the ORDERS file whose sale date is January 15, 1994:
>SAMPLE ORDERS WITH DATE = "01/15/94" (4)
4 ITEMS SELECTED. |
You can list these items with the LIST command:
>LIST ORDERS
0179 0134 0234 0156
4 ITEMS LISTED. |