September 2002 Technical Tip Format conversion with SyncSort

I recently had a client ask me if it was possible to use SyncSort to convert a packed decimal field to its zoned decimal equivalent. Specifically, this client needed to convert a packed field in positions 8-10 to its zoned decimal equivalent, to be stored in the same positions. All other fields were to remain unchanged. The SyncSort solution follows:

SORT FIELDS=COPY
OUTREC FIELDS=(1:1,7,                 BEFORE THE FIELD
               8:8,3,PD,ZD,LENGTH=3,  FIELD IN QUESTION
              11:11,69)               AFTER THE FIELD

To convert numeric fields specify the first byte of the receiving field (8), a colon (:), the first byte of the sending field (8), the length of the sending field (3), the format of the sending field (PD), the format of the receiving field (ZD), and (optionally) the length of the receiving field (LENGTH=3).

If the LENGTH parameter is omitted, the length of the receiving field will be determined based on the length and format of the sending field. For example, a 3 byte packed field can hold 5 digits. If the LENGTH parameter had been omitted, the new length would default to 5 bytes. Two more examples may help to explain:

  • Convert the packed decimal field in positions 10-13 to its zoned decimal equivalent to be placed in positions 101-107: 101:10,4,PD,ZD (Note LENGTH was unnecessary here as a 4 byte packed field has 7 digits and that (7) is the length of the receiving field.)
  • Convert the zoned decimal field in positions 78-86 to its packed decimal equivalent to be placed in positions 201-207: 201:78,9,ZD,PD,LENGTH=7 (Note LENGTH was required here because the zoned decimal sending field is 9 bytes in length, and 9 digits would pack into 5 bytes, but we want the receiving field to be 7 bytes long.)

As you can see, SyncSort does so much more than sort! Caliber Data Training is pleased to offer training in SyncSort as well as other utilities such as FileAid, Easytrieve, and SAS. We hope you will consider us when deciding upon a training provider.


Go to the articles index. Written by Bill Qualls. Copyright © 2002 by Caliber Data Training 800.938.1222