View previous topic :: View next topic |
Author |
Message |
dhansr Beginner
Joined: 26 May 2016 Posts: 14 Topics: 6
|
Posted: Thu Aug 11, 2016 4:40 pm Post subject: Counting the occurance of field values ? |
|
|
Hi,
I have a sequential file with 7 columns which was written after comparing two file, only fields whose values did not match has been written in this output file. File contains record number, 1st file field name, value, 2nd file field name, value
1st column is the record number (can be upto 99999)
2nd column is the fields in the first record of first file we can have any number of fields upto 3500
3rd column is the value of the fields
4th column is for count
5th column is the fields in the first record of second file, field name and number matches with the column2 but value will be different
6th column is value for field of second file
7th column is for count
I need count how many times field & its value in column 2 and column 3 is repeated with same value and write against that field in the same row where XXXXX is mentioned. Also find similarly for column 7 from 5 & 6
Example: Field1 & value 100 repeated only once so X value is 1
Filed3 & value 271 repeated 2 times so X value is 2
Code: |
COL1 COL2 COL3 COL4 COL5 COL6 COL7
---------------------------------------------------------------
1 FILED1 100 00001 FILED1 XXXXX
1 FIELD3 271 00002 FIELD3 XXXXX
1 FILED7 11111 XXXXX FILED7 398 XXXXX
2 FILED2 323 XXXXX FILED2 323334 XXXXX
2 FILED3 271 XXXXX FILED3 354 XXXXX
2 FILED5 5674433 XXXXX FILED5 XXXXX
2 FILED9 233 XXXXX FILED9 23356778889 XXXXX
2 FILED10 578 XXXXX FILED10 578 XXXXX
2 FIELD11 2333232323 XXXXX FIELD11 222 XXXXX
3 FIELD5 567 XXXXX FIELD5 567 XXXXX
3 FILED9 233 XXXXX FILED9 233 XXXXX
4 FILED2 323 XXXXX FILED1 XXXXX
4 FILED4 566 XXXXX FILED4 444 XXXXX
4 FILED7 11111 XXXXX FILED8 674 XXXXX
4 FILED44 244 XXXXX FILED44 244323232 XXXXX
5 FILED1 299 XXXXX FILED1 XXXXX
|
Currently I am thinking of putting this into two arrays. Take first record from first array and compare against all the records of 2nd array, similarly take 2nd record from first array and compare against all the records of 2nd array.
Since I will have more than 99999 records this might not be a good option,
Please suggest if there is any alternate way which would improve performance
Thanks |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 11, 2016 7:31 pm Post subject: Re: Counting the occurance of field values ? |
|
|
dhansr wrote: |
Currently I am thinking of putting this into two arrays. Take first record from first array and compare against all the records of 2nd array, similarly take 2nd record from first array and compare against all the records of 2nd array.
Since I will have more than 99999 records this might not be a good option,
Please suggest if there is any alternate way which would improve performance
Thanks |
Dhansr,
Array? You mean internal tables? Array is a horizontal structure and I am not sure as to how you plan to compare/count?
Either way It is a simple request and it does not matter as to how many records you have.
1. Sort the input file on COL2 and COL3 and read this file as INP1
2. Now load the internal table when it is the first duplicate (You can search the table before you load into it) Sample program here
http://www.mvsforums.com/helpboards/viewtopic.php?p=42173
3. whenever it is a duplicate you increment the counter.
Repeat the same process for the other COL5 and COL 6
Btw you can do this quite easily with JOINKEYS in one go. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
dhansr Beginner
Joined: 26 May 2016 Posts: 14 Topics: 6
|
Posted: Fri Aug 12, 2016 10:40 am Post subject: |
|
|
Hi Kolusu , I have gone through the sample program and now I got the solution .
Sorting & count increment made the flow easy.
Thank you so much. as usual you deserve more valuable than Thanks, which is not defined yet
|
|
Back to top |
|
|
|
|