Help using Base SAS procedures

I want to conditionally highlight the cell.

Reply
Contributor sss
Contributor
Posts: 65

I want to conditionally highlight the cell.

============================================================
ANUM JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC TOTAL_FAIL
============================================================
4299 40 20 27 37 25 32 26 24 22 28 17 33 27.58
4264 30 30 36 15 17 27 27 30 25 27 14 24 25.17
4246 19 24 40 18 32 18 20 19 24 16 14 25 22.42
4281 16 18 31 23 17 24 27 20 19 26 13 27 21.75
41786 21 43 33 21 20 21 26 21 11 11 13 14 21.25
4080 16 19 21 16 13 23 13 18 21 17 27 20 18.67
4262 17 14 23 16 30 22 20 18 26 11 9 10 18.00
1789 19 19 14 10 21 19 24 17 18 24 9 14 17.33
4315 20 11 28 17 18 19 11 22 17 25 5 11 17.00
4297 16 11 17 15 14 14 15 16 28 12 6 26 15.83
4279 17 15 16 11 14 14 8 15 14 15 8 8 12.92
4042 15 6 8 6 3 9 13 19 8 3 5 10 8.75
41787 4 4 9 9 3 8 8 19 16 8 10 7 8.75
2377 10 6 11 4 13 11 4 8 9 4 4 7 7.58
4241 6 5 9 5 7 7 6 12 6 7 3 4 6.42
============================================================
hi.......
I want to conditionally highlight the cell.
In col(ANUM) is number for asset and values in MONTH(Jan,Feb....DEC) column are No. of Failures with respective to month and TOTAL_FAIL in mean on all month.

I want to highlight the values whose values are greater then TOTAL_FAIL With respect to ANUM col as Red or some other color.

ex:-in 1st row i want to highlight the values 40,37,32,28,33
in 2nd row i want to highlight the values 30,30,30,27,27,27

This code is not working gr8 as per ma requirement
compute JAN ;
if JAN OR FEB OR MAR OR APR GE TOTAL_FAILURES then do;
call define(_COL_,'STYLE','STYLE=[foreground=red]');
end;
else
call define(_COL_,'STYLE','STYLE=[foreground=black]');

end comp;
run;


I 'll be very thankful for you suggestion
SAS Super FREQ
Posts: 8,744

Re: I want to conditionally highlight the cell.

SAS Super FREQ
Posts: 8,744

Re: I want to conditionally highlight the cell.

Super User
Posts: 9,687

Re: I want to conditionally highlight the cell.

Hi. very interesting.
Cynthia gives very details and useful information.Are you to try what she said?
So reference my code.

[pre]
data temp;
input ANUM JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC TOTAL_FAIL ;
cards;
4299 40 20 27 37 25 32 26 24 22 28 17 33 27.58
4264 30 30 36 15 17 27 27 30 25 27 14 24 25.17
4246 19 24 40 18 32 18 20 19 24 16 14 25 22.42
4281 16 18 31 23 17 24 27 20 19 26 13 27 21.75
41786 21 43 33 21 20 21 26 21 11 11 13 14 21.25
4080 16 19 21 16 13 23 13 18 21 17 27 20 18.67
4262 17 14 23 16 30 22 20 18 26 11 9 10 18.00
1789 19 19 14 10 21 19 24 17 18 24 9 14 17.33
4315 20 11 28 17 18 19 11 22 17 25 5 11 17.00
4297 16 11 17 15 14 14 15 16 28 12 6 26 15.83
4279 17 15 16 11 14 14 8 15 14 15 8 8 12.92
4042 15 6 8 6 3 9 13 19 8 3 5 10 8.75
41787 4 4 9 9 3 8 8 19 16 8 10 7 8.75
2377 10 6 11 4 13 11 4 8 9 4 4 7 7.58
4241 6 5 9 5 7 7 6 12 6 7 3 4 6.42
;
run;
ods html file='c:\test.html' style=sasweb;
proc report data=temp nowd;
column anum JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC total_fail ;
define anum /display;
define jan /display;
define feb /display;
define mar /display;
define apr /display;
define may /display;
define jun /display;
define jul /display;
define aug /display;
define sep /display;
define oct /display;
define nov /display;
define dec /display;
define total_fail/display;
compute total_fail;
if JAN ge total_fail then call define('JAN','style','style={foreground=red}');
if FEB ge total_fail then call define('FEB','style','style={foreground=red}');
if MAR ge total_fail then call define('MAR','style','style={foreground=red}');
if APR ge total_fail then call define('APR','style','style={foreground=red}');
if MAY ge total_fail then call define('MAY','style','style={foreground=red}');
if JUN ge total_fail then call define('JUN','style','style={foreground=red}');
if JUL ge total_fail then call define('JUL','style','style={foreground=red}');
if AUG ge total_fail then call define('AUG','style','style={foreground=red}');
if SEP ge total_fail then call define('SEP','style','style={foreground=red}');
if OCT ge total_fail then call define('OCT','style','style={foreground=red}');
if NOV ge total_fail then call define('NOV','style','style={foreground=red}');
if DEC ge total_fail then call define('DEC','style','style={foreground=red}');
endcomp;
run;
ods html close;
[/pre]


BTW, proc report sometimes will give us weird result,which needs patient for us.
Good Luck.


Ksharp
Ask a Question
Discussion stats
  • 3 replies
  • 107 views
  • 0 likes
  • 3 in conversation