General discussion


Print last n records from DFSORT/ICEMAN

By Dan Bauman ·
Is there an operator in IBM's DFSORT or ICEMAN that will print or dump the last n records of a dataset? (e.g. The last 10 records of a dataset).

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by chris.bonner In reply to Print last n records from ...

I've done this in multiple steps, when I don't know how many records there are.

Step 1. SORT FIELDS=COPY the file, appending sequence numbers to the end of each record. I.E., OUTREC FIELDS=(1,80,SEQNUM,8,ZD...

Step 2. sort the output of step 1 in descending order of the sequence number you appended.

Step 3. sort copy the output of step 2, with a STOPAFT=10.

Step 4. sort the output of step 3, ascending order of sequence number, stripping off the sequence number.

You should be left with the last ten records of the file, in the same order as originally.

Related Discussions

Related Forums