BookmarkSubscribeRSS Feed
SivaKV
Fluorite | Level 6

Hi,

 

I am using PROC REPORT procedure to print data on pdf (ODS PDF). The challenge i am having is, i am using break variable  and it has more records, so the data spanning into next page. But when data displaying in the next page ,break variable value is not displaying in second page. It only displaying at the start point only.

Here is the sample code.

options orientation=portrait center topmargin=.25in;
ods pdf file="mock up.pdf" notoc;


proc report data=sashelp.pricedata nowd;
column regionname productLine productname date price1 price2;
define regionname / group ;
define productLine / group ;
define productname/group;
define price1 / analysis ;
define price2 / analysis ;
define date/display;
break after productLine/ol;
run;

ods _all_ close;

 

If we run above code, the break variable is productLine and it has data about one and half page. So if we look at second page forst record the variables regionname, productline and productnames are empty. But i would like to display value of break variable when grouping/break variable has data of more than one page .

 

Regards

Siva

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @SivaKV,

 

Let me first say that I'm not very familiar with ODS PDF. Such paging issue seem to be well known and I'm not aware of a general solution. In simple cases such as your example where page breaks occur after a constant number of lines (36 on my computer), you could create an auxiliary variable whose value indicates the start of a new page and then copy the group (actually: order) variable values to those lines as shown below:

data pricedata;
set sashelp.pricedata;
top=(mod(_n_-1,36)=0);
run;

proc report data=pricedata;
column top regionname regname productline prodline productname prodname date price1 price2;
define top / display noprint;
define regionname / order noprint;
define productline / order noprint;
define productname / order noprint;
define regname / computed 'Sales Region';
define prodline / computed 'Name of product line';
define prodname / computed 'Product Name';
define date / display;
compute before regionname;
  rn=regionname;
endcomp;
compute before productline;
  pl=productline;
endcomp;
compute before productname;
  pn=productname;
endcomp;
compute regname / char length=7;
  if top then regname=rn;
endcomp;
compute prodline / char length=5;
  if top then prodline=pl;
endcomp;
compute prodname / char length=9;
  if top then prodname=pn;
endcomp;
run;

While the original variables regionname, productline and productname are still used as order variables, only their computed copies regname, prodline and prodname are actually printed. They receive their values from temporary variables rn, pl and pn, which are populated while the corresponding values are available.

 

I have omitted the BREAK statement because "/ol" doesn't have an effect in ODS destinations other than LISTING. A different case would be, e.g.

break after productline / page;

In this case a page break would occur when the value of productline changes so that the definition of variable top would need to be adapted:

data pricedata;
set sashelp.pricedata;
by regionname productline;
if first.productline then ctr=1;
else ctr+1;
top=(mod(ctr-1,36)=0);
run;

 

What I've seen in industrial settings is that people don't use ODS PDF, but other ODS destinations (e.g. LISTING or RTF) and eventually convert their reports to PDF documents by means of third-party software tools.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 584 views
  • 1 like
  • 2 in conversation