SyntaxHighlighter

Saturday, February 22, 2014

Alternating colored rows and columns

The below code shows how to use SAS's proc report to display alternating colored rows and to have the header and 1st column have matching colors. This is all accomplished using ODS style attributes.

ods html body = "x.html" style=sasweb ;
  proc report 
    data = sashelp.class
    nowd 
    style( header ) = [ background = red ]
  ;
    where age > 14 ;

    column name sex age height weight ;

    compute name ;
      count + 1 ;
      if mod( count, 2 ) then 
           call define( _row_, 'style', 'style=[background = cxd9d9d9]' ) ;
      else call define( _row_, 'style', 'style=[background = cxe9f3ff]' ) ;

      call define( _col_, 'style', 'style = [ foreground = white background = red]' ) ;
    endcomp ;     
  run ;

ods html close ;

No comments:

Post a Comment