The SAS Output Delivery System and reporting techniques

Highlighting Complete Columns

Reply
N/A
Posts: 0

Highlighting Complete Columns

I have heard about conventional traffic-lighting, where cell values are in a different colour according to their value. I also know how to highlight a particular column header using, say, CLASSLEV within TABULATE. But how do I highlight a complete column? Suppose I have a CLASS variable DATE for last week and I want to emphasise all values for, say, Wednesday. Is this possible?
SAS Employee
Posts: 174

Re: Highlighting Complete Columns

It is possible but not easy. You have to combine traffic lighting with TABULATE's special-purpose STYLE= syntax. Here's an example:
[pre]
ods html body="band.html"; ods listing close;

title;

data;
input region $ citysize $ pop product $ saletype $
quantity amount;
cards;
NC S 25000 A100 R 150 3750.00
NE S 37000 A100 R 200 5000.00
SO S 48000 A100 R 410 10250.00
WE S 32000 A100 R 180 4500.00
NC M 125000 A100 R 350 8750.00
NE M 237000 A100 R 600 15000.00
SO M 348000 A100 R 710 17750.00
WE M 432000 A100 R 780 19500.00
NE L 837000 A100 R 800 20000.00
SO L 748000 A100 R 760 19000.00
WE L 932000 A100 R 880 22000.00
NC S 25000 A100 W 150 3000.00
NE S 37000 A100 W 200 4000.00
WE S 32000 A100 W 180 3600.00
NC M 125000 A100 W 350 7000.00
NE M 237000 A100 W 600 12000.00
SO M 348000 A100 W 710 14200.00
WE M 432000 A100 W 780 15600.00
NC L 625000 A100 W 750 15000.00
NE L 837000 A100 W 800 16000.00
SO L 748000 A100 W 760 15200.00
WE L 932000 A100 W 880 17600.00

proc format;
value $salefmt 'R'='Retail'
'W'='Wholesale';

/*-- define region background color --*/

value $regcol 'NC'='CX37E139'
'NE'='CXDFFDC5'
'SO'='CX37E139'
'WE'='CXDFFDC5';


proc tabulate;
class region saletype;
classlev region / s={background=$regcol.};
class citysize / s=;
classlev citysize / s=;
var quantity / s=;
keyword sum / s=;
format saletype $salefmt.;
label quantity="Quantity";
keylabel all="Total";


table (saletype=' ' all),
region=' '*citysize*quantity*sum*{style=};

run;

ods html close; ods listing;
[/pre]

I'll point out that if you blank out a heading through which style is inherited, you must declare the inheritance with STYLE=. Otherwise the inheritance will not take effect. This is counter-intuitive, to say the least.

Good luck!

-- David Kelley, SAS
N/A
Posts: 0

Re: Highlighting Complete Columns

Thank you, that is exactly what I was looking for!
Ask a Question
Discussion stats
  • 2 replies
  • 110 views
  • 0 likes
  • 2 in conversation