BookmarkSubscribeRSS Feed
Flip
Fluorite | Level 6
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?
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
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:
[pre]
compute before grpvar;
holdgrp = grpvar;
endcomp;
[/pre]

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.

cynthia
Flip
Fluorite | Level 6
Thanks, that worked.

compute before campaign_type;
hold_camp = campaign_type;
endcomp;
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}');
endcomp;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 624 views
  • 0 likes
  • 2 in conversation