Help using Base SAS procedures

Set Summary Line Color by Header in Proc Report

Reply
Frequent Contributor
Posts: 84

Set Summary Line Color by Header in Proc Report

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]];
SAS Super FREQ
Posts: 8,869

Re: Set Summary Line Color by Header in Proc Report

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;

Ask a Question
Discussion stats
  • 1 reply
  • 136 views
  • 0 likes
  • 2 in conversation