View previous topic :: View next topic
|
Author |
Message |
juares castro
New User
Joined: 04 May 2012 Posts: 34 Location: Brazil
|
|
|
|
Hi All !
I need to select a specific number of records of different keys. I mean, considering the example below:
INPUT - VB - LRECL=4000 - key in pos 1, length 4, numeric
0001 xxxx 0001
0000 xxxx 0002
0001 yyyy 0003
0099 aaaa 0004
0000 bbbb 0005
0004 bbbb 0006
0002 cccc 0007
0002 aaaa 0008
0099 aaaa 0009
0000 xxxx 0010
0001 xxxx 0011
0099 aaaa 0012
0003 cccc 0013
Output file should appear like this: (VB, lrecl=4000)
0000 xxxx 0002
0000 bbbb 0005
0001 xxxx 0001
0001 yyyy 0003
0002 cccc 0007
0002 aaaa 0008
0003 cccc 0013
0004 bbbb 0006
0099 aaaa 0004
0099 aaaa 0009
Each key with 2 records at maximum.
Could i use syncsort to do this? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
First two, last two, any two, two with highest or lowest figure, what? |
|
Back to top |
|
|
juares castro
New User
Joined: 04 May 2012 Posts: 34 Location: Brazil
|
|
|
|
First two.
Sorry i considered that my example was clear. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, showing unsorted data for the input and just example output without the rules is not clear.
Sort the file on the key.
On OUTREC use GROUP on your key and PUSH a SEQuence number. You have a variable-length record file, so put your sequence in the "fixed" part, right up at the front is easiest.
Your key does not start at 1 for a length of 4, because, with VB, you need to take the RDW into account. Your key is 5 for a length of 4.
On OUTFIL INCLUDE=(whereyourseqis,yourlength,ZD,LE,2) with BUILD to only include the RDW and the original part of the record. |
|
Back to top |
|
|
juares castro
New User
Joined: 04 May 2012 Posts: 34 Location: Brazil
|
|
|
|
Thanks for your response Bill.
I'll try this and reply if any problem. |
|
Back to top |
|
|
|