# ssample command

The ssample command creates and sorts a temporary select-list of the
 first *n* items in a file that match the specified criteria. This command is useful when
 testing a small number of items. For example, testing 100 items in a file rather than processing
 all 10,000 items.

The ssample command creates a temporary select-list containing, in sorted
 order, 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.CAUTION: Only the statement immediately following the ssample command
 has access to the select-list. You must use the select-list immediately or you will lose
 it.

 To permanently save the select-list, use the save-list
 command. When 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
 ssample 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.

## Syntax

```
 ssample [DICT] filename [item-list] [selection] [sort-keys] [output] (n)
```

## Parameter(s)

| DICT | Specifies the file dictionary. |
| --- | --- |
| filename | The name of the file. |
| item-list | A 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 one or more 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 information. |
| sort-keys | Specifies which attributes to sort and whether to sort them in ascending or descending order. You can use the following modifiers with sort-keys: |
| BY | Specifies which attributes to sort and whether to sort them in ascending or descending order. You can use the following modifiers with sort-keys: |
| BY-DSND | Sorts items in descending order by the specified attribute. |
| BY-EXP | Sorts a multivalued attribute in ascending order and produces a separate line for each value. |
| BY-EXP-DSND | Sorts a multivalued attribute in descending order and produces a separate line for each value. |
| If more than one sort-key is specified in an ssample command line, the system sorts these attributes from left to right (the leftmost sort-key is the most significant). | |
| output | The name of an attribute whose values are to be selected. Each value becomes a separate item-ID in the select-list. |
| n | The number of items to sample. |

## Example(s)

The following example creates a select-list containing the first four items in the ORDERS file
 whose sale date is January 15, 2018:

```
>SSAMPLE ORDERS WITH DATE = "01/15/18" (4)
4 ITEMS SELECTED.
```

 If you list these items with the list command, they appear in sorted
 order:

```
>LIST ORDERS

0134
0156
0179
0234

4 ITEMS LISTED.
```

## See also

- [get-list command](https://d3codex.com/tcl/get-list-command/)
- [list command](https://d3codex.com/access/list-command/)
- [save-list command](https://d3codex.com/tcl/save-list-command/)
- [sample command](https://d3codex.com/tcl/sample-command/)

---
Source: https://d3codex.com/tcl/ssample-command/ - part of the D3Codex reference.
