SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 34626: How to rearrange tables using PROC DOCUMENT

DetailsCodeAboutRate It
The default order of tables displayed by a SAS procedure when a BY statement is used is as follows:
BYGROUP 1:
 Table 1
 Table 2
 Table n

BYGROUP 2:
 Table 1
 Table 2
 Table n

It is often the case that the desired order is:

BYGROUP1: Table 1
BYGROUP2: Table 1

BYGROUP1: Table 2
BYGROUP2: Table 2

Using SAS macro logic, the desired order can be achieved, but requires multiple procedure steps to accomplish the desired output. With the use of ODS DOCUMENT and PROC DOCUMENT, output from one or more SAS procedures (PROC FREQ in the sample code) can be stored to a DOCUMENT itemstore, then with PROC DOCUMENT, the output can be replayed in the desired order without repeating the initial procedure (FREQ) step.

Additional information on the ODS DOCUMENT destination and PROC DOCUMENT is available here.


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.