Hi,
I am using proc template to generate a systemtitle with preimage and pretext. This is the header for the complete document.
proc template;
define style Styles.Custom_nl;
parent = Styles.Printer;
style Body from Defaults/
topmargin=0.6in
leftmargin=0.6in
rightmargin=0.6in
just = center
;
replace fonts /
'TitleFont' = ("Segoe UI",12pt,Bold) /* Titles from TITLE statements */
'TitleFont2' = ("Segoe UI",10pt,Bold ) /* Proc titles ("The XX Procedure")*/
'headingFont' = ("Segoe UI",10pt,Bold) /* Table column and row headings */
'docFont' = ("Segoe UI",8pt) /* Data in table cells */
'footFont' = ("Segoe UI",8pt) /* Footnotes from FOOTNOTE statements */;
replace color_list /
'bgH' = cx9C1B3A /* row and column header background */
'bgT' = white /* table background */
'bgD' = white /* data cell background */
'fg1' = black /* text color */
'fg2' = white
'bg' = white; /* page background color */
replace Table from Output /
frame = box /* outside borders: void, box, above/below, vsides/hsides, lhs/rhs */
rules = all /* internal borders: none, all, cols, rows, groups */
cellpadding = 4pt /* the space between table cell contents and the cell border */
cellspacing = 0.25pt /* the space between table cells, allows background to show */
borderwidth = 0.25pt /* the width of the borders and rules */
background = color_list('bgT') ;
style header /
background = cx9C1B3A
foreground = white
font = fonts("Headingfont")
font_weight = bold;
Style systemtitle from TitlesAndFooters /
font = fonts("TitleFont")
cellpadding = 0
cellspacing = 0
preimage = "logo.png"
pretext = ' My header '
;
Style PageNo from TitlesAndFooters /
font = fonts("footFont")
cellpadding = 0
cellspacing = 0
pretext = "Page "
just=r
vjust=b;
/* style SystemFooter from SystemFooter /*/
/* font = fonts("footFont");*/
style rowheader from header;
end;
run;
When I use the title for my table it get added to the header of the document instead of forming a header in the document.
options papersize=A4 nodate orientation=landscape center;
ods rtf file = 'doc.rtf' style= Custom_nl;
title 'Boys';
proc print data=sashelp.class(where=(sex='M'));
run;
title 'Girls';
proc print data=sashelp.class(where=(sex='F'));
run;
ods rtf close;The result is the following.
I would like to have the following as the results where my title is not a part of the header of the document.
Any help is highly appreciated. Thanks a lot.
You have added the STARTPAGE=NO option which was not in your original code. As I mentioned in my first statement, you use BODYTITLE to move Titles and Footnotes to the body of the document. However, when you use BODYTITLE and also use STARTPAGE=NO, this will affect the titles.
You can use ODS RTF TEXT= instead of a Title statement as shown in this example.
ods escapechar='^';
options nodate orientation=landscape center papersize=a4;
ods listing close;
ods rtf file = 'doc.rtf' style= Custom_nl startpage=no bodytitle;
title 'Boys';
proc print data=sashelp.class(where=(sex='M'));
run;
title;
ods rtf text='^S={outputwidth=100% font_weight=bold font_size=12pt just=c} Girls';
proc print data=sashelp.class(where=(sex='F'));
run;
ods rtf close;
ods listing;
To move the header into the body of the document, add the BODYTITLE option as follows:
ods rtf file = 'doc.rtf' style= Custom_nl bodytitle;
To get a line break between the PRETEXT and the TITLE text, you can add ^n either after PRETEXT or in the TITLE statement as follows:
ods escapechar='^';
ods rtf file = 'doc.rtf' style= Custom_nl bodytitle;
title '^n Boys';
Thanks Kathryn,
The issue here is not the new line but separating the header of the document from the title of the table. Is there a way that the title is not added to the header of the document? I would like the title to appear on top of the table and not in the header.
ods escapechar='^';
options papersize=A4 nodate center;
ods rtf file = 'doc.rtf' style= Custom_nl startpage=no;
title '^n Boys';
proc print data=sashelp.class(where=(sex='M'));
run;
title '^n Girls';
proc print data=sashelp.class(where=(sex='F'));
run;
ods rtf close;In the output below you will see that the title for the second table has been moved to the header of the second page.
You have added the STARTPAGE=NO option which was not in your original code. As I mentioned in my first statement, you use BODYTITLE to move Titles and Footnotes to the body of the document. However, when you use BODYTITLE and also use STARTPAGE=NO, this will affect the titles.
You can use ODS RTF TEXT= instead of a Title statement as shown in this example.
ods escapechar='^';
options nodate orientation=landscape center papersize=a4;
ods listing close;
ods rtf file = 'doc.rtf' style= Custom_nl startpage=no bodytitle;
title 'Boys';
proc print data=sashelp.class(where=(sex='M'));
run;
title;
ods rtf text='^S={outputwidth=100% font_weight=bold font_size=12pt just=c} Girls';
proc print data=sashelp.class(where=(sex='F'));
run;
ods rtf close;
ods listing;
Thanks. I did not want to use ODS Text as this will lead to changing the code, but it looks like my only option.
The text generated by ODS TEXT=, would get grey box around it. That lead you can not make this text as a bookmarker.
So the best solution is using PRETEXT= option of PROC REPORT.
options nodate orientation=landscape center papersize=a4;
ods rtf file = 'c:\temp\doc.rtf' startpage=no ;
proc report data=sashelp.class(where=(sex='M')) style={pretext='Boys'};
run;
proc report data=sashelp.class(where=(sex='F')) style={pretext='Girls'};
run;
ods rtf close;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.