I have an input file as shown below:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----
AAAAAAAAAA COUNTX 25
BBBBBBBBBB COUNTP 50
CCCCCCCCCC COUNTU 75
AAAAAAAAAA COUNTY 75
BBBBBBBBBB COUNTQ 100
CCCCCCCCCC COUNTV 25
My output file should be:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----
AAAAAAAAAA COUNTX 25
BBBBBBBBBB COUNTP 50
CCCCCCCCCC COUNTU 75
AAAAAAAAAA COUNTY 75
PERCENTAGE 300.00
BBBBBBBBBB COUNTQ 100
PERCENTAGE 200.00
CCCCCCCCCC COUNTV 25
PERCENTAGE 33.33
Basically I need to find out the % of the counts given in record 4 against the record 1 of input file. ie., 75*100/25 = 300.00
Similarly record 5 (Vs) record 2 and record 6 (Vs) record 3.
This percentage should get written in the output file as shown above.
Thanks a lot for your time and the code works fine. The idea is great.
But now I am facing a problem while getting a Count of Zero in the input file as shown below:
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----
AAAAAAAAAA COUNTX 0
BBBBBBBBBB COUNTP 0
CCCCCCCCCC COUNTU 75
AAAAAAAAAA COUNTY 75
BBBBBBBBBB COUNTQ 100
CCCCCCCCCC COUNTV 25
The error message is 'INREC ARITHMETIC OVERFLOW'.
Kindly suggest me if you have any idea to resolve this.