August 2004 Technical Tip – Recoding records with SyncSort
The CHANGE operand of the OUTREC statement is a feature of SyncSort which allows the programmer to recode records. Consider the following dataset containing pet information with the pet name in positions 1-8, the gender (M or F) in position 9, and the species (D = dog, C = cat, R = rabbit) in position 10:
Let's assume I desire the following output with the name remaining in positions 1-8, a blank in position 9, the gender (recoded as 1 = male, 2 = female) in position 10, a blank in position 11, and the species (spelled out as DOG, CAT, or OTHER) in positions 12-16:
My SyncSort control cards would appear as follows:
Let's quickly explain the last field: 12 is the position in the output record, 10 is the position in the input record, 1 is the length in the input record, 5 is the length in the output record, C'D' and C'C' are the change-from values, and C'DOG ' and C'CAT ' are the change-to values. Note the NOMATCH operand is optional (it wasn't used with gender), but if it is omitted and an unmatched condition is encountered, SyncSort will abend with U0016 return code. As always, be careful of misplaced blanks, commas and parentheses. Proper alignment is not required by SyncSort, but may be required by your peers!
Want to know more about SyncSort? Give us a call! You can count on Caliber Data Training for top quality mainframe and/or internet programming education.