The SAS Output Delivery System and reporting techniques

Formating a group

Super Contributor
Posts: 359

Formating a group

In excelxp I am formating the background color of certain rows. I would like to set the color for a group. In this case a summary of earlier rows that is pre calculated.

In my compute block I check the value of this column and set the background color. My problem is that since Proc Report places a blank in subsequent rows for this group, they do not get the format. Is there any way to set the background color for this entire group?
Posts: 8,743

Re: Formating a group

This is one of those cases where it's hard to visualize the code from your description. Seeing the PROC REPORT code, your COMPUTE block and what the data looks like would be useful. Using COMPUTE block techniques, you can "grab" the value of a GROUP report item in a COMPUTE before...something like:
compute before grpvar;
holdgrp = grpvar;

And then later, if you want to test the value (as for a CALL DEFINE with _ROW_), you must test the HOLDGRP temporary variable....and not the GRPVAR.

I -think- that's what you're asking about. But seeing your starting code would help.

And, as a teacher, it is my duty to give you this warning: You are going to use ODS to place formatting instructions into an XML file. You plan to open that XML file with Excel. There are some instances where Excel deals with formatting the same way the browser would treat the formatting. There are some instances where Excel ignores your formatting. Generally, I have found that CALL DEFINE formatting is honored in Excel for simple things like background and foreground color and font settings. Since that is what you say you want to do, that should be OK.

Super Contributor
Posts: 359

Re: Formating a group

Thanks, that worked.

compute before campaign_type;
hold_camp = campaign_type;
compute attr_comm;
if hold_camp = 'Total' then
call define(_ROW_,'STYLE','style={background=yellow}');
else if channel = 'All' then
call define(_ROW_,'STYLE','style={background=green}');
else if attr_camp = 'Total' then
call define(_ROW_,'STYLE','style={background=red}');
else if attr_comm = 'Total' then
call define(_ROW_,'STYLE','style={background=orange}');
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation