Page 1 of 1

Remove duplicates in group record using key combination

PostPosted: Tue Oct 08, 2013 10:16 pm
by erick999
Hi my input file looks as below


Y adghfdhfe 56 shdghjhfhjs
C dhchhhhht d7 dgghjhfhhf
Y ghfhhvvhb f2 cvbbbbnjhg
C dvvbhhfffd 5n fghhjjjjjjhf
Y fdjfufftghrg 56 ghgffgghhf
C fhgvfhhcdff D7 ghcghhjjj
Y cvvccvvvvv 45 chcxghggh
C gggcvvvvhb. Fg ghhjjjhhjjg


I want to group record with Y & C and my key is the combination of two character in middle from both Y & C. My output should give only the unique combination of the keys along with the record.

It should look like


Y adghfdhfe 56 shdghjhfhjs
C dhchhhhht d7 dgghjhfhhf
Y ghfhhvvhb f2 cvbbbbnjhg
C dvvbhhfffd 5n fghhjjjjjjhf
Y cvvccvvvvv 45 chcxghggh
C gggcvvvvhb. Fg ghhjjjhhjjg

It's like unique key combination of all the records.the vale in first character is constant and the position of key is same in both Y and C

Can we do this in sync sort


Regards,
Erick

Re: Remove duplicates in group record using key combination

PostPosted: Tue Oct 08, 2013 10:21 pm
by erick999
For this I am having the idea of

1) grouping this record
2) Append the keys like 56d7 in all the record
3) sort to remove the duplicate

I don't know the commands for sure

Can any one help me out

Re: Remove duplicates in group record using key combination

PostPosted: Tue Oct 08, 2013 10:41 pm
by Akatsukami
Do you indeed wish "d7" and "D7" is be judged identical, or is that a typo?

Re: Remove duplicates in group record using key combination

PostPosted: Tue Oct 08, 2013 10:54 pm
by erick999
Identical

Re: Remove duplicates in group record using key combination

PostPosted: Tue Oct 08, 2013 11:11 pm
by BillyBoyo
To confirm that, d7 and D7 should be treated as the same? Which do you want on the output when this case arises? d7 or D7 by value, or that which is physically first/last on the file?

I think you are almost there with your suggested outline. What is the REFCM and LRECL?

Re: Remove duplicates in group record using key combination

PostPosted: Wed Oct 09, 2013 12:25 am
by erick999
d7 or D7 both are same. Let me put my requirement again

Group the first two record, a record has 2 from input file in order. First record starts as Y and the
The second one starts with C.

Key is in middle of two records. Consider If the first has AA and the second has BB. Then the key for the group is AABB.similarly we need to group all the records and the final out put is the unique combination of keys and its associated records for the first occurance.

In my example we have 56d7 and 56D7 both key are identical . I need any one of its associated record, if it is 56d7 output is 1st group I.e 1st and 2nd record. If it is 56D7 the output should have only 5th and 6 th record . I need any one of 56d7 combination. Hope this clarifies. Consider rec length as 80