Maxvalue of a Group



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

Maxvalue of a Group

Postby ibmmf4u » Fri May 18, 2012 11:48 pm

Hi Everyone,

My requirement goes this way, I would like to find out the maximum value of a particular group and write it to an output file. Mentioned below is an example.

Input file:-
TEST1    0010
TEST1    0020
TEST2    0030
TEST2    0040
TEST3    0050
TEST3    0060
TEST3    0070
TEST4    0080
TEST4    0060
TEST5    0090
TEST5    0100



Output file:-
TEST1    0020
TEST2    0040
TEST3    0070
TEST4    0080
TEST5    0100


Can someone provide me the sort card in achieving the above

Thanks in advance!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Maxvalue of a Group

Postby ibmmf4u » Sat May 19, 2012 11:38 am

Hi All,

I can able to achieve the above with synctool. Pasted below is the code that's working fine.

//STEP010    EXEC  PGM=SYNCTOOL                                 
//TOOLMSG DD SYSOUT=*                                     
//SSMSG      DD SYSOUT=*                                     
//INPUT       DD  *                                             
TEST1    0010                                             
TEST1    0020                                             
TEST2    0030                                             
TEST2    0040                                             
TEST3    0050                                             
TEST3    0060                                             
TEST3    0070                                             
TEST4    0080                                             
TEST4    0060                                             
TEST5    0090                                             
TEST5    0100                                             
//OUTPUT DD SYSOUT=*                                       
//TOOLIN  DD    *                                         
SELECT FROM(INPUT) TO(OUTPUT) ON(1,5,CH) FIRST USING(CTL1)
/*                                                         
//CTL1CNTL DD *                   
  SORT FIELDS=(1,5,CH,A,10,4,ZD,D)
/*                                 


Its giving me the exact output i.e. required.

However earlier, i am able to sort the records in the order i.e.required as per the output with the below sort card

SORT FIELDS=(1,5,CH,A,10,4,ZD,D)


But can't able to eliminate the duplicates as per the required output. Pasted below is the output file that was generated with the help of the above sort card.

TEST1    0020
TEST1    0010
TEST2    0040
TEST2    0030
TEST3    0070
TEST3    0060
TEST3    0050
TEST4    0080
TEST4    0060
TEST5    0100
TEST5    0090


Can someone provide me the sort card on how to eliminate the duplicates from the above the file and get the required output.

Thanks in advance!!!

These users thanked the author ibmmf4u for the post:
tivrfoa (Tue Jun 11, 2013 10:33 pm)
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Maxvalue of a Group

Postby dick scherrer » Sat May 19, 2012 8:04 pm

Good to hear it is working - thank you for letting us know :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Maxvalue of a Group

Postby ibmmf4u » Sat May 19, 2012 9:52 pm

Thank you Dick!!

Can you please let me know ho w to eliminate the duplicates from the below intermediate file .

    TEST1    0020
    TEST1    0010
    TEST2    0040
    TEST2    0030
    TEST3    0070
    TEST3    0060
    TEST3    0050
    TEST4    0080
    TEST4    0060
    TEST5    0100
    TEST5    0090



Thanks in advance
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Maxvalue of a Group

Postby ibmmf4u » Sun May 20, 2012 2:37 pm

Hi All,

I can able to achieve it with help of sort. pasted below is the code that's working fine.

//STEP010  EXEC PGM=SORT
//SORTIN   DD *         
    TEST1    0010       
    TEST1    0020       
    TEST2    0030       
    TEST2    0040       
    TEST3    0050       
    TEST3    0060       
    TEST3    0070       
    TEST4    0080       
    TEST4    0060       
    TEST5    0090       
    TEST5    0100                                   
//SORTOUT  DD DSN=TEST.SORT.RES,DISP=SHR 
//SYSOUT   DD SYSOUT=*                             
//SYSIN    DD *                                     
  SORT FIELDS=(5,5,CH,A,14,4,ZD,D)                 
/*                                                 
//STEP020  EXEC PGM=SORT                           
//SYSOUT   DD  SYSOUT=*                             
//SORTIN   DD  DSN=TEST.SORT.RES,DISP=SHR
//SORTOUT  DD  SYSOUT=*                             
//SYSIN    DD  *                                   
  SORT FIELDS=(5,5,CH,A)                           
  SUM FIELDS=NONE                                   
/*                                                 
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Maxvalue of a Group

Postby BillyBoyo » Sun May 20, 2012 10:19 pm

OK, you might also want to see if your release supports WHEN=GROUP.

If, so, you should be OK with one step.

Do the sort (from your first step, with the A/D depending on whether you want to retain lowest/highest amount), then with OUTREC (which is processed after SORT/SUM) use WHEN=GROUP to set a sequence number.

With OUTFIL, INCLUDE only those records with sequence number of one, then return record to desired length (with BUILD, for instance).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Maxvalue of a Group

Postby dick scherrer » Sun May 20, 2012 10:36 pm

Hello,

I didn't completely comprehend what i replied to last time. My bad :oops:

Do try what BB has suggested and try to have only one step. It there only 100 records, 2 steps might not be so bad, but if there are 100million records. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Maxvalue of a Group

Postby ibmmf4u » Sun May 20, 2012 11:22 pm

Thanks Bill & Dick.

I shall try the same and let you know the outcome.
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Maxvalue of a Group

Postby bodatrinadh » Mon May 21, 2012 3:21 pm

Hello ibmmf4u,

If you are using SYNCSORT FOR Z/OS 1.4.0.1R version, you can try below code.

//STEP1    EXEC PGM=SORT   
//SYSPRINT DD SYSOUT=*     
//SYSOUT DD SYSOUT=*       
//SORTIN   DD *           
TEST1    0020             
TEST2    0030             
TEST2    0040             
TEST3    0050             
TEST3    0060             
TEST3    0070             
TEST4    0080             
TEST4    0060             
TEST5    0090             
TEST5    0100             
//SORTOUT DD SYSOUT=*     
//SYSIN DD *               
  SORT FIELDS=(1,5,CH,A)   
  DUPKEYS MAX=(10,4,ZD)   


Output:-

TEST1    0020
TEST2    0040
TEST3    0070
TEST4    0080
TEST5    0100


Thanks
-3nadh
Thanks
-3nadh

These users thanked the author bodatrinadh for the post:
tivrfoa (Tue Jun 11, 2013 11:28 pm)
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: Maxvalue of a Group

Postby ibmmf4u » Mon May 21, 2012 9:49 pm

Hi 3nadh,

Thanks a lot. we are currently using syncsort 1.3.2.2R. Its working fine here.

Regards,
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post