2 best ways split a file using DFSORT

The OUTFIL operands SPLIT1R, SPLIT and SPLITBY can be used with the operands FNAMES and FILES to split records in various ways among multiple output data sets as follows:
SPLIT1R=n writes the first n output records to the first output data set, the second n output records to the second data set, and so on; when each output data set has n records, any remaining records are written to the last output data, so the records in each output data set will be contiguous.

Here’s an example of OUTFIL SPLIT1R:
OUTFIL FNAMES=(T1,T2,T3,T4),SPLIT1R=50

Records 1-50 are written to the T1 data set, records 51-100 are written to the T2 data set, records 101-150 are written to the T3 data set, and records 151-n (where n is the last record, for example, 220) are written to the T4 data set.

Use SPLIT1R rather than SPLIT or SPLITBY if you want to ensure that each output data set has contiguous records. SPLIT writes the first output record to the first output data set, the second output record to the second output data set, and so on; when each output data set has one record, the rotation starts again with the first output data set, so the records in each output data set will not necessarily be contiguous.

Here’s an example of OUTFIL SPLIT:
OUTFIL FNAMES=(PIPE1,PIPE2,PIPE3),SPLIT

The first record is written to the PIPE1 pipe, the second record is written to the PIPE2 pipe, the third record is written to the PIPE3 pipe, the fourth record is written to the PIPE1 pipe, and so on.

dfsort examples
dfsort examples

SPLIT can also be used with / in OUTFIL OUTREC to put pieces of each input record into different data sets.
Here’s an example:
OUTFIL FNAMES=(PART1,PART2,PART3),SPLIT,
BUILD=(1,20,/,21,20,/,41,20)

Positions 1-20 of each input record are written to PART1. Positions 21-40 of each input record are written to PART2. Positions 41-60 of each input record are written to PART3.

SPLITBY=n writes the first n output records to the first output data set, the second n output records to the second data set, and so on; when each output data set has n records, the rotation starts again with the first output data set, so the records in each output data set will not necessarily be contiguous.

Here’s an example of OUTFIL SPLITBY:
OUTFIL FNAMES=(OUT1,OUT2),SPLITBY=50

Records 1-50 are written to the OUT1 data set, records 51-100 are written to the OUT2 data set, records 101-150 are written to the OUT1 data set, records 151-200 are written to the OUT2 data set, and so on. (Ref: IBM)

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.

Start Discussion

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s