PROC REPORT creates columnar report output. The columns are created from a COLUMN statement. A DEFINE statement instructs PROC REPORT how a variable is used in the output report. Each variable on the COLUMN statement can have only one usage definition listed on the DEFINE statement. If the variable listed on the COLUMN statement needs to be shown in more than one column with different usages, there are two methods that can be used.
The first method is to preprocess the data set. In the preprocessing, the variable that needs to be used more than once is duplicated and assigned a different variable name. Then in PROC REPORT, the duplicated variables are listed with the new variable names and the DEFINE statements are created accordingly. This method does require a change to the original data set.
The second method allows PROC REPORT to create the duplicate variables. This technique uses an alias. The alias is used on the COLUMN statement in the form of variable-name=alias. The alias variable name is used on the DEFINE statement. In a COMPUTE block, the alias name is used in every situation except when the alias variable is part of an ACROSS. In this case, the column number is used in the form of _Cn_.
The sample code on the Full Code tab uses the second method to illustrate how to create a column of MIN and a column of MAX for the same variable within a grouping.
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.
data example;
input a $ b $ mydate mmddyy8.; ;
datalines;
wilma stone 01122001
wilma stone 02122001
wilma stone 01012001
fred stone 03052008
fred stone 03152008
fred stone 03152009
;
run;
ods html;
title 'MIN and MAX date per patient';
proc report nowd data=example;
column a b mydate=min_mydate mydate=max_mydate;
define a / group;
define b / group;
define min_mydate / min format=mmddyy10. 'min date';
define max_mydate / max format=mmddyy10. 'max date';
run;
ods html close;
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.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> REPORT |
Date Modified: | 2018-11-08 15:45:23 |
Date Created: | 2010-11-11 15:39:09 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Windows 7 Home Premium x64 | ||
Windows 7 Home Premium 32 bit | ||||
Microsoft Windows Server 2008 for x64 | ||||
Microsoft Windows XP Professional | ||||
Windows 7 Enterprise 32 bit | ||||
Windows 7 Enterprise x64 | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows Server 2003 for x64 | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 95/98 | ||||
OS/2 | ||||
Microsoft® Windows® for x64 | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
OpenVMS VAX | ||||
z/OS | ||||
Windows 7 Professional 32 bit | ||||
Windows 7 Professional x64 | ||||
Windows 7 Ultimate 32 bit | ||||
Windows 7 Ultimate x64 | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
Windows Vista for x64 | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX | ||||
Linux | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Solaris for x64 | ||||
Tru64 UNIX |