f1 f2 f3
------------------
AA SR1789 123
BB SR1678 123
AA SR1789 456
AA SR1234 789
I need to add the f3 fields of all the records with f1=AA and the same f2 field. So my output should be
f1 f2 f3
------------------
AA SR1789 579
BB SR1678 123
AA SR1234 789
Is it possible to do this without splitting the file?
Actually my file is of length 80 and the field coressponding to f3 is present at 61st position in it with length 13. the field f2 is of length 12 at 3rd position and f1 is of length 2 at 1st position. I tried the following:
OPTION EQUALS,ZDPRINT
INREC OVERLAY=(81:61,15,UFF,TO=ZD,LENGTH=13)
INCLUDE COND=(1,2,CH,EQ,C'AA')
SORT FIELDS=(3,12,CH,A)
SUM FIELDS=(81,13,ZD)
OUTREC BUILD=(1,60,61:81,13,ZD)
but this ways, as is obvious, i am losing the BB records, which i need in the output. Can anyone pls help??
No i hadn't.. Not very sure as to where it would fit, but will this serve the purpose?
OPTION EQUALS,ZDPRINT
INREC OVERLAY=(81:61,15,UFF,TO=ZD,LENGTH=13)
INCLUDE COND=(1,2,CH,EQ,C'AA')
SORT FIELDS=(3,12,CH,A)
SUM FIELDS=(81,13,ZD)
OUTREC IFTHEN=(WHEN=(1,2,CH,EQ,C'AA'),
BUILD=(1,60,61:131,15,ZD),
IFTHEN=(WHEN=(1,2,CH,EQ,C'BB'),
BUILD=(1,60,61:131,15)
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
darakhshan,
The INCLUDE is only keeping the 'AA' fields. You shouldn't be using it.
Your posts are confusing. Are you trying to add just the records with f1='AA' and the same f2 field, or are you trying to add all of the records that have the same f1 and f2 field. To illustrate, what output would you expect for these input records?
Code:
AA SR1789 123
BB SR1678 123
AA SR1789 456
AA SR1234 789
FF SR3333 100
FF SR3333 200
FF SR3333 300
EE SR1234 100
EE SR1234 200
Once you answer this question and I know what you want to do, I can show you how to do it with DFSORT.
actually i want to sum up only the AA records and have the rest as it is.. and i have only two kinds of records, AA and BB. So eliminating the EE and FF records, output shud be: