Thanks for that very useful explanation. I was aware of PROC DOCUMENT but had not (yet) used it. The integration with BY processing looks as if it will save a lot of messing about with macro loops.