How to find the number of duplicates in a file using Sort?

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Arundk2012
Member
Posts: 6
Joined: Thu Jan 17, 2013 2:57 pm

How to find the number of duplicates in a file using Sort?

Post by Arundk2012 » Thu Jan 17, 2013 3:02 pm

Below is the sample input record and the output expected
Is this is possible using a sort jcl?
INPUT: ABCXYZ.UTIL.TEST
AB
AB
AB
DC
DC
PQ
PQ

Output:
AB 3
DC 2
PQ 2
Arun.M

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Fri Jan 18, 2013 1:56 am

No - not using sort JCL as JCL (of any flavour) does not do that sort of thing. However, if you give the correct sort control cards to your sort product it, sort, MAY be able to do so.
Regards
Nic

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Jan 18, 2013 3:46 am

Append a field to each record with a value of "one".

If your file is in key order, use SORTIN01 for your data and MERGE with your key and SUM with the appended value.

If not in sorted order already, use SORTIN and SORT with your key and SUM with the appended value.

siddubasha
Member
Posts: 3
Joined: Tue Nov 27, 2012 3:11 pm

Re: How to find the number of duplicates in a file using Sor

Post by siddubasha » Fri Jan 18, 2013 11:21 am

ya it is possible by jcl sort ; & write jcl sort as a control card.

I given the example bellow

*************************************************************

//MAT007P JOB OZA,OZA,MSGLEVEL=(1,1),
// CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID,REGION=6M
//STEP EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MAT004.PALLAVI.DUPNAME,DISP=SHR
//SORTOUT DD DSN=MAT004.PALLAVI.DUPNAME.OUT8,
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=28,RECFM=FB,BLKSIZE=280),
// SPACE=(TRK,(3,2),RLSE)
//SYSIN DD *
INREC FIELDS=(1,20,5X,C'001')
SORT FIELDS=(1,20,CH,A)
SUM FIELDS=(26,3,ZD)
OUTREC FIELDS=(1,20,5X,26,3)
/*
*************************************************************INPUT
*************************************************************

MAT004.PALLAVI.DUPNAME.


SINDU
MRUDULLA
PALLAVI
LAKSHMI
AKILA
MANASA
MADHAVI
AKILA
PALLAVI
AKILA
PALLAVI
MADHAVI
************************************************************* OUTPUT
*************************************************************
AKILA 003
LAKSHMI 001
MADHAVI 002
MANASA 001
MRUDULLA 001
PALLAVI 003
SINDU 001

*************************************************************

The above example is the perfect example to your post




Arundk2012 wrote:Below is the sample input record and the output expected
Is this is possible using a sort jcl?
INPUT: ABCXYZ.UTIL.TEST
AB
AB
AB
DC
DC
PQ
PQ

Output:
AB 3
DC 2
PQ 2

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Jan 18, 2013 2:46 pm

Why do you insist on using the "overloading" of FIELDS?

OVERLAY more descriptive for INREC.

Why do you need the OUTREC at all?

Your data is not really much of a match, as TS shows theirs "sorted".

Arundk2012
Member
Posts: 6
Joined: Thu Jan 17, 2013 2:57 pm

Post by Arundk2012 » Fri Jan 18, 2013 5:54 pm

Thanks Sidhu, its working
Arun.M

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others