i have some trouble to do some sorting data set
my data set is structured like :
year 9(04)
typ 0 or 1 or 2 pic 9(02)
unique key for group record
group of record on (key,typ)
record contain one particular fields A(mnt signed packed decimal s9(11)V9(02) comp 3) which i want test value but only if first record typ is 0 or 1
input data set
YYYY 0 key1 A
YYYY 0 key2 A
YYYY 1 key3 A
YYYY 2 key3 A
YYYY 0 key4 A
YYYY 2 key4 A
YYYY 1 key5 A
YYYY 2 Key6 A
YYYY 0 Key7 A
YYYY 0 key8 A
YYYY 0 key9 A
YYYY 2 key9 A
YYYY 0 key2 A
YYYY 1 key3 A
YYYY 2 key3 A
YYYY 0 key4 A
YYYY 2 key4 A
YYYY 1 key5 A
YYYY 2 Key6 A
YYYY 0 Key7 A
YYYY 0 key8 A
YYYY 0 key9 A
YYYY 2 key9 A
this sort is actually obtain by a sort fields
But how grouping and include only group of record satified some condition on first record typ
I want include only group record with the same key and which satisfied test value of A only on record typ 0 or 1 , record typ 0 and 1 are mutualy exclusive
for example:
I retain group
YYYY 0 key4 A
YYYY 2 key4 A
if test value A of record 0 is satisfied
I exclude record
YYYY 2 key6 A because no record typ 0 or 1
I exclude group
YYYY 0 key9 A
YYYY 2 key9 A
and record
YYYY 0 key2 A
for the same reason value A of record typ 0 don't satisfied condition
OUTPUT
the output must rearrange column / line ( excel need unpack format)
to obtain
YYYY * selected field of record typ 0 or 1 * eventually selected field of record type 2 if satisfied group * key *
i don't know how obtain this result and if it's possible without lost performance ( it's a big data set)