View previous topic :: View next topic
|
Author |
Message |
N.Nirmal Raj
New User
Joined: 19 Sep 2013 Posts: 7 Location: India
|
|
|
|
Hi ,
My requirement is to extract records based on grouping key which should be
equal to 3 records, should not pick any other records having grouping > 3
or <3.
Key Recd
a 1
a 1
a 1
a 1
a 1
b 2
b 2
b 2
c 3
c 3
c 3
d 4
d 4
Desired Output
b 2
b 2
b 2
c 3
c 3
c 3
I used the following sort card but it fetched records grouped in 1,2 & 3.
I need only records grouped in 3.
//SYSIN DD *
SORT FIELDS=(1,4,BI,A,5,10,D)
INREC=(1:31,32:SEQNUM,3,ZD,RESTART=(1,4))
OUTFIL FILES=OUT,BUILD=(1:31,32,ZD,LT,+4)
/* |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Use JOINKEYS with the same dataset for both input files. Join on your key.
In JNF2CNTL use INREC to set up a record (WHEN=INIT and BUILD containng the key and a count of one which is big enough for the greatest number of multiple keys that you can have.
Use SUM FIELDS= for the count field.
If your input is sorted, specify SORTED,NOSEQCHK on the F1 JOINKEYS.
Define a REFORMAT record which has your entire F1 record plus the summed count from F2.
Use OPTION COPY for the main task.
Use OUTFIL INCLUDE= for the summed count on the reformat being equal to three, and use BUILD= to cut the summed count off the record. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
N.Nirmal Raj,
Use SELECT operator with EQUAL(3) and you will get the desired results.
for your sample data assuming the key is the first 1 byte then use the following toolin
Code: |
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,1,CH) EQUAL(3)
//* |
The output from the above is keys b and c |
|
Back to top |
|
|
N.Nirmal Raj
New User
Joined: 19 Sep 2013 Posts: 7 Location: India
|
|
|
|
Skolusu,
Thanks a lot your sort card worked good. |
|
Back to top |
|
|
|