Determining number of lines in proc report output

Accepted Solution Solved
Reply
Contributor
Posts: 40
Accepted Solution

Determining number of lines in proc report output

Hello,
I would appreciate help regarding the following. I am using proc report with ods pdf output in SAS 9.3. As part of the output, I would like to include a table with a variable number of rows. I am having difficulty getting the page breaks to occur at the correct locations with the correct formatting. For example, sometimes the last row is missing the bottom border.

Also, I am getting the following error: "Continuing contents of page NN, which would not fit on a single physical page."

I have spent a lot of time researching this error and have not been able to find a solution that applies to my situation. Therefore, I would like to see if there is a way to compute the number of lines in a table and then create page breaks after a certain number of lines. For example, below the number of lines is 9. Is there a way to compute this number?


Column 1  Column 2    Column 3
ABC          blah blah      test test
                 blah blah      test test
                 blah test
DEF          blah blah      test test
                 blah blah      test test
GHI           blah blah      test test
                 blah blah      test test
                 blah blah      test test
                 blah              test


Thanks,
KelseyB

 

 


Accepted Solutions
Solution
‎01-26-2016 11:17 AM
Super User
Posts: 11,343

Re: Determining number of lines in proc report output

You might want to investigate adding a variable to your data that is used to create a page break either in a BY statement or .

Since the number of lines displayed per page is going to be influenced by title, footnote, fontsizes and paper or logical page size, numbers of summaries and such there really isn't a generic solution to "number of lines" per page issues.

 

I have had the luxury with some of my projects of allways knowing the numbers of subgroups and sub-subgroups and so could relatively easily add a page variable in a data step such as:

 

data addpage;

   set data;

   if column1 in ('ABC' 'DEF') then PageVar=1;

   else if column1 in ('GHI') then PageVar=2;

run;

 

Assuming the generation of the report doesn't take too long then look at your result and add variable as makes sense.

View solution in original post


All Replies
Solution
‎01-26-2016 11:17 AM
Super User
Posts: 11,343

Re: Determining number of lines in proc report output

You might want to investigate adding a variable to your data that is used to create a page break either in a BY statement or .

Since the number of lines displayed per page is going to be influenced by title, footnote, fontsizes and paper or logical page size, numbers of summaries and such there really isn't a generic solution to "number of lines" per page issues.

 

I have had the luxury with some of my projects of allways knowing the numbers of subgroups and sub-subgroups and so could relatively easily add a page variable in a data step such as:

 

data addpage;

   set data;

   if column1 in ('ABC' 'DEF') then PageVar=1;

   else if column1 in ('GHI') then PageVar=2;

run;

 

Assuming the generation of the report doesn't take too long then look at your result and add variable as makes sense.

Contributor
Posts: 40

Re: Determining number of lines in proc report output

Thanks ballardw.  I will try this suggestion!

Super User
Super User
Posts: 7,942

Re: Determining number of lines in proc report output

So what do you want on each page.  Is it 20 observations, then:

data report_data;
  set report_data;
  pge=floor(_n_/20);
run;

proc report ...;
  ...
  
  break on pge / page;
...

If its on a group then break on group.  If its something else, please specify.  Also note, you can export the data from proc report with an out=, which will have the data as in the report, you could use that, but the question is why, just fix the breaking yourself in a datastep.

Contributor
Posts: 40

Re: Determining number of lines in proc report output

RW9,

Thank you for your feedback.  I need to break on the number of lines, not rows, in my dataset.  Otherwise, I would use your logic.  I think I will just count the number of characters and see if I can figure something out from there.

 

Thank you though.

Super User
Super User
Posts: 7,942

Re: Determining number of lines in proc report output

What I have seen before, and done myself also, is to have a split variable macro, this takes a string and splits into known fixed widths, sometimes with indentations:

VAR1

abcdefghijklm...aabb...

 

becomes

VAR1

abcd...

  aabb...

 

Then following on from that, you can use the _n_/number per page.  Basically do the calculation in pre-datastep then report.

Contributor
Posts: 40

Re: Determining number of lines in proc report output

Great!  I will try this out.  Thanks again.

Super User
Posts: 10,018

Re: Determining number of lines in proc report output

Maybe you could take a look this paper I wrote before.

http://support.sas.com/resources/papers/proceedings12/389-2012.pdf

Super Contributor
Posts: 435

Re: Determining number of lines in proc report output

Coild you please tell me what is 'page' in following line?

proc report ...;
  ...
  
  break on pge / page;
...
Super User
Super User
Posts: 7,942

Re: Determining number of lines in proc report output

PGE is a variable created in the datastep before to indicate where a page break should go.  The syntax is:

break on <variable> / <options>;

☑ This topic is solved.

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

Discussion stats
  • 9 replies
  • 625 views
  • 0 likes
  • 5 in conversation