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
SAS Super FREQ
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]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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