The SAS Output Delivery System and reporting techniques

conditional highlighting in proc tabulate

Reply
Regular Contributor
Posts: 235

conditional highlighting in proc tabulate

Hello,

In my dataset i've got a variable type "T", or "D" which indicates it is a total line or a detail line. I want to higlight the Total Lines.

This I what i found out so far...

Proc format;

Value $type 'D'="Green"

  'T'="Red"

;

run;

ods listing close;

/* Set the graphics environment. */                                                                                                 

goptions reset=all cback=white border htext=10pt htitle=12pt;                                                                          

ods html file=_webout (title="Gevangenisarbeid");

PROC TABULATE data=table_result tyle={background=$type.}; 

CLASS &vars_class type / MISSING ;

VAR sumtotaal gedetineerde;

TABLE &vars_table * type,

jaar = 'Jaar' * (sumtotaal gedetineerde) ;

LABEL sumtotaal='Totaal' gedetineerde='# gedetineerden';

RUN;

ods htm close;

Any help?

SAS Super FREQ
Posts: 8,820

Re: conditional highlighting in proc tabulate

Hi,

  I see a couple of possible glitches with your code:

1) does your code actually produce results? You have "tyle" in the PROC TABULATE statement. This should be "style"

2) the STYLE option on a PROC TABULATE will change something about all the DATA cells in a table (see code below)

3) you do not show where your 'T' and 'D' values are used in the table (although one might guess that they are used on the CLASS variable TYPE. (This is will cause a conflict with #2, because CLASS variables are not placed in the DATA cells in a TABULATE table)

4) you open the ODS HTML destination, but close the ODS HTM destination. This should cause you problems.

5) you use a variable called JAAR in the TABLE statement, but it does not appear in the CLASS or VAR statement -- this should prevent TABULATE from running

 

  PROC TABULATE does support "banding", see this Tech Support note (25401 - Demonstrate the use of banding in PROC TABULATE) and the results  SAS Output. However, my tendency, in this instance would NOT be to use TABULATE, because, I think it is easier to do row level highlighting based on a CLASS or category or row variable using PROC REPORT (see pages 13 and 14, examples 3.2 and 3.3 of this paper http://support.sas.com/resources/papers/proceedings13/366-2013.pdf).

  Depending on how you want the red or green row to appear (include the header cells, only color the data cells, etc), you have more conditional control using PROC REPORT and the CALL DEFINE in a COMPUTE block than you have with TABULATE.

Cynthia

ods _all_ close;

ods html file='c:\temp\tab.html' style=sasweb;

proc tabulate data=sashelp.prdsale  style={background=yellow};

class division product  year;

var actual predict;

table division*product,

      year*(actual predict);

run;

ods html close;

Regular Contributor
Posts: 235

Re: conditional highlighting in proc tabulate

I'm sorry. I'm coming closer.

The variable jaar is in the macro variable &var_class which defines all of my class variables. On basis of Type i want to color a row red , or green. Can I manage this with <parent> or am i wrong?

proc format;

    value $type 'D'='Green'

                'T'='Red';

run;

ods listing close;                                                                     

ods html file=_webout (title="Gevangenisarbeid") style=sasweb/*stylesheet=(URL="\\spvsasbi005.intra.just.fgov.be\D\bi_dwh\Epi\Cdrga-scrtp\uds\data\style.css")*/;

PROC TABULATE data=table_result ; 

CLASS &vars_class type / MISSING ;

classlev type   / s={background=$type.};

VAR sumtotaal gedetineerde;

TABLE &vars_table * type,

jaar = 'Jaar' * (sumtotaal gedetineerde) ;

LABEL sumtotaal='Totaal' gedetineerde='# gedetineerden';

RUN;

ods html close;

SAS Super FREQ
Posts: 8,820

Re: conditional highlighting in proc tabulate

Hi:

  You did not show the CSS file in the first posting. But, without knowing what's in the CSS file, it's hard to comment. Theoretically, if you take the Tech Support note and alter the code for the "citysize" example, and assign a user defined color format to the values L, M and S (similar to your T and D), then you would be able to achieve banding with TABULATE and the < parent > syntax. However, since you have a custom CSS involved, I would recommend that you get banding working WITHOUT using your CSS and then add the CSS into the mix, to be sure that nothing in the CSS spec is conflicting with ODS. Tech Support would be the best ones who could help you with that.

  I am not at a computer with SAS today, I have altered the Tech Support example in the past to perform "sub" banding of the L, M and S within the regions in the TABULATE row area and continue the color banding across the row. So that piece will work.

cynthia

Ask a Question
Discussion stats
  • 3 replies
  • 895 views
  • 0 likes
  • 2 in conversation