BI Tools

Tips and tricks for building information maps, OLAP cubes, reports, and dashboards

BI Admin

Learn your way around a SAS BI installation.

Visual Analytics

Learn your way around the SAS Visual Analytics tool

Coding & Data

Extract, transform, and load your data into the SAS BI toolset

Stored Processes

Create and design stored processes like a rock star

Home » Data Visualization, Stored Processes

Stored Process: Using Alternating Background Color with PROC REPORT

Submitted by on 2012-10-30 – 8:17 AM 2 Comments

I remember when I began learning how to program using SAS.  One of my first tasks was to create a set of reports that listed the trouble tickets from the customer.  This was before it was easy to get information from SAS to Excel and the goal was to have the reports on the website so it could be reviewed easily.

All Hail My SAS Heroes!

PROC REPORT results were ugly and hard to read – the manager did not complain but he wasn’t impressed.  What a breakthrough when I found Lauren Haworth Lake’s ODS for PRINT, REPORT, and TABULATE paper she presented at SUGI 26.  It was genius! Instantly – a new SAS hero was standing next to Ron Cody and Susan Slaughter/Lora Delwiche.  Without a lot of work – I could create a really standout report!  It was great because it was easy to code and the manager was impressed!  (Yippie!)

So my marvelous trick was really just adding alternating row of color to make the report easier to read.  Here’s a quick example of what a difference the background color can make to readability.  The first example is the report using the SAS supplied style Journal – this is plain out of the box style.

Now here’s some different examples using alternating row colors.  I’m not going to draw a conclusion about which color works the best – I think it depends on what you are doing.  What I will emphasize is that the color makes it easier for the user to know which row they are on.  There is not a lot of difference between Hex Code #DCDCDC and #EEE8DC, but there is a huge difference when the background is a darker color.

Technique

The technique was crazy easy.  Here’s the code for the above result- a compute block was added that determines if there is an odd or even row.  In the Style you can set the background, foreground, and even font appearance. In the Call Define area where the STYLE= is added – this is where you can add a variety of HTML tags to control everything.

In the example below – I have the background color set to beige (#EEE8DC) and the font set to bold.  I have the foreground option commented out – but you could uncomment that option to set the text color. If you need some help determining the HEX code for the background or foreground – get some help here.  And if you are setting the style as I did, then make sure you take appropriate action on the stored process macros as Angela suggests here!

 


Learn More about SAS Stored Processes and Prompts

You can learn more tips and tricks for creating, debugging, and using SAS stored processes in the 50 Keys to Learning SAS Stored Processes book. It's a complete guide to SAS stored processes. Check Amazon for best pricing and quick shipping!

 

The following two tabs change content below.

Tricia Aanderud

Director of Data Visualization at Zencos Consulting
Tricia Aanderud is a SAS Business Intelligence and Visual Analytics consultant based in Raleigh, NC who works for Zencos Consulting. She has written several books about SAS, presented papers at many SAS conferences, and has been using SAS since 2001. Contact her for assistance with your next project.

Tags: ,

2 Comments »

  • Good idea Michelle!

  • Hi Tricia,

    I have produced reports before where there were 7 columns in the quarterly report:
    1) the item being reported
    2) Numbers for the same quarter in the previous year
    3) Numbers for the current quarter in current year
    4) % change
    5) Rate for the same quarter in the previous year
    6) Rate for the current quarter in current year
    7) % change

    Rather than having alternating colours for the rows the client wanted alternating columns so that the 2 columns for the same quarter in the previous year had a background colour of #F0F0F5 the 2 columns for the current quarter in the current year had a background colour of #D2DCF0 and the % change column background colour was white.

    To distinguish important rows (specific line items in the report) the text was in bold and in a navy colour. This allowed us to both highlight specific rows in the report and also emphasis what quarter figures you were looking at.

    Cheers,
    Michelle