SORT-MERGE/XL General User's Guide (32650-90883)

Chapter 4 55
Using MERGE/XL Interactively
Merging Files Using a Single Key
Merging Files Using a Single Key
To combine the two files EMPLOYEE and NEWHIRES using a single key data item to create a
new merged file named COMPANY, enter the following commands:
:MERGE
HP32214A.01.00 MERGE/3000 WED, JUN 3, 1987, 11:55 AM
© HEWLETT-PACKARD CO. 1986
>INPUT EMPLOYEE, NEWHIRES
>OUTPUT COMPANY
>KEY 1, 11
>END
The two input files (EMPLOYEE and NEWHIRES) and the resulting output file (COMPANY) are
shown below. These files are merged according to last name, as indicated by the command
>KEY 1, 11. Since no other specification was made, the merge is done alphabetically using
the default ascending alphabetical order. Notice that the entries for ADAMS, CARLSON,
CLARK, and MATHEWS are merged into a single list with the other employees in the file
COMPANY.
The existing file EMPLOYEE contains the following data:
1 2 3 4
123456789012345678901234567890123456789012345
1 ANDERSON CHARLES PRESIDENT 0247
2 ANDERSON CHARLES SALES REP 3456
3 ANDERSON MARY ACCOUNTANT 6345
4 CARLSON ROBERTA TREASURER 3586
5 FISHER TOM SHIPPING CLERK 7309
6 JOHNSON FRANCES RECEPTIONIST 7943
7 LANGE ROBERT ENGINEER 3235
8 SMITH HOWARD DESIGNER 6794
9 TAYLOR HEATHER SECRETARY 7272
10 ZIMMER ANDREW ENGINEER 5739
The newly created and sorted file NEWHIRES contains the following data:
1 2 3 4
123456789012345678901234567890123456789012345
1 ADAMS JERROLD INSPECTOR 8044
2 CARLSON PETER BUYER 8043
3 CLARK STEVE ASSEMBLER 8046
4 MATHEWS EDDY PLANNER 8045
The file COMPANY, created as a result of merging the files NEWHIRES and EMPLOYEE, contains
the following data:
1 2 3 4