I'm trying to produce an output that I require using SORT (WHEN BEGIN and END) attaching values at the end of record but failing to achieve it.
Below is the sample input.
001AAALISA MATHS
002BBBLISA
001AAATINA PHYSI
002BBBTINA
001AAAMATT CHEM
002BBBMATT
003BBBMATT
001AAADINO MATHS
002BBBDINO
001AAARAGG BIOLO
002BBBRAGG
003BBBRAGG
002BBBLISA
001AAATINA PHYSI
002BBBTINA
001AAAMATT CHEM
002BBBMATT
003BBBMATT
001AAADINO MATHS
002BBBDINO
001AAARAGG BIOLO
002BBBRAGG
003BBBRAGG
Expected O/P- I want below output
001AAALISA MATHS MATHS
002BBBLISA MATHS
001AAATINA PHYSI PHYSI
002BBBTINA PHYSI
001AAAMATT CHEM CHEM
002BBBMATT CHEM
003BBBMATT CHEM
001AAADINO MATHS MATHS
002BBBDINO MATHS
001AAARAGG BIOLO BIOLO
002BBBRAGG BIOLO
003BBBRAGG BIOLO
002BBBLISA MATHS
001AAATINA PHYSI PHYSI
002BBBTINA PHYSI
001AAAMATT CHEM CHEM
002BBBMATT CHEM
003BBBMATT CHEM
001AAADINO MATHS MATHS
002BBBDINO MATHS
001AAARAGG BIOLO BIOLO
002BBBRAGG BIOLO
003BBBRAGG BIOLO
But am getting below output from my SORT card
001AAALISA MATHS MATHS
002BBBLISA MATHS
001AAATINA PHYSI PHYSI
002BBBTINA PHYSI
001AAAMATT CHEM CHEM
002BBBMATT CHEM
003BBBMATT
001AAADINO MATHS MATHS
002BBBDINO MATHS
001AAARAGG BIOLO BIOLO
002BBBRAGG BIOLO
003BBBRAGG
002BBBLISA MATHS
001AAATINA PHYSI PHYSI
002BBBTINA PHYSI
001AAAMATT CHEM CHEM
002BBBMATT CHEM
003BBBMATT
001AAADINO MATHS MATHS
002BBBDINO MATHS
001AAARAGG BIOLO BIOLO
002BBBRAGG BIOLO
003BBBRAGG
Note '003BBBMATT' doesnt have CHEM and also '003BBBRAGG' doesnt have BIOLO at the end of record.
My code- I use BBB which is default in END so when we have 2 or more occurrences of BBB for same group, the o/p fails. I'm not sure what i can use in END, as I dont find anything else defaulted. LISA, MATT like names varies for each group eventhough they are same for that group. Please suggest me an idea. Thank you!!
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(4,3,CH,EQ,C'AAA'),
END=(4,3,CH,EQ,C'BBB'),PUSH=(20:SEQ=3,23,4))
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(4,3,CH,EQ,C'AAA'),
END=(4,3,CH,EQ,C'BBB'),PUSH=(20:SEQ=3,23,4))