Posted: Mon Feb 26, 2007 7:05 am Post subject: How to find record count that belongs to particular key
Hi All,
I have a input file with record lenght of 250. (10,11) bytes are key fields. This is not unique key. I have a requirement, I want to count the key field and if same key avail in the input file more than 400 times than i have to drop first 200 records with that key. Is there any way to do this in SORT.
Please help me.
Kolusu,
Thanks for your reply
Yes if the key occurance is less than 400 than i have to copy that into output file.
If its greater than 400 I have to drop first 200 occurances and remaining will be copied into output file.
errr, i have a question.
notes this statement,"WHEN=(259,8,ZD,GT,400), OVERLAY=(267:C'Y')"
it may means , only when 259,8,ZD,GT,400 , the 267,1,ch,equals y
but the following outfil condition says
"OMIT=(259,8,ZD,LE,200,AND,267,1,CH,EQ,C'Y')"
there seems a conflict between them,
or did i misunderstand?
i beg for your reply.
thanks in advance.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Apr 20, 2007 12:59 pm Post subject:
waitling,
For a better understanding, consider the following input
Code:
A -REC # 01
A -REC # 02
A -REC # 03
A -REC # 04
A -REC # 05
A -REC # 06
B -REC # 01
B -REC # 02
B -REC # 03
Now for each key(the first byte) if the key occurs more than 5 times I have to drop the first 2 records of key. So I am expecting the folloiwng output
Code:
A -REC # 03
A -REC # 04
A -REC # 05
A -REC # 06
B -REC # 01
B -REC # 02
B -REC # 03
If you look at the above output, I have dropped rec # 1 and rec # 2 for the key 'A'. Since the key 'B' has only 3 records and 3 is not greater than our threshold limit of key we retain all the keys.
Now run the following job
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
A -REC # 01
A -REC # 02
A -REC # 03
A -REC # 04
A -REC # 05
A -REC # 06
B -REC # 01
B -REC # 02
B -REC # 03
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//P1 DD SYSOUT=*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(OUT1) ON(01,1,CH) WITH(01,49) -
WITHALL KEEPBASE USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=(1,1,CH,A)
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(41:SEQNUM,8,ZD,RESTART=(1,1),
50:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(41,8,ZD,GT,5),
OVERLAY=(50:C'Y'))
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum