I need to remove the duplicates within a group. In the above sample, there are 3 records under 01 - HEADER followed by another group. In this first group the second record is a duplicate and has to be removed. the required output is as follows:
Thanks for your advice Peter. I went through the manuals and various posts here based on which I tried the following SORTCARD.
Code:
INREC IFTHEN=(WHEN=GROUP,BEGIN=(6,6,CH,EQ,C'HEADER'),
PUSH=(81:ID=8))
SORT FIELDS=(81,8,ZD,A,1,10,CH,A),EQUALS
SUM FIELDS=NONE
But this sortcard sorts the header too. Though I understand why it sorts it, but I am not able to avoid it. Can someone let me know how can I avoid sorting the header of the group and retain it at the top of the group.
Thanks a ton for both your code snippets. Though I haven't checked the first sortcard, the second one worked perfectly. I had tried the following to get the results.
Certainly not an efficient way to sort. But nevertheless I was able to achieve what I was looking for . I will go with your second suggestion since the job is done in a single step without any intermediary temp files.