The SAS Output Delivery System and reporting techniques

proc report

Reply
Occasional Contributor
Posts: 19

proc report

Hello,

 

We are using the proc report in our application with the proc template to customize the RTF outputs

We manage the breek pages with _page_ variable

We need that the line under the table will be displayed in the bottom of each page

But when the rows of the same _page_ cannot be included in the same page the line in the bottom of page is not displayed

The example below  illustrate the issue, so When you run it , in the first page the line is not displayed because for _page_ =1 , there are 60 rows but only 44 rows can be contained in the page

Thank you for helping us to resolve this issue

 

ods path(prepend) work.templat(update);

proc template;
	define style Styles.Custom;
		parent=styles.rtf;
		style fonts / 'TitleFont'=("Times New Roman",9pt,normal) 
			'TitleFont2'=("Times New Roman",9pt,normal) 
			'StrongFont'=("Times New Roman",9pt,normal)
			'EmphasisFont'=("Times New Roman",9pt,normal) 
			'headingEmphasisFont'=("Times New Roman",9pt,normal) 
			'headingFont'=("Times New Roman",9pt,bold) 
			'docFont'=("Times New Roman",9pt,normal) 
			'footFont'=("Times New Roman",9pt,normal) 
			'FixedEmphasisFont'=("Times New Roman",9pt,normal) 
			'FixedStrongFont'=("Times New Roman",9pt,normal) 
			'FixedHeadingFont'=("Times New Roman",9pt,normal) 
			'BatchFixedFont'=("Times New Roman",9pt,normal) 
			'FixedFont'=("Times New Roman",9pt,normal);
		style color_list / 'link'=blue 'bgH'= grayBB 'fg'= black 'bg' = white;
		style Body from Document / topmargin=3.2cm bottommargin=3.8cm leftmargin=2.8cm rightmargin=1.5cm;
		style Table from Table / frame=hsides   rules=group cellpadding=1pt cellspacing=.15pt borderwidth=.15pt;
	end;

data test;
	length a $128;

	do _page_=1 to 4;
		nb=(4 - _page_)*20;

		do n = 1 to nb;
			a = 'Data Test -- line : ' !! strip(put(n,best.));
			output;
	end;
	end;
run;

ods rtf file='~/test.rtf' bodytitle style=Custom startpage=yes;
title 'title1';
footnote 'Footnote 1';

proc report data=test style(header)= [background=white 
	borderbottomcolor=black borderbottomwidth=0.1pt just=center vjust=top] contents="";;
	col _page_ a;
	define _page_ / order noprint;
	define a / "Avar";
	break before _page_ / page contents='';
run;

ods rtf close;

 

Super User
Super User
Posts: 7,977

Re: proc report

What you are talking about is a calculation to know what rows appear on one page.  What I do in my outputs is keep it as simple as possible.  There are a few options, you could fix how many rows appear on each page - say 10 appear nicely, then do:

data want;
  set have;
  pge=int(_n_/10)+1;
run;

proc report data=have;
  column pge...;
  define pge / noprint order;
  ...
  break after pge / page;
run;

If you want anything more sophisticated then it quickly becomes more complicated - you need to check pages sizes, font sizes, print area, number of characters etc.

Occasional Contributor
Posts: 19

Re: proc report

thank you for your replay RW9, 

 
compute the number of line to be displayed per page can be a solution
is there a formula to compute the number of line in order to display the maximum line in each page ? 

Super User
Super User
Posts: 7,977

Re: proc report

Well, that is what I mention when I talk about more complicated.  You formula would need to know paper size, printable area, title/footnotes, fonts, fonst sizes/weights, images etc.  Its is way more complicated than even that.  I haven't seen any code that can comprehensively do this task, hence why I estimate number of rows per page and fix it myself per output.

Occasional Contributor
Posts: 19

Re: proc report


yes but in our requirements , we must not limit the number of rows but adapted to contain all the available space of the page

SAS Super FREQ
Posts: 8,868

Re: proc report

Hi:

  If you have one "page" that is supposed to contain 100 rows of data and then another "page" that will only contain 20 rows of data, that seems like the type of report that is best delivered via ODS HTML. When you are dealing with any of the "paged" destinations, like LISTING, or PDF or RTF, then you are bound to the physical limits of the printed page. So you cannot, for example, squish 100 rows on 1 PDF page without making the font for that page impossibly small. And if you do use an impossibly small font you have to use it for the WHOLE report....not just the page with 100 rows, but also the page with 20 rows.

 

  With normal BY group processing, you get a new BY group starting on a new page. Thus, if one group has 100 rows, then it will probably use up 2 physical pages in PDF and RTF output (or maybe 3 pages, depending on the font size of the output). But then your second BY group of 20 rows will ALWAYS start on a new page.

 

  I am not sure what you mean, exactly, when you say: "we must not limit the number of rows but adapted to contain all the available space of the page" -- 100 rows will NOT fit in all the available space of 1 physical sheet of paper. So, to me, your requirements seem unachievable.

 

cynthia

Occasional Contributor
Posts: 19

Re: proc report

Posted in reply to Cynthia_sas

Our need is to display the maximum of line that can hold every page
the goal is to find a formula to fill the _page_ variable, which indicate for  each line in what page number will actually be displayed thereby the instruction break before _page_ / page contents=''; will display the line in bottom of pages 

 

the formula must taking into account
plice
the font size
the number of column of the table
the width of each column 
title and footenote

 

our output is RTF and PDF

SAS Super FREQ
Posts: 8,868

Re: proc report

It is very hard for you to control pagination the way you envision. You might need to consult with Tech Support to find out whether what you want to do is even possible.

cynthia
Ask a Question
Discussion stats
  • 7 replies
  • 390 views
  • 1 like
  • 3 in conversation