When creating reports with PROC REPORT, adding a summary line (grand total) is a common operation, usually performed via the RBREAK statement.
By default, this summary line adopts a standard style defined by the active ODS template (often a light gray or white background). However, for aesthetic or readability reasons, it is often desired that this total line looks exactly like the header row of the table (same background color, same bold font, same text color).
The natural first reaction is to open the ODS template's source code, identify the hexadecimal color codes for the header (e.g., cx112277 for the text and cxEDF2F9 for the background in the HTMLBlue style), and manually copy them into the statement.
/* À éviter : Code rigide et difficile à maintenir */
rbreak after / summarize style=[fontweight=bold color=cx112277 backgroundcolor=cxEDF2F9];
1
/* À éviter : Code rigide et difficile à maintenir */
2
rbreak after / summarize style=[fontweight=bold color=cx112277 backgroundcolor=cxEDF2F9];
3
Although functional, this method is problematic: if you change the ODS style (e.g., from HTMLBlue to Plateau), your total line will not adapt and will retain the old colors, creating an inconsistent design.
There are two simple ways to apply this style to your summary line.
Method 1: Local Application on the RBREAK Statement
This is the most precise method if you wish to target only the grand total generated by RBREAK.
proc report data=sashelp.class;
columns sex weight;
define sex / group;
define weight / analysis mean f=5.2;
/* On applique directement le style 'Header' à la ligne de résumé */
rbreak after / summarize style=Header;
run;
1
PROC REPORTDATA=sashelp.class;
2
columns sex weight;
3
define sex / group;
4
define weight / analysis mean f=5.2;
5
6
/* On applique directement le style 'Header' à la ligne de résumé */
7
rbreak after / summarize style=Header;
8
RUN;
Method 2: Global Application via the STYLE Option
You can also define this behavior at the level of the PROC REPORT statement itself. This instructs the procedure to use the "Header" style for any element of type "summary".
proc report data=sashelp.class style(summary)=Header;
columns sex weight;
define sex / group;
define weight / analysis mean f=5.2;
rbreak after / summarize;
run;
Les codes et exemples fournis sur WeAreCAS.eu sont à but pédagogique. Il est impératif de ne pas les copier-coller aveuglément sur vos environnements de production. La meilleure approche consiste à comprendre la logique avant de l'appliquer. Nous vous recommandons vivement de tester ces scripts dans un environnement de test (Sandbox/Dev). WeAreCAS décline toute responsabilité quant aux éventuels impacts ou pertes de données sur vos systèmes.
SAS et tous les autres noms de produits ou de services de SAS Institute Inc. sont des marques déposées ou des marques de commerce de SAS Institute Inc. aux États-Unis et dans d'autres pays. ® indique un enregistrement aux États-Unis. WeAreCAS est un site communautaire indépendant et n'est pas affilié à SAS Institute Inc.
Ce site utilise des cookies techniques et analytiques pour améliorer votre expérience.
En savoir plus.