Stored Process: Using Alternating Background Color with PROC REPORT
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.
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!
Latest posts by Tricia Aanderud (see all)
- Creating a Web Analytics Report in SAS Visual Analytics 8.1 - 2017-06-19
- Designing Dashboards: Sending Your Style Vibe - 2017-01-21
- SAS Visual Analytics: Design Versus Reality - 2016-10-05
- Seize the Day! Submit an #SASGF Abstract - 2016-09-21
- Need a Dynamic X-Axis with Your SAS Visual Analytics Report? - 2016-07-31