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;
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.
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:
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.:
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:
Since it is not entirely clear to me what you are trying to do, this is all I can envision at this point.
Cynthia
Thx for your answer. What I want is different colored spanning header. Something like that:
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:
Right, no colors. But now I open it with Excel...
...and in Excel it shows the result I want:
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?
No problems. When I run your code on SAS on Demand without the Excel destination, I get this result:
Which main ODS destination do you use?
Sorry, but what means "main ODS destination"?
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.