SORT-MERGE/XL General User's Guide (32650-90883)
22 Chapter2
Getting Started With SORT-MERGE/XL
Key Data Items
>KEY 1, 9; 10, 14; 25, 15
If you define multiple key data items with the >KEY command, the priority of the sort
operation is:
• SORT-MERGE/XL treats the first key data item you enter (in this example the last
name) as the major key and sorts that item first.
• If there are two or more items of equal value in the major key (two identical last
names), the key data items are ordered according to the second data item identified
with the >KEY command.
• In the case of ties on the second data item, the third data item entered with the >KEY
command is used, and so on.
• If two or more records are equal in all key fields, the original order of the records in the
input file(s) is used. (This is not possible in this example since each person has a unique
social security number.)
For additional information on sorting by single or multiple key data items, refer to Chapter
3.
Merging Files By Key Data Items
MERGE/XL allows you to combine two or more sorted files into a single, new file based on
one or more key data items. Figure 2-4. shows a file called SORTED1. SORTED1 contains the
three records shown as sorted in Figure 2-2.
Figure 2-4. Sorted File SORTED1
You can merge this data with one or more additional sorted files such as SORTED2, shown
below in Figure 2-5.
Figure 2-5. Sorted File SORTED2
1 2 3 4
1234567890123456789012345678901234567890123456789
JONES SMOKEY TRUCKER 333887777
SOUSE EGBERT DETECTIVE 123234454
WELBY MARCUS PHYSICIAN 242244444
1 2 3 4
1234567890123456789012345678901234567890123456789
JONES AL POLITICIAN 768098989
SMITH REGGIE OUTFIELDER 436897302
TRUMAN HARRY POLITICIAN 895634409