The SAS Output Delivery System and reporting techniques

Add Color to ODS/Proc Report

Reply
N/A
Posts: 0

Add Color to ODS/Proc Report

Hello

I am trying to add color to a field that I have flagged, the code below doesn't seem to work. Any suggestions?

ods listing close;
ods results=off;
ods html file="C:\DMYM\XLS\Disaster.xls" style=SASWeb;

proc report data=dmym.natcalc nowd headline headskip center split='*' formchar(2)='_' missing;
column UAID Trans_date TRANS_ENTER_TM city AUX_ACCT_STATUS mkt_seg brand2 state flag;
define flag / analysis noprint;
compute UAID;
if FLAG.sum eq 1 then call define(_row_,"style","style={background=red}");
endcomp;
run;

ods _all_ close; ods listing;
SAS Super FREQ
Posts: 8,866

Re: Add Color to ODS/Proc Report

Posted in reply to deleted_user
Hi:
PROC REPORT builds a report row from left to right, one report item at a time. PROC REPORT does -not- have a PDV, like the Data Step.

So that seems like it's not a big difference. Your logic might work in a DATA step program. But when PROC REPORT is placing UAID on the report row, it has not placed anything else on the report row, so at that point in time, the COMPUTE block for UAID has NO visibility of the value for FLAG.SUM and since the COMPUTE block for UAID executes when the item is placed on the report row, you will never see any highlighting.

The program below illustrates the correct way (#2) to get the row highlighted.

cynthia
[pre]
ods listing close;
ods html file='c:\temp\showrow.html' style=sasweb;

proc report data=sashelp.class nowd;
title '1) will not work';
column name height weight age;
compute name;
if age.sum = 14 then
call define(_ROW_,'STYLE','style={background=red}');
endcomp;
run;


proc report data=sashelp.class nowd;
title '2) will work';
column name sex height weight age;
define sex / display noprint;
compute age;
if age.sum = 14 and name = 'Henry' then
call define(_ROW_,'STYLE','style={background=red}');
else if age.sum=14 then
call define(_ROW_,'STYLE','style={background=yellow}');
else if age.sum=12 and sex='F' then
call define(_ROW_,'STYLE','style={background=pink}');
else if age.sum=12 and sex='M' then
call define(_ROW_,'STYLE','style={background=lightblue}');
endcomp;
run;
ods html close;
[/pre]
Ask a Question
Discussion stats
  • 1 reply
  • 99 views
  • 0 likes
  • 2 in conversation