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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 976 views
  • 0 likes
  • 2 in conversation