Sample 45458: Customize the order of GROUP or ACROSS variable values in PROC REPORT
GROUP and ACROSS variables in PROC REPORT are ordered by their formatted values by default. If no format is applied, the BEST12. format is used. Alternatives to the default can be specified in the ORDER= option in the DEFINE statements in PROC REPORT. When none of the alternatives provide the desired order, you can create a customized order by doing the following:
- Create a format with PROC FORMAT and specify the NOTSORTED option.
- Add the ORDER=DATA, FORMAT=, and PRELOADFMT options to the DEFINE statement in PROC REPORT.
The sample code on the Full Code tab illustrates this.
Please note that the PRELOADFMT option applies only to GROUP and ACROSS variables.
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.
GROUP and ACROSS variables in PROC REPORT are ordered by their formatted values by default. If no format is applied, the BEST12. format is used. Alternatives to the default can be specified in the ORDER= option in the DEFINE statements in PROC REPORT. When none of the alternatives provide the desired order, you can create a customized order by doing the following:
- Create a format with PROC FORMAT and specify the NOTSORTED option.
- Add the ORDER=DATA, FORMAT=, and PRELOADFMT options to the DEFINE statement in PROC REPORT.
Please note that the PRELOADFMT option applies only to GROUP and ACROSS variables.
data sample;
input category;
datalines;
1
2
2
1
0
1
1
2
;
run;
/* Specify the NOTSORTED option when creating the format. */
proc format;
value myyn (notsorted)
1 = 'Yes'
2 = 'No'
0 = 'Unknown';
run;
/* Specify GROUP or ACROSS usage, FORMAT=, PRELOAFMT, and ORDER= options. */
title 'Group variable';
proc report data=sample nowd;
column category n;
define category / group format=myyn. preloadfmt order=data;
run;
title 'Across variable';
proc report data=sample nowd;
column category, n;
define category / across format=myyn. preloadfmt order=data;
run;
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.
Group variable 10:46 Monday, January 23, 2012 7
category n
Yes 4
No 3
Unknown 1
Across variable 10:46 Monday, January 23, 2012 8
category
Yes No Unknown
n n n
4 3 1
This sample illustrates how to customize the order of GROUP or ACROSS variable values in PROC REPORT.
Date Modified: | 2012-02-10 08:47:33 |
Date Created: | 2012-01-23 11:05:12 |
Operating System and Release Information
SAS System | Base SAS | 64-bit Enabled AIX | 9 TS M0 | |
64-bit Enabled HP-UX | 9 TS M0 | |
64-bit Enabled Solaris | 9 TS M0 | |
HP-UX IPF | 9 TS M0 | |
Microsoft Windows XP Professional | 9 TS M0 | |
Microsoft Windows Server 2003 Standard Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9 TS M0 | |
Microsoft Windows NT Workstation | 9 TS M0 | |
Microsoft Windows 2000 Server | 9 TS M0 | |
Microsoft Windows 2000 Professional | 9 TS M0 | |
Microsoft Windows 2000 Datacenter Server | 9 TS M0 | |
Microsoft Windows 2000 Advanced Server | 9 TS M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9 TS M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9 TS M0 | |
z/OS | 9 TS M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | |
Linux | 9 TS M0 | |
OpenVMS Alpha | 9 TS M0 | |
Tru64 UNIX | 9 TS M0 | |