MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

counting duplicates in sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
koolspark
Beginner


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Fri May 28, 2010 5:04 am    Post subject: counting duplicates in sort Reply with quote

Hi,

I've a file whose LRECL=153. key is at position 63 to 72. I've 1 in positon 152-153 (s9(4) comp) for all the records in the file. I've duplicates in the key(position 63-72). Now, I would like to sort the file on key(63-72) and have the duplicate record count in position 152-153.
for eg
input file:(assume 1111,2222 is the key)
ab 1111 1
cd 2222 1
ef 1111 1
gh 2222 1
ij 1111 1

output file shoule look like(if key matches, add the last byte values)
ab 1111 3
ef 1111 3
ij 1111 3
cd 2222 2
gh 2222 2

Please advise.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 28, 2010 11:11 am    Post subject: Reply with quote

koolspark,

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now supports the JOINKEYS function which can do this kind of thing much more easily. use the same file for both SORTJNF1 and SORTJNF2. The JNF2 file will be summed to get the total no: of duplicates and joined on to the JNF1

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTJNF1 DD DSN=Your input fb 153 byte file,DISP=SHR
//SORTJNF2 DD DSN=Your input fb 153 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  JOINKEYS FILES=F1,FIELDS=(63,10,A)                       
  JOINKEYS FILES=F2,FIELDS=(63,10,A)                       
  REFORMAT FIELDS=(F1:1,151,F2:152,2)                       
  SORT FIELDS=COPY                                         
//JNF2CNTL DD *                                             
  SUM FIELDS=(152,2,BI)                                     
//*


For complete details on JOINKEYS and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
koolspark
Beginner


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Tue Jun 01, 2010 1:11 am    Post subject: Reply with quote

Thank you very much Kolusu. It really worked.. Smile. I tried almost all the options which i know of(sum fields,add,count,splice, outfil, sections with Trailer3). All these options were giving me the count, but eliminating the duplicates.
once again thank you very much & Appreciate your help.

Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group