SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 36505: Organizing output based on BY variable values: PROC DOCUMENT or Macro

DetailsCodeAboutRate It

When reports are created with multiple procedures that use a BY statement in each step, the default output is organized so that one procedure processes all the BY groups and outputs the tables or graphs, then the next procedure does the same, and so on. In addition, when writing output to the ODS destinations, such as PDF, a Table of Contents is created that shows the order of the output contained in the report. What if the desired report is to organize the output by the value of the BY variable so that each BY group's output appears together? This sample will show two ways to do that - one using ODS DOCUMENT and PROC DOCUMENT and the other using macro logic.

The technique used by DOCUMENT is to create the default output and then use the appropriate statements to reorder the output objects that get created. The technique used by macro is to create a unique macro variable for each value of the BY variable and then loop through the procedure steps in a macro %DO loop.

See related SAS Sample: SN-034626




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.