BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Zatere
Quartz | Level 8

Hi all,

 

I would ask for your help on the following.

 

I am using this code:

 


data have;
    length CUSTID 8 Name $20 Address $30 Product $20;
    input CUSTID Name $ Address $ Product $ Value Quantity;

    datalines;
1 A CityA Laptop 1200 2
2 B CityB Phone 800 1
3 C CityC Tablet 400 3
4 D CityD Monitor 300 2
5 E CityE Keyboard 50 5
;
run;



PROC REPORT DATA=have;

COLUMN 
("Customer Information" 
    (CUSTID Name Address) 
)

("Sales Information" 
    (Product Value Quantity) 
);

define CUSTID / display "CUSTID" style(header)=[background=cx00B050 foreground=white]; 
define Name / display "Name" style(header)=[background=cx00B050 foreground=white];
define Address / display "Address" style(header)=[background=cx00B050 foreground=white];

define Product / display "Product" style(header)=[background=cxFF0000 foreground=white]; 
define Value / display "Value" style(header)=[background=cxFF0000 foreground=white];
define Quantity / display "Quantity" style(header)=[background=cxFF0000 foreground=white];

RUN;

It gives the following result:

 

 

 
 

result.png

 

What I am trying to do is for the group headers to have the same colour as the column headers as follows:


result want.png
Is that possible?

 

Thanks in advance.

 



 

1 ACCEPTED SOLUTION
3 REPLIES 3
Zatere
Quartz | Level 8
Using a format for the header background worked good for me
A_Kh
Barite | Level 11

ODS Escapechar can be used to apply specific colors in headers. 
In this specific example I used ods rtf as an output file. 

ods escapechar='~'; 
ods rtf file='test.rtf';
PROC REPORT DATA=have;
COLUMN ("~S={backgroundcolor=cx00B050 foreground=white}Customer Information" (CUSTID Name Address) )("~S={backgroundcolor=cxFF0000 foreground=white}Sales Information" (Product Value Quantity));

define CUSTID / display "CUSTID" style(header)=[background=cx00B050 foreground=white]; 
define Name / display "Name" style(header)=[background=cx00B050 foreground=white];
define Address / display "Address" style(header)=[background=cx00B050 foreground=white];

define Product / display "Product" style(header)=[background=cxFF0000 foreground=white]; 
define Value / display "Value" style(header)=[background=cxFF0000 foreground=white];
define Quantity / display "Quantity" style(header)=[background=cxFF0000 foreground=white];

RUN;
ods rtf close; 

rtf.png 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 3 replies
  • 348 views
  • 3 likes
  • 3 in conversation