MGayathri
New User
Joined: 19 May 2007 Posts: 25 Location: Chennai
|
|
|
|
Hi,
I have an input file:
Code: |
col1 col2
---- -----
abc 050
abc 025
abc 025
abc 100
def 075
def 025
|
Then I need the output file as:
For key abc, sum up the col2 values and divide by 100, similarly for def.
Is it possible to do such calculation in dfsort? |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
abc 050
abc 025
abc 025
abc 100
def 075
def 025
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(6,3,ZD)
OUTREC BUILD=(1,3,
6,3,ZD,DIV,+100,TO=ZD,LENGTH=1)
/*
|
|
|