Hi,
I need the sequence number repeated for every 'n' number of records. These 'n' number of records will have the same key.
Not always will the input contain 'n' number of records for a group.
In this case, is it possible to create dummy records or blank records with sequence numbers still, if there are records less than 'n'?
Like,
Input:
Code:
AAA
AAA
AAA
BBB
BBB
CCC
CCC
CCC
Say, Positions 1-3 will have the key. I need to repeat sequence number for every 3 records (not more than 3 records would have the same key),
1. Used JOINKEYS with the same dataset for both files
2. Applying seq num for both the files, with seq num starting from 1 for one dataset and 0 for another.
3. Reapplied sequence number with restart.
4. Checked the reapplied new sequence number at key change.
6. If its not the restart value, added the records using OUTFIL and '/' to create empty records.
Thanks again for the help. The link you provided and the hyperlinks that it has are of much use!
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
Today I was working on something similar, but not exactly like this. I have to add the sequence no and total count of each type of record. Posting my code here. Hope this helps.
You can use INREC instead of OUTREC. I see no reason for the 100:X, since you later BUILD only 5-byte records. There's no point adding data that you are not going to use.
You don't really need to include the blanks (Xs) on your first BUILD either. They can be useful to "see" the data more easily as you develop a solution, but can come out of the final version. To take them out, you need to adjust the later positions. You can "automate" that, and make your control cards more "self-documenting" by using symbols/SYMNAMES.
I like to make things easier to read, so here's part of a rearrangement:
As well as being easier to read, it is easier to maintain. Note some of the formatting that mistah kurtz applied as well (I'd go further, but that's me :-) ). The way you've coded the BUILD with the slash operator (/) is good (though again I'd go further and put the "/," on its own line.
You got the solution, it is then just a question of some consolidation and tidying, and applying what you've learned from the whole process in the future.