BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KarlK
Fluorite | Level 6

The sample program below produces the attached HTML file (Win 7 32 bit, SAS 9.3 TS1M2). This is a simplified version of a much a bigger report that I'm currently doing by pre-processing the data and outputing with Proc Report. I want to switch to Proc Tabulate because that would allow me to eliminate the pre-processing step. The problem is I can't get Tabulate to format the output to meet the project specs. Specifically, the column headers' background color needs to vary by class level. I've got it for the class levels themselves using a format, but I want the statistic keaders under the class headers to "inherit" the color of their corresponding class level and I can't seem to get that figured out.

To clarify, if you look at the example (tabtest.html), the backgrounds for "N" and "%" under the "Individual" header should be yellow, and the "N" and "%" under the "Group" header should be light green. Any advice on how I can get that?

Thanks in advance!

Karl

Sample program:

data one;

input InVsGr X Ctr;

datalines;

1 1  5

1 2 20

1 3 35

2 1 50

2 2 65

2 3 80

;;;;

run;

proc format;

value f1f

    1 = "Individual"

    2 = "Group";

value f2f

    1 = "Cat 1"

    2 = "Cat 2"

    3 = "Cat 3";

value c1f

    1 = "yellow"

    2 = "light green";

quit;

ods html file="c:\windows\temp\tabtest.html";

proc tabulate data = one;

class InVsGr X;

table X=' ',

   InVsGr=' ' * (n='N' pctn<X>='%') /

   box = [label = 'Label Placeholder'];

classlev InVsGr / style = [background=c1f.];

freq ctr;

format InVsGr f1f. X f2f.;

title 'Proc Tabulate Test';

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi,

I don't have time to test this right now, but you might want to try using style=<parent> on the KEYWORD statement for the N and PCTN statistic, something like this:

keyword n  pctn / style=<parent>;  

(that is < parent > as: less than symbol parent greater than symbol with no spaces between -- not sure how the forum will represent the < and > signs)

cynthia

View solution in original post

3 REPLIES 3
KarlK
Fluorite | Level 6

Never mind, my friends. Figured it out. I found an old paper by Cynthia@sas in which she reminded me of the <parent> style syntax.

If you're interested, I just needed to add the following:

keyword n pctn / style = <parent>;

Cynthia_sas
SAS Super FREQ

Hi,

I don't have time to test this right now, but you might want to try using style=<parent> on the KEYWORD statement for the N and PCTN statistic, something like this:

keyword n  pctn / style=<parent>;  

(that is < parent > as: less than symbol parent greater than symbol with no spaces between -- not sure how the forum will represent the < and > signs)

cynthia

KarlK
Fluorite | Level 6

Thanks, Cynthia. I knew you'd know, so I purposely tagged you in my "Oops, I figured it out" reply, in the hopes you'd see that and not waste your time with a response to my OP.

Anyway, thanks as always for your wisdom. Now if I could just figure out a general way to do green bar shading without pre-processing the data, I might actually come to like Proc Tabulate.

Karl

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