A quick question: is there a way to force a page break in the middle of a table when using RWI? Sample code:
ods _all_ close;
ods pdf file="&outpath/rwitest.pdf";
options nodate nonumber;
title;
footnote;
proc sort data=sashelp.baseball out=baseball;
by team name;
run;
data _null_;
length dataval $ 200;
set baseball end=last;
by team;
if _n_ eq 1 then do;
declare odsout o();
o.table_start();
o.body_start();
end;
if first.team and _n_ ne 1 then
o.page();
dataval = catx(' - ',team,name);
o.row_start();
o.format_cell(data: dataval);
o.row_end();
if last then do;
o.body_end();
o.table_end();
o.delete();
end;
run;
ods pdf close;This has to run inside SAS Studio.
Hi:
My understanding is that you may not be able to force a page break with RWI under some conditions such as with ODS LAYOUT. However, unless your desired output is more complex, you could use PROC REPORT or a SAS Macro program to handle the page breaking, as an alternative.
But it looks like you want to end the table for each BY group, so I think you need to use your o.page() on the FIRST.TEAM and LAST.TEAM conditions. Here's what I was able to produce with this approach (using only 2 teams):
Although I think for a simple report such as you show, my tendency would be to use PROC REPORT. But I suspect your real report must be more complex.
Cynthia
Yes, my situation is more complicated; it's more akin to:
data _null_;
length dataval $ 200;
set baseball end=last;
by team position;
retain page 1;
if _n_ eq 1 then
declare odsout o();
if first.team then
o.table_start();
dataval = catx(' - ',position,team,name);
o.row_start();
o.format_cell(data: dataval);
o.row_end();
if last.position then do;
o.row_start();
o.format_cell(data:page,overrides:'just=r');
o.row_end();
o.page();
page + 1;
end;
if last.team then
o.table_end();
if last then
o.delete();
run;
ods pdf close;Suppressing the PDF bookmark that gets generated at the table_start() method is the issue. Fortunately, a PROC REPORT soluition already exists, but this was for an independent validation that explicitly did not use PROC REPORT. However, from a little further testing and your code, it looks like the PAGE() method doesn't work without closing the table.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.