shivashunmugam Muthu
Active User
Joined: 22 Jul 2005 Posts: 114 Location: Chennai
|
|
|
|
I need to remove duplicate records but also, along with it, I need to take
the average of a field taking the values of all duplicate records. I don't
want to write a cobol program for this. Can DFSORT/SYNCSORT or any other utility
help me out with this. Here an example of what I want
Input File (The first two fields form the record key) :
USD EUR 3
USD EUR 4
USD EUR 5
USD AUD 3
USD AUD 4
Output File
USD EUR 4
USD AUD 3.5
Syntax please..... |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will give you a report similar to what you're asking for. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) in order to use DFSORT's new OVERLAY function. Only DFSORT has this function, so if you don't have DFSORT, you won't be able to use it. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:
Use [URL] BBCode for External Links
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
USD EUR 3
USD EUR 4
USD EUR 5
USD AUD 3
USD AUD 4
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
* Sort by key
SORT FIELDS=(1,14,CH,A)
* Multiply each number by 10 for fraction (e.g. 3*10 = 30 -> 3.0)
OUTREC OVERLAY=(26:C'0')
* Get average of n*10 values for each key and format with one
* decimal place (e.g. 3.5).
OUTFIL NODETAIL,REMOVECC,
SECTIONS=(1,14,
TRAILER3=(1,14,25:AVG=(25,2,ZD,EDIT=(IT.T))))
/*
|
SORTOUT would have:
Code: |
USD AUD 3.5
USD EUR 4.0
|
|
|