Get the first 3 records for each key



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

Get the first 3 records for each key

Postby ranga_subham » Sun Jan 25, 2009 7:10 pm

Hi,

I want to get the first 3 records for each key from the below dataset. I have pasted only portion of it (LRECL=190, RECFM=FB).

CENTRE1000
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE9898
CENTRE9898
CENTRE9898
CENTRE9898
CENTR10980
CENTR10980
CENTR10980
CENTR10980
CENTR10980


Output:
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE9898
CENTRE9898
CENTRE9898
CENTR10980
CENTR10980
CENTR10980


I tried using below code with SYNCTOOL but unsuccessfully. I thought it is not supported in v1.2.3.1R.

//TOOLIN DD *
SELECT FROM(IN1) TO(OUT1) ON(1,10,CH) FIRST(3)
/*


Please suggest.

Thanks.
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Get the first 3 records for each key

Postby Alissa Margulies » Mon Jan 26, 2009 8:45 pm

ranga_subham,

If the data is already in sorted order, then you can use the job below:

//SORT1 EXEC PGM=SORT                                   
//SYSOUT  DD SYSOUT=*
//SORTOUT DD DSN=output.file,...
//SORTIN  DD *
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE1000
CENTRE9898
CENTRE9898
CENTRE9898
CENTRE9898
CENTR10980
CENTR10980
CENTR10980
CENTR10980
CENTR10980
//SYSIN   DD *
   INREC FIELDS=(1,10,11:SEQNUM,8,ZD,RESTART=(1,10))   
   SORT FIELDS=COPY                                 
   OUTFIL INCLUDE=(11,8,ZD,LE,3),OUTREC=(1,10)       
/*
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: Get the first 3 records for each key

Postby ranga_subham » Tue Jan 27, 2009 5:09 pm

Wow.....thanks a lot Alissa.....nice alternative !
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post