BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9

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?

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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;

Filipvdr
Pyrite | Level 9

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;

Cynthia_sas
SAS Super FREQ

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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