With PROC REPORT, a CALL DEFINE statement used within a COMPUTE block is a way to change the format of a cell within a column. The syntax for a CALL DEFINE statement is:
call define(column-id,'attribute-name',value)
The column-id can be:
An example of applying a format to a cell using CALL DEFINE follows:
proc report nowd data=sashelp.class; col name sex age weight height; compute height; if sex='F' then do; call define(_col_,'format','dollar8.2'); end; endcomp; run;
If you need to apply the format to multiple cells in a row, you will need to create a CALL DEFINE statement for each column cell. You can also use a DO loop to loop through each column-id to apply the format.
An example of applying a format to multiple cells using a DO loop and CALL DEFINE follows:
proc report nowd data=sashelp.class; col name sex age weight height; compute height; if sex='F' then do; do i = 3 to 5; call define(i,'format','dollar8.2'); end; end; endcomp; run;
Please note that the report-item in the COMPUTE statement is the last one listed in the COLUMN statement. The REPORT procedure works from left to right based on the order of the report-items in the COLUMN statement. All columns can be modified within one COMPUTE block when the last report-item is used in the COMPUTE statement.
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.
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.
** Output showing the format change of the HEIGHT variable cell when the value of Sex='F' ** Name Sex Age Weight Height Alfred M 14 112.5 69 Alice F 13 84 $56.50 Barbara F 13 98 $65.30 Carol F 14 102.5 $62.80 Henry M 14 102.5 63.5 James M 12 83 57.3 Jane F 12 84.5 $59.80 Janet F 15 112.5 $62.50 Jeffrey M 13 84 62.5 John M 12 99.5 59 Joyce F 11 50.5 $51.30 Judy F 14 90 $64.30 Louise F 12 77 $56.30 Mary F 15 112 $66.50 Philip M 16 150 72 Robert M 12 128 64.8 Ronald M 15 133 67 Thomas M 11 85 57.5 William M 15 112 66.5** Output showing the format change of the AGE/WEIGHT/HEIGHT cells when the value of Sex='F' ** Name Sex Age Weight Height Alfred M 14 112.5 69 Alice F $13.00 $84.00 $56.50 Barbara F $13.00 $98.00 $65.30 Carol F $14.00 $102.50 $62.80 Henry M 14 102.5 63.5 James M 12 83 57.3 Jane F $12.00 $84.50 $59.80 Janet F $15.00 $112.50 $62.50 Jeffrey M 13 84 62.5 John M 12 99.5 59 Joyce F $11.00 $50.50 $51.30 Judy F $14.00 $90.00 $64.30 Louise F $12.00 $77.00 $56.30 Mary F $15.00 $112.00 $66.50 Philip M 16 150 72 Robert M 12 128 64.8 Ronald M 15 133 67 Thomas M 11 85 57.5 William M 15 112 66.5
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> REPORT |
Date Modified: | 2010-04-28 15:22:13 |
Date Created: | 2010-02-17 13:47:10 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | Microsoft Windows Server 2003 Enterprise Edition | ||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows 2000 Datacenter Server | ||||
z/OS | ||||
OpenVMS VAX | ||||
Microsoft Windows 95/98 | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows XP Professional | ||||
Windows 7 Enterprise 32 bit | ||||
Windows 7 Enterprise x64 | ||||
Windows 7 Home Premium 32 bit | ||||
Windows 7 Home Premium x64 | ||||
Windows 7 Professional 32 bit | ||||
Windows 7 Professional x64 | ||||
Windows 7 Ultimate 32 bit | ||||
Windows 7 Ultimate x64 | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
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 |