22 Jul, 2012
SORT using SYNCSORT
//STEP01 EXEC PGM=SYNCSORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=XXXXXXX.NONX.SAMPLE1
//SORTOUT DD DSN=XXXXXXX.NONX.SAMPLE2,DISP=(NEW,CATLG),
//SYSIN DD *
The above example sorts the input dataset on the first five characters. The control card is explained below.
SORT FIELDS=(1,5,CH,A) - Specifying SyncSort to sort the input dataset on the first five bytes of data in ascending order.
1 = Starting Position in input dataset
5 = Length
CH = Format of the data on which we are performing SORT
A = Ascending
– In the above example we are trying to sort zip code on ascending order and city name on descending order. As both the zip code and city name are of same format we are specifying the format in last.
SORT and copies only the first 100 records into output dataset
Ignores the first 100 records from input dataset
Supported data formats not limited to –
CH – Character, PD – Packed Decimal, ZD – Zoned Decimal, BI – Binary etc.,
Remove the duplicate records. If we want to capture the duplicate records that are removed from the input dataset then mention the SUM control statement as below.
Note: If the input dataset is of variable block type then add 4 to the starting position. This is required for variable length records.