SORT To take first record of every GROUP



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

SORT To take first record of every GROUP

Postby ankushgattani » Mon Jun 09, 2014 12:58 pm

Hi,

I am trying to code a Sort card to do the following.
My input file is:
AAA1AAA
AAA2AAA
AAA2AAA
AAA3AAA
AAA4AAA
AAA7AAA
AAA9AAA


I want to divide it into three groups
1. Fourth cahracter >= 1 and <3.
2. Fourth cahracter >= 3 and < 6
3. Fourth cahracter >=6

And then I want to take first(or any one, but only one) record of each group.
The input file has thousands of records and i want to copy these 3 reocrds to the output file(one single output file created using MOD in the SORTOUT).
Output file will look like
AAA1AAA
AAA3AAA
AAA7AAA


Is there any option which I can use to divide the input by Logical expressions and then access one record of every group.
I'm not sure if the GROUP function can be applied here.

Thanks
ankushgattani
 
Posts: 30
Joined: Wed Aug 29, 2012 12:20 pm
Has thanked: 3 times
Been thanked: 0 time

Re: SORT To take first record of every GROUP

Postby BillyBoyo » Mon Jun 09, 2014 3:00 pm

You have SyncSort, so I don't think you have KEYBEGIN for WHEN=GROUP.

You'll need three WHEN=NONE specifying a SEQNUM with RESTART containing the logical expression (in different locations).

Then a number one in any of those locations is the one you want. OUTFIL INCLUDE= for that, and use BUILD in OUTFIL to return your record to original content.

The sequence numbers need to be long enough to cover the maximum number of records in a group.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SORT To take first record of every GROUP

Postby ankushgattani » Thu Jun 12, 2014 11:55 am

Hi,

I tried the BEGIN option of WHEN=GROUP to check whether I have it or not, and I have it.
I am using SYNCSORT FOR Z/OS 1.4.1.0R.

I gave BEGIN a try for only the first condition (Fourth cahracter >= 1 and <3.)

It creates individual group for top 3 records every record, because each record satisfies the condition.

 SORT FIELDS=COPY                                               
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(4,1,CH,GE,1,and,4,1,CH,LT,3),PUSH=(8:ID=1))                 


output is like
AAA1AAA1
AAA2AAA2
AAA2AAA3
AAA3AAA
AAA4AAA
AAA7AAA
AAA9AAA


I need the top 3 records to have same identifier, so that i can Apply RECORDS=1 on them to choose first record.
Any suggestions?
ankushgattani
 
Posts: 30
Joined: Wed Aug 29, 2012 12:20 pm
Has thanked: 3 times
Been thanked: 0 time

Re: SORT To take first record of every GROUP

Postby ankushgattani » Fri Jun 13, 2014 11:22 am

Was able to do it using IFTHEN condition and BUILD :)

 INREC IFTHEN=(WHEN(4,1,CH,GE,1,and,4,1,CH,LT,3),overlay=(8:C'1')),
           IFTHEN=(WHEN(4,1,CH,GE,3,and,4,1,CH,LT,6),overlay=(8:C'2')),                 
           IFTHEN=(WHEN(4,1,CH,GE,6),overlay=(8:C'3'))                 
 SORT FIELDS=(8,1,CH,A)
 SUM FIELDS=NONE
 OUTREC BUILD=(1,7)
ankushgattani
 
Posts: 30
Joined: Wed Aug 29, 2012 12:20 pm
Has thanked: 3 times
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post