BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rkk33
Obsidian | Level 7

Hello,

 

How to print multiple titles at the left upper corner of each page (not just on the first page of the output of PROC REPORT, but on all of them) while having the BODYTITLE option on?

 

I tried the following code, but it prints the titles in the first rows of the table (please see the attachement). I don't need the titles on the table, I would like to have them on the left upper corner of the page.

 

data one; do x = 1 to 350; y = x * x; z = x  * x  * x ; output; end; run;

options ls = 180  ps=25 orientation=landscape;
options nodate nonumber;
title1;
title2;
ods bodytitle;
ods rtf file="sample99.rtf";
proc report data=one nowd missing
            split='|' formchar(2)='_'
            headline
            headskip contents=''
            spacing=4
			ls=132 ps=43
			;
	column x y z;
	define x /DISPLAY id width = 20  center format = 10.0 style=[cellwidth=2cm];
	define y /DISPLAY width = 20     center format = 10.0 style=[cellwidth=2cm];
	define z /DISPLAY width = 20     center format = 10.0 style=[cellwidth=2cm];
	compute before _page_ / style = [protectspecialchars=off] ;
		line@15 "Company Pharmaceuticals";
		line@15 "Study: XYZ1234";
		line@15 "Site: Glesborg";
		line@15 "";
	endcomp;
run;
ods rtf close;

  

 

I use SAS 9.2.

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  As already noted, there is NOT an ODS BODYTITLE statement. BODYTITLE is an option that goes on your ODS RTF statement. BODYTITLE is an option that is only applicable to the RTF destination.

 

  Also, some of your options are LISTING only options and are ignored by ODS. I have indicated those options below using the strikethrough indicator:

proc report data=one nowd missing
            split='|' formchar(2)='_'
            headline
            headskip contents=''
            spacing=4
	    ls=132 ps=43
			;

 

With regard to Linesize (LS) and Pagesize (PS) options, either in the OPTIONS statement or in the PROC REPORT statement, those are LISTING only options and have no impact on RTF-based destinations. Finally, this code, using TAGSETS.RTF works for me, implementing the TITLE suggestion:

 

options orientation=landscape 
        topmargin=.50in bottommargin=.50in rightmargin=.50in leftmargin=.50in;
options nodate nonumber;
 
** change continue_tag to 'OFF' if you do not want to see (continued);
ods tagsets.rtf file="sample99.rtf" options(continue_tag='ON');
		title1 j=l "Company Pharmaceuticals";
		title2 j=l "Study: XYZ1234";
		title3 j=l "Site: Glesborg";

proc report data=one nowd missing
            split='|'   contents='';
	column x y z;
	define x /DISPLAY id   center format = 10.0 style=[cellwidth=2cm];
	define y /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
	define z /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
run;
ods tagsets.rtf close;

using_tagsets_rtf_no_need_bodytitle.png

 

As you can see, with TAGSETS.RTF, you do NOT need the BODYTITLE options, since the titles are automatically put into the body of the document at the top of each page. If you do not like the (continued) at the bottom of each page, you can easily get rid of it by turning the continue_tag suboption to 'OFF'.

 

  With regular RTF, the BODYTITLE option will not work the way you want. It will only put your SAS titles at the top of the FIRST page, not the top of every page. With "regular" RTF, the SAS TITLE statement puts the title into the Header area of the document, that is the only way to have the information repeat at the top of every page. If you do NOT want your titles in the document Header, then TAGSETS.RTF will do what you want.

 

cynthia

View solution in original post

8 REPLIES 8
ballardw
Super User

1: Bodytitle is an option that goes on the ODS RTF statement. You should see an error in your log for ODS Bodytitle; as Statement not valid or out of order with Bodytitle underlined.

ods rtf file="sample99.rtf" bodytitle;

 

2: You do not have any title statements for bodytitle to use currently. What your are getting is the text from the compute before _page_ which will be part of the table.

Before or as part of the Proc Report you would have something like:

Title1 "Company Pharmaceuticals";

Title2 "Study: XYZ1234tle";

and remove those from the comput before. If you only have one study site then you could also move that to Title3 and remove the compute before entirely.

 

rkk33
Obsidian | Level 7

Hi Ballardw,

 

1. Yes, you are right, I did have an error message. Now I put the BODYTITLE on ODS RTF and no errors show.

 

2. The reason why I was trying to use compute block was that I wanted my titles show at every page of the output, not just the first one. If I use the "title" statements instead, the titles, unfortunately, will only be on the first page. Same with footers. So this doesn't quite solve my problem yet, but thank you for looking into it !

Cynthia_sas
SAS Super FREQ

Hi:

  As already noted, there is NOT an ODS BODYTITLE statement. BODYTITLE is an option that goes on your ODS RTF statement. BODYTITLE is an option that is only applicable to the RTF destination.

 

  Also, some of your options are LISTING only options and are ignored by ODS. I have indicated those options below using the strikethrough indicator:

proc report data=one nowd missing
            split='|' formchar(2)='_'
            headline
            headskip contents=''
            spacing=4
	    ls=132 ps=43
			;

 

With regard to Linesize (LS) and Pagesize (PS) options, either in the OPTIONS statement or in the PROC REPORT statement, those are LISTING only options and have no impact on RTF-based destinations. Finally, this code, using TAGSETS.RTF works for me, implementing the TITLE suggestion:

 

options orientation=landscape 
        topmargin=.50in bottommargin=.50in rightmargin=.50in leftmargin=.50in;
options nodate nonumber;
 
** change continue_tag to 'OFF' if you do not want to see (continued);
ods tagsets.rtf file="sample99.rtf" options(continue_tag='ON');
		title1 j=l "Company Pharmaceuticals";
		title2 j=l "Study: XYZ1234";
		title3 j=l "Site: Glesborg";

proc report data=one nowd missing
            split='|'   contents='';
	column x y z;
	define x /DISPLAY id   center format = 10.0 style=[cellwidth=2cm];
	define y /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
	define z /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
run;
ods tagsets.rtf close;

using_tagsets_rtf_no_need_bodytitle.png

 

As you can see, with TAGSETS.RTF, you do NOT need the BODYTITLE options, since the titles are automatically put into the body of the document at the top of each page. If you do not like the (continued) at the bottom of each page, you can easily get rid of it by turning the continue_tag suboption to 'OFF'.

 

  With regular RTF, the BODYTITLE option will not work the way you want. It will only put your SAS titles at the top of the FIRST page, not the top of every page. With "regular" RTF, the SAS TITLE statement puts the title into the Header area of the document, that is the only way to have the information repeat at the top of every page. If you do NOT want your titles in the document Header, then TAGSETS.RTF will do what you want.

 

cynthia

rkk33
Obsidian | Level 7

Hi Cynthia,

 

Your answer has brought me closer to the solution. The first problem I encountered was that the continue_tag="OFF" didn't actually remove the "continue" mark. I found the following workaround, that did not quite fix the problem because a little rectangle still appears at the bottom of the page:

STYLE Continued from Continued / pretext = "" font=("Arial", 1pt) width=1%;

 

Thank you, I am now trying to use your approach to get to the desired outputs. To be "(Continued)". I use SAS 9.2.

-- Rkk33

rkk33
Obsidian | Level 7

Hi again,

 

At this time I still have a rudimentary rectangle in place of a "Continued" that I am hoping to get rid of, and, as always, very grateful for any suggestions!

 

Cheers

Rkk

Cynthia_sas
SAS Super FREQ

Hi:

  I don't understand what you mean by "rectangle", when I run my code, but change the continue_tag to 'OFF', this is what I get. I don't know what you mean by a little rectangle. I used the standard RTF style. No style change needed. You might want to work with Tech Support. I am running 9.4 M3. Here is page 1. The only thing I have when I turn paragraph symbols on is a Word page break at the bottom of the page, but that is to be expected with TAGSETS.RTF.

cynthia

 

continue_eq_OFF.png

rkk33
Obsidian | Level 7

Hi Cynthia,

 

Thanks for the reply! I ran the following code, you can see a small rectangle at the bottom of the first page right under the middle column.

 

data one; do x = 1 to 50; y = x * x; z = x  * x  * x ; output; end; run;

%macro fontSpecs();
	   FONT_FACE = "SAS Monospace"
	   FONT_SIZE = 7pt
	   FONT_WEIGHT = medium
	   FONT_STYLE = roman
	   FOREGROUND = black
	   BACKGROUND = white
%mend;
proc template;
	define style Styles.Custom;
	parent = Styles.Default;
	*class Continued / pretext= _undef_ font=("SAS Monospace", 1pt) frame=void borderspacing=0 padding=0;
	STYLE Continued from Continued / pretext = "" font=("Arial", 1pt) width=1%;
	STYLE SystemTitle  /	%fontSpecs();
	STYLE Header       / %fontSpecs();
	STYLE Data         / %fontSpecs() ;
	STYLE SystemFooter / %fontSpecs();
	STYLE Table        / %fontSpecs()
	   BORDERWIDTH = 1
	   CELLSPACING = 0pt
	   CELLPADDING = 0pt
	   FRAME = ABOVE
	   RULES = GROUPS
	;
	STYLE SysTitleAndFooterContainer /CELLSPACING=0;
	end;
run;

options orientation=landscape 
        topmargin=.50in bottommargin=.50in rightmargin=.50in leftmargin=.50in;
options nodate nonumber;
 
** change continue_tag to 'OFF' if you do not want to see (continued);
ods tagsets.rtf file="C:\sample99.rtf" options(continue_tag='OFF')  style=Styles.Custom;
		title1 j=l "Company Pharmaceuticals";
		title2 j=l "Study: XYZ1234";
		title3 j=l "Site: Glesborg";

proc report data=one nowd missing
            split='|'   contents='';
	column x y z;
	define x /DISPLAY id   center format = 10.0 style=[cellwidth=2cm];
	define y /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
	define z /DISPLAY      center format = 10.0 style=[cellwidth=2cm];
run;
ods tagsets.rtf close;


 

 

Here it is:

 

the little rectangle.png

Thank you again for help with my problems.

rkk33
Obsidian | Level 7

I think I have a solution now. With the following style definition I don't have no more annoying rectangles at the bottom of each non-ending page.

 

proc template;
     define style styles.nocontinued;
     parent=styles.rtf ;
     style Continued from Continued / pretext=" " font=("Arial", 1pt) width=1%;
     style parskip from parskip / font=("Arial", 1pt);
end;
run;
ods tagsets.rtf file='c:\myrtf_tradtional.rtf' style=styles.nocontinued;

Thanks for all your support!  But if it OK, I will post again, because it can be discouraging sometimes to look for solutions of apparently simple and common things that have been done for many decades, but for some reason still require esotheric knowledge of SAS gurus like you, guys. Thank you!

 

-- rkk33

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
  • 8 replies
  • 7893 views
  • 2 likes
  • 3 in conversation