The SAS Output Delivery System and reporting techniques

proc report page break

Reply
Frequent Contributor
Posts: 115

proc report page break

using below code to generate a proc report.

data test1;
input first $ last $ num1;

datalines4;
first1 last1  1
first1 last2  2
first1 last3  3
first2 last4  4
first2 last5  5
first2 last6  6
first2 last7  7
first2 last8  8
first2 last9  9
;;;;

proc report data=test1;
column first last num1;
define first/group;
define last/display;
define num1/analysis;
run;

I want to uese page break after every 4 records for one of my requirement. but i need to pass the column headinds in next page break with previous group by variable as below


first last num1
first1 last1 1
        last2 2
        last3 3
first2 last4 4

first last num1
first2 last5 5
        last6 6
        last7 7
        last8 8

SAS Super FREQ
Posts: 8,868

Re: proc report page break

Posted in reply to sunilreddy

Hi:

  PROC REPORT will not automatically break after every 4 report rows, unless you make a "fake" page break variable. Then, once you have your "fake" page break variable, you can either use a BREAK statement inside PROC REPORT or a BY statement. I don't know what you mean when you say that you need to "pass the column headings in next page break with previous group" -- because when page breaks come from either the BREAK statement or BY group processing, the column headings do get automatically generated for each page.

  Consider the following program using your data and a fake page break variable.

cynthia

data test1;

infile datalines;

input first $ last $ num1;

return;

datalines;

first1 last1  1

first1 last2  2

first1 last3  3

first2 last4  4

first2 last5  5

first2 last6  6

first2 last7  7

first2 last8  8

first2 last9  9

;

run;

   

proc sort data=test1;

by first last num;

run;

  

data final;

  set test1;

  order = _n_;

  pgbrk=ceil(divide(order,4));

run;

  

ods listing close;

ods pdf file='c:\temp\use_pgbrk1.pdf' notoc;

proc report data=final nowd ;

  title '1) Use PGBRK in BREAK AFTER';

  column pgbrk first last num1;

  define pgbrk / group noprint;

  define first/group;

  define last/display;

  define num1/analysis;

  break after pgbrk / page;

  compute before _page_;

    disp_line = 'Calc PageBrk Is: '||trim(put(pgbrk,2.0));

    line disp_line $20.;

  endcomp;

run;

ods pdf close;

   

proc sort  data=final;

by pgbrk;

run;

options nobyline;

ods pdf file='c:\temp\use_pgbrk2.pdf' notoc;

proc report data=final nowd ;

  by pgbrk;

  title '2) Use PGBRK in BY PGBRK=#byval1';

  column first last num1;

  define first/group;

  define last/display;

  define num1/analysis;

run;

ods pdf close;

title;

options byline;

   

ods pdf file='c:\temp\use_pgbrk3.pdf' notoc startpage=no; 

proc report data=final nowd ;

  by pgbrk;

  title '3) Use PGBRK with STARTPAGE=NO and automatic BYLINE';

  column first last num1;

  define first/group;

  define last/display;

  define num1/analysis;

run;

ods pdf close;

title;

;

Ask a Question
Discussion stats
  • 1 reply
  • 3479 views
  • 0 likes
  • 2 in conversation