The SAS Output Delivery System and reporting techniques

ODS, PROC REPORT and page breaking

Not applicable
Posts: 0

ODS, PROC REPORT and page breaking

Hi, for this I'm producing RTF and using SAS 9.1.3.

If I use FRAME=HIDES and RULES=GROUPS in my style sheet, when I produce a table in PROC REPORT I get lines at the top and bottom of the table, along with a line between the header and the main body of the table - which is what I want.

I am using OPTIONS ORIENTATION=LANDSCAPE and PAPERSIZE=A4 to sort out the output file (is there another way?).

However, when my table span more than one page, I am having to force in page breaks (using BREAK AFTER in PROC REPORT) in order to get a line at the bottom of the table on each page. Is there any other way of doing this, because it's sometimes very awkward to calculate where page breaks are required. Surely there must be some way of informing ODS what page size to use and to insert the breaks itself (including the lines)?
SAS Employee
Posts: 20

Re: ODS, PROC REPORT and page breaking

Posted in reply to deleted_user
I'm afraid there is not much that can be done. The table is too large for a page and when Word makes an implicit page break, the cell borders are not expressed because of the options you want to use.

We have hopes to address this at some point by having a way to determine when a page break is needed in the SAS code rather than send Word the entire table.

Orientation and papersize are the correct controls to use. The amount of text you can fit to a page is going also be impacted by the number or titles and footntoes as well as the size of the fonts used in the table. A smaller font allows more lines.
Posts: 9,371

Re: ODS, PROC REPORT and page breaking

Posted in reply to deleted_user
Here's my .02 with a program for you to experiment with. As the previous reply said, the only thing that SAS knows when it is handling the file is where the TABLE is going to end, NOT where the VIEWER will insert a page break. So, FRAME=HSIDES puts the line under the table and not at the end of each page.
You COULD put a line (using RTF control strings) into the first footnote ...and that would get you a line that goes at the bottom of each page, because ODS puts the footnote into the footer area of the document. You can see how this footnote looks with FRAME=HSIDES if you run this program (it uses - a few of the REGIONS are too big to fit on 1 "page". After you run the program the first time, then change the FRAME=HSIDES to FRAME=ABOVE and submit the program again. This may give you something closer to what you want (lines under the column headers and a line for the footnote on each page. (Sadly, I do not know enough about RTF control strings to do more than pass on this very handy string that I got from somebody in Tech Support.)
The other pieces of ODS that go into making this work is the use of ODS ESCAPECHAR to specify an escape character so you can use the escapechar + S= in order to change PRETEXT= to pass the control string and then PROTECTSPECIALCHARS=off, which allows the string to pass from ODS to RTF unchanged.
options nodate nonumber;
title; footnote;
ods listing close;

title1 j=l font='Arial' h=10.1pt
"Protocol XXX"
j=r font='Arial' h=10.1pt

title2 j=c font='Arial' h=10.1pt "Some Table";
title3 j=c font='Arial' h=10.1pt "Report Adverse Events";

**make sure there is a SPACE between the 1 and the quote;
** in the footnote below;
footnote j=l font='Arial' h=10.1pt
"^S={protectspecialchars=off "
"pretext='\brdrt\brdrs\brdrw1 '}"
footnote2 j=l font='Arial' h=10.1pt
'Some Other Footnote Text';

ods listing close;
ods rtf file='c:\temp\line_vs_hsides.rtf' ;
ods escapechar='^';
proc report nowd
style(report)={rules=groups frame=hsides
cellspacing=0 borderwidth=1}
where region in ('Asia', 'Pacific','Canada');
column region subsidiary product sales;
define region /group;
define subsidiary/group;
define product /order;
define sales/sum;
break after region/ summarize page;
ods rtf close;
title; footnote;
Occasional Contributor
Posts: 9

Re: ODS, PROC REPORT and page breaking

Posted in reply to Cynthia_sas

Thanks for this post! I was having a similar issue and this seems to be an acceptable fix for it.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation