BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Knopperoni
Fluorite | Level 6

Good afternoon.  I've been looking for a solution to this problem for a while and have had no luck.  I will start by saying that, although I've used sas for a while now, the functions of proc report are still rather new to me.  That said, I have a group of variables that I wanted 2 headers for.  I was hoping to find a way to just color the background of the top header (Names) and not the entire header row.

data person;
   input name $ dept $;
   datalines;
John Sales
Mary Acctng
;
run;

proc report data=person out=stuff
style(report)={font_size=8pt} 
style(header)={font_weight=bold borderwidth=0 borderspacing=0 font_size=9pt };
COLUMN ("All Data" ("Names" Name) ("Department" Dept));

define Name / display style(column)=[cellwidth=1.2in];
define Dept / display style(column)=[cellwidth=1.2in];
run;

I've tried using call define, but can't figure out how to use that method to target just the cell that the header appears in.  I've also tried to manipulate the style in the column statement to no avail.  Hoping there's a rather easy method to this madness that doesn't require me to be an advanced coder to sort out.  Any help you can provide is greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

See if this gives you some help:

proc report data=person out=stuff
style(report)={font_size=8pt} 
style(header)={font_weight=bold borderwidth=0 
borderspacing=0 font_size=9pt  };
COLUMN ("All Data"  Name  Dept);

define Name / display style(column)=[cellwidth=1.2in] 
              style(header)=[background=pink] "Names";
define Dept / display style(column)=[cellwidth=1.2in]
              style(header)=[background=lightblue]"Department" ;

run;

View solution in original post

10 REPLIES 10
Reeza
Super User
Can you include an image of what you want here? An example from Excel is fine but it's hard to 'see' exactly what you want.
ballardw
Super User

Did you try in the Style(header) statement to include something like  "Background=pink" as on of the options?

Knopperoni
Fluorite | Level 6

Yeah, I did that, and for that most part, that works.  However, I was looking to achieve a higher level of versatility.  If I use the style function within the report header control, it would color both "Names" and "Department."  The enclosed example is just a simple test version of the actual project I'm working on and I was trying to avoid coloring the entire header row which is why I'm trying to just influence one header cell.

 

I don't know if there is really a way to achieve that level of control simply, but if there is, that's what I'm looking for.

Reeza
Super User
I messed up your thread 😞
Give me a few minutes to fix it.
Reeza
Super User
Looks like it's fixed but slightly out of order 😞
My apologies. I was trying to move it to the Reporting forum so a reporting person can respond.

Hopefully someone with reporting experience can reply. I know this is possible and until someone answers your question definitively I think the answer can be found here:
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=proc&docsetTarget=p14xega...
ballardw
Super User

See if this gives you some help:

proc report data=person out=stuff
style(report)={font_size=8pt} 
style(header)={font_weight=bold borderwidth=0 
borderspacing=0 font_size=9pt  };
COLUMN ("All Data"  Name  Dept);

define Name / display style(column)=[cellwidth=1.2in] 
              style(header)=[background=pink] "Names";
define Dept / display style(column)=[cellwidth=1.2in]
              style(header)=[background=lightblue]"Department" ;

run;
Knopperoni
Fluorite | Level 6

"AHHHHHHHHHHHHHHHHHHHHH" - that's what a sigh of relief looks like. Thank you so much.  I had to reconfigure some of my define statements slightly but this nuanced, yet simple solution is just what the doctor ordered.  @ballardw, you get the hero for the day award.  A MILLION times thank you!

Knopperoni
Fluorite | Level 6

What_I_Want.JPG

For lack of a better way of doing it - this is sort of what I'm looking for.  I want to be able to control the color background color of one of the second header cells.

Cynthia_sas
SAS Super FREQ

Hi:

  Using a format for the header background, including spanning headers works in 9.4 M5 and M6, as shown below:

Cynthia_sas_0-1602031869934.png

 

This approach might work for you. Of course you have to know what the values are going to be for the column headers in order to code the PROC FORMAT, but it might be a possibility for what you want to do.

 

Cynthia

Knopperoni
Fluorite | Level 6

Cynthia, thank you - this is a cool approach.  I will very likely use the proc format methodology at some point.  I appreciate the added insight!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2076 views
  • 4 likes
  • 4 in conversation