Page 1 of 1

how can I eliminate records which have a sum of zero?

PostPosted: Wed Dec 11, 2013 2:36 am
by lostcontinent
hi there,
I have a DS with content like this:
Key1 Key2  value with leading sign (blank or '-')
0001 1111 -000100
0001 1111  000100
0002 1111  000200
0001 1111  000200
0002 1111 -000300
0002 1111  000300
0001 1111 -000100
0001 1111  000100


and the result should be:
0002 1111  000200
0001 1111  000200


so I want to get rid off all of the records which have exactly the same keys and value (except for the sign) - a kind of +/- pairs,
so these records have to be removed
0001 1111 -000100
0001 1111  000100

but these records
0001 1111 -000200
0001 1111  000100

have to be kept both.

I guess a normal SUM will not work and I first have to split the DS and rejoin, but I really have no idea how to do this.

I hope I explained it clearly enough, sorry for my bad english.

frank

Re: how can I eliminate records which have a sum of zero?

PostPosted: Wed Dec 11, 2013 7:13 pm
by NicC
Your data does not match between your examples. there is no
0001 1111 -000200
in your input and surely you should be dropping 2 lots of
0001 1111 -000100
0001 1111  000100
not just 1 lot?
and should you not include
0002 1111 -000300
0002 1111  000300

in the records to be dropped?

What is the LRECL and RECFM of all files?

Re: how can I eliminate records which have a sum of zero?

PostPosted: Thu Dec 12, 2013 12:43 am
by lostcontinent
Your data does not match between your examples

Nic,
thank you for the hint.
Yes, these were two different examples. I did not point that out clearly.

The DS has a LRECL of 50, FB.
I just want to get rif of all pairs which have the same key and value except for the sign of the value.

More examples:
1st example:
0001 1111 -000100
0001 1111  000100
0001 1111 -000100
0001 1111  000100

should result in an empty DS.

2nd Example
0001 1111 -000100
0001 1111  000100
0001 1111  000100

should result in
0001 1111  000100


3rd example:
0001 1111  000100       
0001 1111  000100
0001 1111 -000111
0001 1111 -000100

should result in
0001 1111  000100       
0001 1111 -000111


I hope it's more clear now.
thank you very much,
regards,
frank

Re: how can I eliminate records which have a sum of zero?

PostPosted: Thu Dec 12, 2013 4:45 am
by skolusu
what is the expected output from this scenario?

0001 1111 -000100
0001 1111  000100
0001 1111  000100
0001 1111  000100


The 1st 2 records cancel out each in terms of sum. Do you need 2 records like this

0001 1111  000100
0001 1111  000100


or is it ok to have just 1 record with a total of 200?
0001 1111  000200


The second output is quite easy to get.