Usage Note 24256: How do I get accurate pagebreaks in PDF when using FILE PRINT ODS and PUT _PAGE_?
Forcing pagebreaks with _PAGE_ when using FILE PRINT ODS may not break as desired. Using the undocumented escape sequence '^4P' and an ODS ESCAPECHAR may allow pagebreaks in PDF when you want them. With this technique, only the table up to the point of the escape sequence will be written to a page. (No empty cells are output until the page is filled and a new page is started.)
The escape sequence '^4P' is concatenated to the front of the first column, therefore the first column must be character. If you have numeric data in the
first column, convert it to character using the PUT function. Ensure your first
column is mapped as character if you are using a custom template. View
results by clicking on the word results.
/* Create sample data with multiple BY-Groups */
options center nodate ls=100 ps=30;
proc sort data=sashelp.class
out=sorted(rename=(sex=gender));
by sex;
run;
title "This produces the output we want
using FILE PRINT ODS in PDF";
ods pdf file="C:\fileprintods.pdf";
ods escapechar='^';
data _null_;
length name $20; /* need length statement */
set sorted;
by gender;
file print ods;
/* concatenate escape sequence onto */
/* first variable in first column */
if first.gender then name='^4P'||left(name);
put _ods_;
run;
ods pdf close;
Because this technique may not work in all cases, another alternative is to
create a unique macro variable for each value of the BY variable. Then, a macro can be created to loop through each value of the BY variable to create
a separate page of output. See the sample code in the Full Code tab above.
Operating System and Release Information
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This code provides an alternative to the ^4P technique.
proc sort data=sashelp.class out=class;
by sex;
run;
data class;
retain count 0;
set class;
by sex;
if first.sex then do;
count+1;
call symput('val'||left(count),trim(left(sex)));
end;
call symput('last',left(count));
run;
%put &last;
title "This produces the output we want
using FILE PRINT ODS in PDF";
%macro loop;
ods listing close;
ods pdf file="fileprintods.pdf";
ods escapechar='^';
%do i=1 %to &last;
data _null_;
set sashelp.class;
where sex="&&val&i";
file print ods;
put _ods_;
run;
%end;
ods pdf close;
ods listing;
%mend;
%loop
Type: | Usage Note |
Priority: | low |
Topic: | System Administration ==> Printing Third Party ==> Output ==> PDF SAS Reference ==> DATA Step SAS Reference ==> ODS (Output Delivery System)
|
Date Modified: | 2009-10-16 11:43:18 |
Date Created: | 2005-03-06 11:20:24 |