This is a well-written description of how to create a macro that cutomizes the behavior of a SAS program. The various steps are all well explained and clear.

From an efficiency point of view, the advantage of the BY-group analysis is that it passes through the data one time for each procedure. The macro approach shown here passes through the data k times for each procedure, where k is the number of BY-group categories. Therefore, for large data, the BY-group analysis is preferred.

If you want to generate a report that orders the tables and graphs by the BY groups, you can write the output to an ODS document, and then reorder the output using the REPLAY statment in PROC DOCUMENT. This approach is shown in SAS Sample 36505, which also includes a version of your analysis (but without your helpful exposition). Another SAS Sample contains similar information.

So my question is: can you adapt your macro to give us the best of both worlds? Use the BY-group analysis to efficiently get all of the tables and graphs into a document. (No macro is required for this step.) Then write a macro that fills out the body of a PROC DOCUMENT call to replay the output in the order that you desire?