When a PROC REPORT COMPUTE block is executed, the DATA step compiler is called. The PROC REPORT COMPUTE block can handle most of the DATA step functionality, including a variation of array processing.
The sample code on the Full Code tab illustrates how to apply a character and a numeric array within a COMPUTE block. A dummy column is added to the COLUMN statement and is used as the COMPUTE block to handle the array processing.
This example shows how to apply trafficlighting or highlighting based on the value of another column.
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.
The sample code below illustrates how to apply a character and a numeric array within a COMPUTE block. A dummy column is added to the COLUMN statement and is used as the COMPUTE block to handle the array processing.
This example shows how to apply trafficlighting or highlighting based on the value of another column.
data desserts;
input dessert $ 1-16 posmean poslo poshi taste repeat sweet new;
if taste lt poslo then pl06flag1=-1;
else if taste gt poshi then pl06flag1=1;
else pl06flag1=0;
if repeat lt poslo then pl06flag2=-1;
else if repeat gt poshi then pl06flag2=1;
else pl06flag2=0;
if sweet lt poslo then pl06flag3=-1;
else if sweet gt poshi then pl06flag3=1;
else pl06flag3=0;
if new lt poslo then pl06flag4=-1;
else if new gt poshi then pl06flag4=1;
else pl06flag4=0;
datalines;
Chocolate cake 3.25 3.12 3.38 3.44 3.35 3.08 3.18
Banana pudding 3.60 3.20 4.00 3.88 3.15 3.34 4.21
Red Velvet cake 3.15 2.80 3.50 3.72 3.26 3.29 2.76
Ice cream 3.50 3.25 3.75 3.45 3.63 3.31 3.42
Brownies 3.80 3.60 4.00 4.23 3.55 4.18 3.66
;
run;
proc format;
value colorfm
-1 = '#FF8888'
1 = '#AAFFAA'
other = 'lightyellow';
run;
%let colcnt = 4;
%let pl06name1 = taste;
%let pl06name2 = repeat;
%let pl06name3 = sweet;
%let pl06name4 = new;
options orientation=landscape;
ods listing close;
ods pdf file='myreport.pdf' style=sasweb notoc;
proc report nowd split='*' data=desserts
style(report)={background=#BBBBBB outputwidth=8.0in}
style(header)={font_weight=medium background=#E0E0E0 foreground=black just=center}
style(summary)={font_weight=bold background=#E0E0E0 foreground=black
font_style=italic just=right};
column dessert ('Preference' poslo posmean poshi) &pl06name1 -- &&pl06name&colcnt;
column pl06flag1 - pl06flag&colcnt dummy;
define dessert / display 'dessert';
define poslo / display '-1 SD' format=4.2;
define posmean / display 'Mean' format=4.2;
define poshi / display '+1 SD' format=4.2;
define &pl06name1 -- &&pl06name&colcnt / display format=4.2 ;
define pl06flag1 - pl06flag&colcnt / display noprint;
define dummy / computed noprint;
compute dummy;
array name(&colcnt) $ ("&pl06name1" "&pl06name2" "&pl06name3" "&&pl06name&colcnt");
array flag(4) pl06flag1 pl06flag2 pl06flag3 pl06flag4;
do i=1 to dim(name);
call define(name(i),'style','style=[background=' || put(flag(i),colorfm.) || ']');
end;
endcomp;
title1 'PROC REPORT output using an array to traffic light';
run;
quit;
ods _all_ 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: | 2011-09-14 15:46:25 |
Date Created: | 2011-07-18 11:10:30 |
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 |