Sorting the records of the data set


Use the SORT KEYS primary command to sort the records of your data set based on the record key.

Arrange Records in Key Sequence - SORT KEYS

image2021-6-16_15-3-13.png

Steps:

  1. Type SORT KEYS in the COMMAND field.
  2. Press Enter. File-AID redisplays the data set in ascending key (first five characters of each record) order. The number of records sorted is indicated in the message in the top right corner of the display as illustrated in the following figure.

Edit - After SORT KEYS

File-AID - Edit - USERID9.FASAMP.EMPLOYE1 ------------------ 56 RECORDS SORTED
 COMMAND ===>                                                  SCROLL ===> PAGE
 ****** ***************************** TOP OF DATA ******************-CAPS OFF-*
 000001 00090 MARTIN         EDWARD    M  AIRPLANE MANUFACTURER         42789012
 000002 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 ==DUP> 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 ==DUP> 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 ==DUP> 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 ==DUP> 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 ==DUP> 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 000008 00200 JACKSON        JOSEPH    C  ORATOR                        27558717
 000009 10000 ANDREWS        GEORGE       ACTOR                         57631203

More about the SORT command:

  • You can sort records on one or more fields by using the syntax:
SORT from to A/D from to A/D ...

or

SORT /field-name A/D /field-name A/D

where "from" and "to" are column locations of the field(s) to be used as sort fields and /field-name is the name of field in a supplied record layout. A/D indicates ascending (A) or descending (D) sequence; if you do not specify either A or D, File-AID assumes an A (ascending) sequence order.

  • If a keyed file is sorted on a field other than the key field, you are not able to save your changes until all records are in key sequence. In this case, use the SORT KEY command to return the records to key sequence before saving your changes.
  • The default parameter for SORT is KEYS for a keyed file. Thus the commands SORT and SORT KEYS are the same.
  • For RRDS and BDAM files the SORT command sorts records in relative record number (RRN or RBN) order.
  • EBCDIC and Unicode UTF-8 or UTF-16 SORT Order:

    The collating sequence of Unicode is different than that of EBCDIC. The SORT command allows you to reorder the data. The SORT command always operates on the underlying data; thus, when the data is Unicode, the results may be different than for EBCDIC data.

Deleting duplicate records - D (Delete) line command

Use the D (Delete) and DD (Delete Block) line commands to delete records.

DD (Delete block) - Delete Duplicate Records

image2021-6-16_15-5-7.png

Steps:

  1. Type DD (delete block) in the sequence number field of line numbers 3 and 7.
  2. Press Enter. File-AID deletes the lines of data between the delete block commands as illustrated in the following figure.

After Duplicates Have Been Deleted

File-AID - Edit - USERID9.FASAMP.EMPLOYE1 --------------- COLUMNS 000001 000071
 COMMAND ===>                                                  SCROLL ===> PAGE
 ****** ***************************** TOP OF DATA ******************-CAPS OFF-*
 000001 00090 MARTIN         EDWARD    M  AIRPLANE MANUFACTURER         42789012
 000002 00100 MULSTROM       ROBERTA   A  HOLLYWOOD SEAMSTRESS          34657365
 000003 00200 JACKSON        JOSEPH    C  ORATOR                        27558717
 000004 10000 ANDREWS        GEORGE       ACTOR                         57631203
 000005 10001 SMITH          MARY         ACTOR                         57631203
 000006 15000 MURPHY         RONALD    L  PAINTER                       98765432
 000007 18034 SCHNEIDER      ELLEN     C  NURSE                         34155954
 000008 21035 JONES          GEORGE    B  COUNTRY SINGER                46381345
 000009 25100 ROBERTS        WILLIAM   R  POLITICIAN                    87956332
 000010 27007 ALLEN          JOYCE     M  AUTHOR                        78345833
 000011 30001 RICHARDS       REX       W  RODEO CLOWN                   63276453
 000012 31000 SAVAGE         JONATHON  C  ELECTRICIAN                   34856799
 000013 34010 SMITH          JANET        AIRLINE ATTENDANT             55778298
 000014 34011 JACOBS         DIANA        DOCTOR                        22536839


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*