Thanks Frank, that makes perfect sense when you explain it that way and also makes me realise why the examples in the book are the way they are.
So SPLICE works very well with "reliable" data, ie a list of state codes and then an invoice total by states for whatever states you sold in, or in this case a specific number of records for each state activity, say gross sales and taxes paid.
It's a little bit trickier if you're merging two files with some state codes on one file and some state codes on another and either might or might not have repeated records. Though I have managed somethign along those lines. How come I always seem to be pushing the envelope?
To make the above example work, all I have to do is insert records for the "blank" fields before I get to the SPLICE
...what I hadn't realised was that with WITHEACH each WITH applies to an individual duplicate record. I was looking at it like OCCURS and using the WITHs to select fields from all the duplicate records. This wouldn't work anyway as if every WITH applied to every duplicate record, they'd overwrite the WITHs from the previous duplicate record.
...erm I think
Good stuff, but like I said, suited mostly to dependalbe file configurations.