BookmarkSubscribeRSS Feed
Konkordanz
Pyrite | Level 9

Hi,

I want to group some columns as "test1" and "test" and want to colorize them differently and the font should be bold. But which is the easiest way to do that? Via google I found that: https://communities.sas.com/t5/SAS-Programming/proc-report-making-spanning-header-a-different-color/...

But are dummy-variables really necessary? Is this way the only and best way to do that? That sounds pretty complicated to me.

Thank you!

 

 

proc report data=shoes(obs=3);
column ("test1"(region subsidiary)) ("test2"(product sales));
define region / display;
define subsidiary / display;
define product / display;
define sales / display;
run;

 

 

7 REPLIES 7
ballardw
Super User

Without example data of what you have and the rules involved for exactly how to "colorize them differently" there really isn't any way to tell if dummy variables are needed.

 

So please describe what coloring you expect.

Konkordanz
Pyrite | Level 9

Right, sorry, I didnt set the dataset-step correctly. Thats the sample:

 

proc report data=sashelp.shoes(obs=3);
    column ("test1"(region subsidiary)) ("test2"(product sales));
	define region / display;
	define subsidiary / display;
	define product / display;
	define sales / display;
 run;

 

What I want is to colorize the spanning headers "test1" and "test2" differently. For example:

Konkordanz_0-1675059578326.png

 

Cynthia_sas
SAS Super FREQ

Hi:

  I'm not entirely clear what you mean by grouping and colorizing. As you show them now, your test1 and test2 are just spanning headers so without some advanced technique, you only have one way to alter the style attributes of those header cells, as shown in #2 and #3.:

Cynthia_sas_0-1674853500958.pngCynthia_sas_1-1674853568521.png

But if you want the headers for test1 and test2 to be the SAME as the other headers and columns, then you have to either use dummy variables (#4) or a technique like the user defined format in #5:

Cynthia_sas_2-1674853636309.pngCynthia_sas_3-1674853660028.png

  Since it is not entirely clear to me what you are trying to do, this is all I can envision at this point.

Cynthia

 

Konkordanz
Pyrite | Level 9

Thx for your answer. What I want is different colored spanning header. Something like that:

Konkordanz_0-1675061529666.png

 

 

I tried a little bit around and the current result is this code with a strange result:

 

proc format;
	value $test
	"test1" = 'lightblue'
	"test2" = "grey"
	"Region" = "red";
run;	

/*=================================================================================================*/
/*Output-Optionen*/
ods excel file="." ;
/*=================================================================================================*/
 
proc report data=sashelp.shoes(obs=3) style(header)=[background=$test.];
    column ("test1"(region subsidiary)) ("test2"(product sales));
	define region / display;
	define subsidiary / display;
	define product / display;
	define sales / display;
 run;

 

After running this code SAS shows this result:

Konkordanz_1-1675061753425.png

 

Right, no colors. But now I open it with Excel...

Konkordanz_3-1675061864297.png

 

 

...and in Excel it shows the result I want:

Konkordanz_4-1675061891561.png

 

Now my spanning headers are colored differently and I got the result without dummyvariables. But only within the excel output. Do you see a problem in my code?

Kurt_Bremser
Super User

No problems. When I run your code on SAS on Demand without the Excel destination, I get this result:

Bildschirmfoto 2023-01-30 um 10.04.43.png

Which main ODS destination do you use?

 

Konkordanz
Pyrite | Level 9

Sorry, but what means "main ODS destination"?

Kurt_Bremser
Super User

It's what you select in the Results settings of your SAS interface (SAS Studio or Enterprise Guide). The default setting in SAS On Demand is HTML (in particular, HTML5).

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 753 views
  • 0 likes
  • 4 in conversation