BookmarkSubscribeRSS Feed
LLOUKINE
New User | Level 1

Hi, I am working on the report and I need help with applying the same colors to the headers of the spanning columns. For example I want to add “azure” color to the header cell 'PUBLISHABLE w. FLAGS'.  Also, how I can add a color to the background for the 'Cutoffs Percentages' cell?  Below is my SAS code and the output I got so far. I am looking for a suggestions how I can modify my code to color other header cells in the table below that are not colored now. Thank you!

 

 

proc report data=TestData (keep=cycle entity     case Frequency  GeoMean   

Deficient_Frequency Deficient_Percent Marginal_Frequency    Marginal_Percent);

 column ('PUBLISHABLE w. FLAGS' cycle entity     case) ('Geometric Results'     Frequency  GeoMean    )

('Cutoffs Percentages' ( 'Deficient (<148 pmol per L)' Deficient_Frequency     Deficient_Percent)

('Marginal (148-220 pmol per L)' Marginal_Frequency    Marginal_Percent )) ;

 define cycle/display style(header)={background=azure};

 define entity/display style(header)={background=azure};

 define case/display style(header)={background=azure};

 COMPUTE cycle;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=azure]");

 ENDCOMP;

 COMPUTE entity;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=azure]");

 ENDCOMP;

 COMPUTE case;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=azure]");

 ENDCOMP;

*geomeans;

 define Frequency/display 'N' style(header)={background=PAY};

 define GeoMean/display style(header)={background=PAY};

 define LowerCLGM/display style(header)={background=PAY};

 COMPUTE Frequency;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=PAY]");

 ENDCOMP;

 COMPUTE GeoMean;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=PAY]");

 ENDCOMP;

*Deficient Percent;

 define Deficient_Frequency/display style(header)={background=GWH};

 define Deficient_Percent/display style(header)={background=GWH};

 COMPUTE Deficient_Frequency;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=GWH]");

 ENDCOMP;

 COMPUTE Deficient_Percent;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=GWH]");

 ENDCOMP;

*marginal Percent;

 define Marginal_Frequency/display style(header)={background=PWH};

 define Marginal_Percent/display style(header)={background=PWH};

 COMPUTE Marginal_Frequency;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=PWH]");

 ENDCOMP;

 COMPUTE Marginal_Percent;

 CALL DEFINE(_COL_, "style", "STYLE=[BACKGROUND=PWH]");

 ENDCOMP;

 run;

 

 

LLOUKINE_0-1727469967818.png

 

1 REPLY 1
ballardw
Super User

Very strong suggestion: Only include enough variables to demonstrate the issue.

Best is to include some data.

Or use one of the SAS training data sets like SASHELP.CLASS that only has a few observations and variables to start with.

 

Consider the following, which is code that you should be able to run as you should have the SASHELP.CLASS data set:

proc format library=work;
value $hdrcolor
      'Student name and sex'='lightgreen'
      'Measurements' = 'gold'
;
run;

proc report data=sashelp.class
   style(header)= [background=$hdrcolor.]
   ;
   columns ('Student name and sex' name sex) ('Measurements' height weight);
   define name /    style=[background=lightgreen];
   define sex /     style=[background=lightgreen];
   define height/   style=[background=gold];
   define weight/   style=[background=gold];
run;

The format is used to assign a color to the background of any header that has the shown text (which means it may not be the best for ACROSS values). The text appearing in the header must be exactly the same as the text in the first column of the definition for the $hdrcolor format.

This same approach can be used to modify other characteristics such as the text color, font , font size or other characteristics using multiple formats and the appropriate style element.

 

I used lightgreen instead of azure because on my monitor I have a very hard time seeing if "azure" was even applied.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 47 views
  • 0 likes
  • 2 in conversation