for data and <code> snippets good manners suggest to use the code tags
( the text is displayed with a fixed font and make easier for the people spending their OWN time helping to understand what You are trying to tell )
unfortunately the way the output is formatted You will need at least two steps
the first one to decide where to split the data
and the second for the reformatting
Code:
1
2
. split point
3
4
.split point
5
6
Code:
1 3 5
2 4 6
it would have been easier for an horizontal reformat
sort can do it in a single pass ( or ICETOOL RESIZE )
You always have 21 records as a input ?, if yes, then use the below code, if no shows us the sample input and required output for more than 21 records.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
The first two GROUPs can be merged together.
The fifth group, with RECORDS=1, can be turned into a WHEN=(logicalexpression).
You are relying on EQUALS for your SORT to work as expected. If you put on a second key of the 81,1 you don't need EQUALS.
An alternative for the OUTFIL is to use INCLUDE= for 81,1 equal to 3 and just have an ordinary OUTFIL otherwise (cutting down to 80, only outputting the data required). I'm not sure 29 is the correct length (three sixes and two spacing characters gets me to 20).
Can also be done with a USING on RESIZE for simplified code (as RESIZE would do the sticking-together).
The fifth group, with RECORDS=1, can be turned into a WHEN=(logicalexpression).
Why we should change this to WHEN=(logicalexpression), Is it for performance ?
Bill woodger wrote:
You are relying on EQUALS for your SORT to work as expected. If you put on a second key of the 81,1 you don't need EQUALS.
You mean this ? Please correct me if i amwrong
Code:
SORT FIELDS=(82,1,CH,A,81,1,CH,A)
Bill woodger wrote:
An alternative for the OUTFIL is to use INCLUDE= for 81,1 equal to 3 and just have an ordinary OUTFIL otherwise (cutting down to 80, only outputting the data required). I'm not sure 29 is the correct length (three sixes and two spacing characters gets me to 20).
You are right, changed it.
Quote:
Can also be done with a USING on RESIZE for simplified code (as RESIZE would do the sticking-together).
The reason why i didnt choose this because, we need Records from 1st,7th,14 etc. and not 1st, 2nd, 3rd.
The reason is you are effectively specifying the same group, in two different ways. Firstly by RECORDS=7, setting the ID, then by change of ID.
One GROUP is sufficient, specifying both the ID and the SEQ on the PUSH.
The GROUP with RECORDS=1 is a rare beast. It only affects the current record. You may find a use for it when it is followed by another WHEN=GROUP, but if there is no subsequent WHEN=GROUP it can be replaced with a simple WHEN=(logicalexpression) which indeed will be more efficient (not that you'd notice with 21 records).
Yes, if you SORT on the SEQ and then on the ID there is no danger (without EQUALS) of getting the columns mixed.
ICETOOL's RESIZE, as with other data-manipulation operators, operates at the OUTREC stage (which is why you can't specify OUTREC in the USING control cards). This means that if the data is in the wrong order for the RESIZE, it can be formatted with INREC (if necessary) and SORTed before the RESIZE is done, and OUTFIL can even be used for further processing.
Of course, if it is not a fixed number of records, it will require two passes of the data. It would be possible to generate the control cards for the second pass.
Moderators, Please edit my previous code with this, Because previous code will work only for multiple of 3 records. below solution will work irrespective of that.