BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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;
1 REPLY 1
Cynthia_sas
Diamond | Level 26
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]

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 795 views
  • 0 likes
  • 2 in conversation