BookmarkSubscribeRSS Feed
P5C768
Obsidian | Level 7

I have a report where I set the colors of the header by certain groupings.  I just added total to the report using RBREAK AFTER /SUMMARIZE and I would like to color the summary row to match the corresponding header.  I know I need to use the compute statement, but I can't figure out how to set the color by the column the data is in rather than by the value of the data.  Any ideas?  Thanks!

define tot/ analysis format=comma12. 'Total' style(header) = [background = midnightblue foreground = white] ;

define  Change/ analysis format=comma12. 'Total Changed' style(header) = [background = midnightblue foreground = white] ;

define  Per_Change/ computed format=percent8.2 '% of Changed' style(header) = [background = midnightblue foreground = white] ;

define  Impact/ analysis format=comma12. 'Count of Changed' style(header) = [background = MediumBlue foreground = white];
define  NoImpact/ analysis format=comma12. 'Count of Changed' style(header) = [background = RoyalBlue foreground = white] ;
define  Per_Impact/ computed format=percent8.2 '% of Changed' style(header) = [background = MediumBlue foreground = white];
define  Per_NoImpact/ computed format=percent8.2 '% of Changed' style(header) = [background = RoyalBlue foreground = white]];
1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  The answer will depend on whether you have ACROSS usage items or not. This is hard to tell, since you don't show all of your PROC REPORT code and you don't show your ODS statements. And, you don't show your COMPUTE blocks for the COMPUTED variables.

  But, you can make the change you want in a CALL DEFINE statement. And since PROC REPORT allows you to test an automatic variable called _BREAK_, you can easily issue your CALL DEFINE based on the summary line having a value of '_RBREAK_' for the summary line.

 

   Some example code below. Not using any ACROSS items (which would cause you to need slightly different code.

cynthia

ods html file='c:\temp\showcolors.html'

    style=sasweb;

  

  proc report data=sashelp.class nowd

       style(summary)=Header;

    column name age height weight sex xxx;

    define name / order;

    define age / min 'Age'

    style(header)={background=pink};

    define height / mean 'Ht'

    style(header)={background=lightbrown};

    define xxx / computed

    style(header)={background=lightgreen};

    compute xxx;

       xxx= height.mean * age.min;

      if _break_ = '_RBREAK_' then do;

         call define (_col_,'style','style={background=lightgreen}');

       end;

    endcomp;

    rbreak after / summarize;

    compute age;

      if _break_ = '_RBREAK_' then do;

         call define (_col_,'style','style={background=pink}');

      end;

    endcomp;

    compute height;

      if _break_ = '_RBREAK_' then do;

        call define (_col_,'style','style={background=lightbrown}');

      end;

    endcomp;

   run;

ods html close;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 763 views
  • 0 likes
  • 2 in conversation