I want the output such that, all duplicates in COL-D are removed and only the one corresponding to the highest value in COL-C for a given value in COL-D is retained.
Example:
For COL-D = 9300000024
Only one record should be present in output where COL-C = 8
Note: It could be possible that there are two records for the same value in COL-D where the highest value in COL-C is same. In such a case, I want both the records in the output.
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
Hi Sid,
We can acheive it in 2 step
First step sort card
Code:
SORT FIELDS=(15,10,ZD,A,14,1,ZD,D)
Second step sort card
Code:
OPTION EQUALS
SORT FIELDS=(15,10,ZD,A)
SUM FIELDS=NONE
Quote:
Note: It could be possible that there are two records for the same value in COL-D where the highest value in COL-C is same. In such a case, I want both the records in the output.
I am just try to give u solution . Frank can provide better solution.
Forgot to mention earlier, that my input file is sorted on COL-D in ascending order.
Using a sort descending on COL-C and de-duping, partially solves my problem.
Is there any way in SORT where I can achieve -
Quote:
Note: It could be possible that there are two records for the same value in COL-D where the highest value in COL-C is same. In such a case, I want both the records in the output.
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
Hi Sid,
In that case change the first step sort card to
Code:
SORT FIELDS=(15,10,ZD,D,14,1,ZD,D)
Regarding this as i said earlier frank can provide solution
Quote:
Note: It could be possible that there are two records for the same value in COL-D where the highest value in COL-C is same. In such a case, I want both the records in the output.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Sid,
Keeping dup records with the highest COL-C makes this a bit tricky, but here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.