BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
2 REPLIES 2
David_SAS
SAS Employee
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
deleted_user
Not applicable
Thank you, that is exactly what I was looking for!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 606 views
  • 0 likes
  • 2 in conversation