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



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

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

Postby lostcontinent » Wed Dec 11, 2013 2:36 am

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
lostcontinent
 
Posts: 13
Joined: Tue Jul 27, 2010 1:47 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Wed Dec 11, 2013 7:13 pm

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?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby lostcontinent » Thu Dec 12, 2013 12:43 am

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
lostcontinent
 
Posts: 13
Joined: Tue Jul 27, 2010 1:47 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby skolusu » Thu Dec 12, 2013 4:45 am

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.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post