MainframeMaster

SPLIT1R

SPLIT1R is an OUTFIL parameter that splits the output into multiple datasets in contiguous blocks. You specify SPLIT1R=n and a list of output DD names in FNAMES=(DD1,DD2,…,DDk). The first n records go to the first file, the next n to the second, and so on. When the total record count is not evenly divisible by n, the remainder typically goes to the last file. So you get one contiguous segment per file—no cycling back to the first file like SPLITBY. SPLIT1R is useful when you need roughly equal-sized output files in order (e.g. for parallel processing where each file is processed independently) or when downstream systems expect one range of records per file. This page covers SPLIT1R syntax, how remainder is handled, how it differs from SPLITBY and SPLIT, choosing n, and JCL requirements.

OUTFIL Advanced
Progress0 of 0 lessons

SPLIT1R=n: Contiguous Block Distribution

The "1R" in SPLIT1R is often read as "one round" or "one pass": each output file is filled once in order with a block of n records. There is no second round back to the first file. So with FNAMES=(OUT1,OUT2,OUT3) and SPLIT1R=1000:

  • OUT1 receives records 1–1000.
  • OUT2 receives records 1001–2000.
  • OUT3 receives records 2001–3000 (and any remainder, e.g. if you have 2500 records, OUT3 gets 501–2500).

If you have 2500 records, OUT1 gets 1000, OUT2 gets 1000, and OUT3 gets the remaining 500. The last file in the list gets the remainder. This makes SPLIT1R ideal when you want contiguous key ranges or record ranges per file (e.g. first third of sorted data in file1, second third in file2, last third in file3).

Syntax

Code one OUTFIL with FNAMES= and SPLIT1R=n. All listed DD names must be defined in your JCL. The value n is the number of records per block (per file, for the first k-1 files; the last file may get n plus remainder).

text
1
2
SORT FIELDS=COPY OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLIT1R=1000

This sends the first 1000 records to OUT1, the next 1000 to OUT2, and the next 1000 (and any remainder) to OUT3. You can list as many DD names as you need; each will receive one contiguous block of n records (except the last, which may receive the remainder).

Choosing n for Roughly Equal File Sizes

If you want k output files with roughly the same number of records, set n to approximately (total records / k). For example, if you expect 9000 records and want three files, use SPLIT1R=3000. Then OUT1 gets 3000, OUT2 gets 3000, OUT3 gets 3000. If the actual count is 9500, OUT1 gets 3000, OUT2 gets 3000, OUT3 gets 3500. So the last file can be larger when the total is not divisible. If you do not know the total in advance, choose n based on a maximum expected size (e.g. 10,000 records per file) or on downstream limits.

SPLIT1R vs SPLITBY vs SPLIT
OptionBehaviorTypical use
SPLIT1R=nFirst n to file1, next n to file2, …; remainder to last fileContiguous blocks; roughly equal-sized files in order
SPLITBY=nFirst n to file1, next n to file2, next n to file3, then next n to file1 (cycle)Rotating blocks; balance count across files over many records
SPLIT (no n)One record to file1, one to file2, one to file1, … (round-robin)Interleave records across files
Multiple OUTFILs, SPLIT=nFirst n to first OUTFIL, next n to second OUTFILFirst chunk to one file, next chunk to another (e.g. first 500 to OUT1, rest to OUT2)

SPLIT1R vs SPLITBY

SPLITBY=n with FNAMES=(A,B,C) rotates blocks: first n to A, next n to B, next n to C, then next n to A again, and so on. So over a large number of records, A, B, and C each get roughly one-third of the total, but the records in each file are every third block (e.g. A has blocks 1, 4, 7, …). SPLIT1R=n fills in order: first n to A, next n to B, next n to C; remainder to C. So A has the first contiguous segment, B the second, C the third (plus remainder). Use SPLIT1R when you need contiguous ranges per file; use SPLITBY when you want rotating distribution and do not care about contiguity.

Example: 10 Records, Three Files, SPLIT1R=4

With 10 records, FNAMES=(A,B,C), and SPLIT1R=4: records 1–4 go to A, records 5–8 to B, and records 9–10 to C. So A=4, B=4, C=2. The last file gets the remainder. This is different from SPLITBY=4 with the same FNAMES, where you would get: first 4 to A, next 4 to B, next 4 to C (only 2 in this case), so A=4, B=4, C=2 for 10 records—here the result is the same because 10 is less than 12; with 12 records SPLITBY would give A=4, B=4, C=4 and then cycle; SPLIT1R would give A=4, B=4, C=4.

JCL and Record Format

Each DD name in FNAMES= must have a corresponding //DDname DD ... in your JCL. The record length (and RECFM) written to each file is the same—either the full record length after INREC/OUTREC or the length defined by BUILD= on that OUTFIL. Set LRECL and SPACE on each DD to match the expected record count and record size. If the last file gets the remainder, it may have fewer (or more, if n is small) records than the others; allocate enough space for the maximum possible.

SPLIT1R with BUILD= or Other OUTFIL Options

You can combine SPLIT1R=n with BUILD=, INCLUDE=, or other OUTFIL options. The record is built or filtered first; then the resulting record stream is distributed by SPLIT1R to the output files. All split files receive the same record format. Exact support and syntax (e.g. SPLIT1R vs SPLIT 1R) may vary by DFSORT product and version; always check your installation manual.

Explain It Like I'm Five

You have 10 toy cars and three boxes. SPLIT1R=4 means: put the first 4 cars in box 1, the next 4 in box 2, and the last 2 in box 3. You do not go back to box 1. So box 1 has cars 1–4, box 2 has 5–8, box 3 has 9–10. That way each box has one group of cars in order. SPLIT1R is the rule that says "fill the first box with 4, then the second with 4, then give the rest to the last box."

Exercises

  1. You have 5000 records and want five output files with contiguous blocks. Write the OUTFIL statement using SPLIT1R. How many records does each file get?
  2. With 100 records, FNAMES=(X,Y,Z), and SPLIT1R=30, how many records go to X, Y, and Z?
  3. What is the main difference between SPLIT1R and SPLITBY when you have three output files and 9000 records? Which gives contiguous segments per file?
  4. Look up your DFSORT manual: what is the exact keyword for SPLIT1R (e.g. SPLIT1R, SPLIT 1R) and how does it handle remainder?

Quiz

Test Your Knowledge

1. What does SPLIT1R=n do with FNAMES=(OUT1,OUT2,OUT3)?

  • Rotates records round-robin across the three files
  • Writes the first n records to OUT1, the next n to OUT2, the next n to OUT3; any remainder typically goes to the last file
  • Writes only to OUT1
  • Writes n records total across all files

2. How does SPLIT1R differ from SPLITBY with three output files?

  • They are identical
  • SPLIT1R fills the first file with n, then the second with n, then the third with n (and remainder to last); SPLITBY rotates blocks—first n to file1, next n to file2, next n to file3, then next n back to file1
  • SPLITBY is only for two files
  • SPLIT1R rotates, SPLITBY fills in order

3. You have 2500 records and want three output files with roughly equal contiguous blocks. What SPLIT1R value would you use?

  • 2500
  • 833 (or 834) — divide total records by number of files so each file gets one block; remainder goes to last file
  • 500
  • 3

4. When would you choose SPLIT1R over multiple OUTFILs with SPLIT=n?

  • Never
  • When you want a single OUTFIL with multiple FNAMES and contiguous blocks (first n to first file, next n to second, etc.) in one statement
  • Only for two files
  • SPLIT1R is faster

5. With 10 records, FNAMES=(A,B,C), and SPLIT1R=4, how many records do A, B, and C get?

  • A=4, B=4, C=2 (first 4 to A, next 4 to B, remainder 2 to C)
  • A=10, B=0, C=0
  • A=4, B=4, C=4 (with 2 overflow)
  • Round-robin: A=4, B=3, C=3