The SAS Output Delivery System and reporting techniques

Break page proc report ods rtf/pdf

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Break page proc report ods rtf/pdf

 

Hello,

 

I have a dataset that  contain a breaking page , byte(12) , as shown bellow

 

data test;
attrib a length=$50; 
     a= "aaaa"; output;
     a=byte(12); output;
     a= "bbbb"; output;
     a=byte(12); output;
     a= "cccc"; output;
     a=byte(12); output;
     a= "dddd"; output;
 run ;
 
 
 proc report data=test ;
 col a;
 run ;

 

I use the proc report to display the dataset within an ods PDF / RTF

I would like to break the page when the a variable equal to byte(12) , but the proc report don’t do  that , it display only a blank space.

The are another way to break page by creating a _page variable and add  break before __page / page ; but it is not appropriate because it create a new section for each breaking page

 

Best regard

 


Accepted Solutions
Solution
‎04-21-2016 04:04 AM
Occasional Contributor
Posts: 19

Re: Break page proc report ods rtf/pdf

thank you for this solution 
i have another solution which consists to replace the byte(32) values by "^R'\pagebb'" as follow

ods rtf; 
data test;
attrib a length=$50; 
     a= "aaaa"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "bbbb"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "cccc"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "dddd"; output;
 run ;

 
 proc report data=test ;
 col a;
 run ;
 ods rtf close ; 

best regard 

View solution in original post


All Replies
Super User
Super User
Posts: 7,704

Re: Break page proc report ods rtf/pdf

Hi,

 

Create a page variable containing the observations per page and break on that:

data test;
  length a $50; 
     a= "aaaa"; pge=1; output;
     a= "bbbb"; pge=1; output;
     a= "cccc"; pge=2; output;
     a= "dddd"; pge=2; output;
 run ;
  
proc report data=test ;
  col pge a;
  define pge / group noprint;  /* Or order instead of group */
  define a / "Avar";

  break after pge / page;
run;

 

 

 

 

 

Respected Advisor
Posts: 3,786

Re: Break page proc report ods rtf/pdf

This is a very good question.  I don't know the answer.   One way might be to edit the RTF file I do that to remove paragraph marks in RTFs with embedded graphics.  There are 4 paragraph marks that are inserted, by something, that take up a lot of vertical space, but enough about that.

 

Another possibility might be to use PROC DOCUMENT but that may produce the same section breaks I don't know.

 

Hope you get a good answer that's easy.

 

It might be good to know your SAS version and OS.

Occasional Contributor
Posts: 19

Re: Break page proc report ods rtf/pdf

sas version : 9.4 

os : hpux 

Respected Advisor
Posts: 3,786

Re: Break page proc report ods rtf/pdf

This uses a data step to remove the section break but did not work unless I used ODS option BODYTITLE.  I don't know if this will be helpful.

 

data test;
   do page=1 to 2;
      do n = 0 to 4;
         length a $128;
         a = repeat('It is working? ',n);
         output;
         end; 
      end;
   run ;
ods rtf file='~/section.rtf' bodytitle;
title 'title1';
footnote 'Footnote 1';
proc report data=test ;
   col page a;
   define page / order noprint; 
   define a / "Avar";
   break after page / page;
   run;
   ods rtf close;
data _null_;
   infile '~/section.rtf' length=l lrecl=1024;
   file '~/section2.rtf' lrecl=1024;
   input;
   if find(_infile_,'sect\sectd\') then do;
      putlog _infile_;
      _infile_ = transtrn(_infile_,'\sect\sectd',trimn(' '));
      putlog _infile_;
      end;
   put _infile_;
   run;

Capture.PNG

 

 

Solution
‎04-21-2016 04:04 AM
Occasional Contributor
Posts: 19

Re: Break page proc report ods rtf/pdf

thank you for this solution 
i have another solution which consists to replace the byte(32) values by "^R'\pagebb'" as follow

ods rtf; 
data test;
attrib a length=$50; 
     a= "aaaa"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "bbbb"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "cccc"; output;
     a=strip("^R'\pagebb'") ; output;
     a= "dddd"; output;
 run ;

 
 proc report data=test ;
 col a;
 run ;
 ods rtf close ; 

best regard 

Respected Advisor
Posts: 3,786

Re: Break page proc report ods rtf/pdf

I did not know about \pagebb.  But what about that weird blank cell on pages 2 and above.

 

Capture.PNG

 

 

Occasional Contributor
Posts: 19

Re: Break page proc report ods rtf/pdf

it is rtf tag to break page 

we can do that alse within ods rtf 

ods rtf text="^R'\pagebb'"; we have the same result 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 683 views
  • 1 like
  • 3 in conversation