The SAS Output Delivery System and reporting techniques

How to set up page brake using ods pdf

Reply
Occasional Contributor
Posts: 10

How to set up page brake using ods pdf

Hi, I used the folowing code to generage pdf output containing both tables and graphs. The STARTPAGE= NEVER options works for tables as there are no page breaks between tables but the graph is overlaped on the table. Any ideas on solving this?

 

%Macro LOOP_OUTPUT;

 

%LET DSID=%SYSFUNC(OPEN(Eventdir.range,IN));

%LET NOBS=%SYSFUNC(ATTRN(&DSID,NOBS));

%IF &DSID > 0 %THEN %LET RC=%SYSFUNC(CLOSE(&DSID));

%IF NOBS>0 %THEN %DO;

proc sql; create table Eventdir.Group_list as select distinct Group from Eventdir.range; quit;

data Eventdir.Group_list; set Eventdir.Group_list; id=_n_;run;

%put _n_;

data _NULL_;

if 0 then set Eventdir.Group_list nobs=n;

call symputx('nrows',n);stop; run;

%DO I=1 %TO &nrows;

 

proc sql noprint; select distinct Group into :Group_macro from Eventdir.Group_list where id=&I.;quit;

%put &Group_macro;

%put "**********************************************************";

%put I_&I.;

%put "**********************************************************";

proc sql;

create table Eventdir.ORange_&I as

select * from Eventdir.range

where Group="&Group_macro" ;

quit;

 

proc sql;

create table Eventdir.OEstimate_&I as

select * from Eventdir.Estimate

where Group="&Group_macro" ;

quit;

 

goptions device=png;

ods pdf file="&Drive./Output" startpage=never;

proc report data=Eventdir.ORange_&I nowd; title "&Title Range";

compute result;

if strip(result)='Out of Rang -Red' then do;

call define(4, "style", "style=[backgroundcolor=red]");

call define(_row_, "style", "style=[backgroundcolor=red]");

end;

if strip(result)='Out of Rang -Yellow' then do;

call define(4, "style", "style=[backgroundcolor=yellow]");

call define(12, "style", "style=[backgroundcolor=yellow]");

end;

endcomp;

run;

proc print data=Eventdir.OEstimate_&I;title "&Title Estimate";

run;

/* %XLS_EXPORT ( Eventdir.Output, "&supdata.&Group_macro._NESTED_ACC_SUPP.xlsx", "&Group_macro.");*/

 

%_eg_conditional_dropds(WORK.SORTTempTableSorted);

/* -------------------------------------------------------------------

Sort data set EVENTDIR.RANGE

------------------------------------------------------------------- */

/* FOR MANUAL RUN %let I = 99; */

ods pdf startpage=now;

PROC SORT

DATA=EVENTDIR.ORange_&I(KEEP=period Distance AdjAvg Count Group LLyellow ULyellow LLred ULred)

OUT=WORK.SORTTempTableSorted

;

BY Group;

RUN;

PATTERN1 COLOR=CXd7d7d7;

PATTERN2 COLOR = _STYLE_;

PATTERN3 COLOR = _STYLE_;

PATTERN4 COLOR = _STYLE_;

PATTERN5 COLOR = _STYLE_;

PATTERN6 COLOR = _STYLE_;

PATTERN7 COLOR = _STYLE_;

PATTERN8 COLOR = _STYLE_;

PATTERN9 COLOR = _STYLE_;

PATTERN10 COLOR = _STYLE_;

PATTERN11 COLOR = _STYLE_;

PATTERN12 COLOR = _STYLE_;

SYMBOL1

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=SQUARE

CV=CXFF9900

LINE=2

WIDTH=2

CI=CXFF9900

;

SYMBOL2

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=CIRCLE

CV=CX001aaa

CO=WHITE

LINE=1

WIDTH=4

CI=CX001aaa

;

SYMBOL3

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=Triangle

CV= cxfff700

CO=WHITE

LINE=2

WIDTH=2

CI=cxfff700

;

SYMBOL4

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=Triangle

CV=cxfff700

CO=WHITE

LINE=2

WIDTH=2

CI=cxfff700

;

SYMBOL5

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=Triangle

CV= cxff0000

CO=WHITE

LINE=2

WIDTH=2

CI=cxff0000

;

SYMBOL6

INTERPOL=JOIN

 

HEIGHT=10pt

VALUE=Triangle

CV=cxff0000

CO=WHITE

LINE=2

WIDTH=2

CI=cxff0000

;

Legend2

FRAME

;

Legend1

FRAME

;

Axis1

STYLE=1

WIDTH=1

MINOR=NONE

 

;

Axis2

STYLE=1

WIDTH=1

 

;

Axis3

STYLE=1

WIDTH=1

MINOR=

(NUMBER=1

)

LABEL=("Count")

 

;

TITLE;

TITLE1 "Distance Bar and &Title Line Plot";

FOOTNOTE;

FOOTNOTE1 "Generated on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";

ODS PDF startpage=now;

PROC GBARLINE DATA=WORK.SORTTempTableSorted

;

BAR period

/

SUMVAR=Distance

CLIPREF

FRAME TYPE=SUM

COUTLINE=BLACK

RAXIS=AXIS1

MAXIS=AXIS2

LREF=1

CREF=CXDDDD00

/*REF=3.5 2.3 -2.3 -3.5*/

LEGEND=LEGEND2

;

PLOT / SUMVAR=AdjAvg

TYPE=SUM

CLIPREF

AXIS=AXIS3

LEGEND=LEGEND1

;

PLOT / SUMVAR=Count

TYPE=SUM

CLIPREF

AXIS=AXIS3

;

PLOT / SUMVAR=LLyellow

TYPE=SUM

CLIPREF

AXIS=AXIS3

LEGEND=LEGEND1

;

PLOT / SUMVAR=ULyellow

TYPE=SUM

CLIPREF

AXIS=AXIS3

LEGEND=LEGEND1

;

PLOT / SUMVAR=LLred

TYPE=SUM

CLIPREF

AXIS=AXIS3

LEGEND=LEGEND1

;

PLOT / SUMVAR=ULred

TYPE=SUM

CLIPREF

AXIS=AXIS3

LEGEND=LEGEND1

;

 

BY Group;

 

ods pdf close;

/* -------------------------------------------------------------------

End of task code

------------------------------------------------------------------- */

/*RUN; QUIT; */

/*%_eg_conditional_dropds(WORK.SORTTempTableSorted);*/

/*TITLE; FOOTNOTE;*/

/*PATTERN1;*/

/*GOPTIONS RESET = SYMBOL;*/

%END;

 

%end;

ods pdf close;

%mend LOOP_OUTPUT;

%LOOP_OUTPUT;

 

 

Attachment
Grand Advisor
Posts: 10,210

Re: How to set up page brake using ods pdf

How does this differ from: https://communities.sas.com/t5/Base-SAS-Programming/How-to-set-up-page-brake-using-ods-pdf/m-p/31936... ?

 

 

Have you tried doing this for one set of output with NO macros involved?

Grand Advisor
Posts: 10,210

Re: How to set up page brake using ods pdf

See if this code generates a document with two tables on one page and a graph on the second.

 

ods pdf file="c:\example.pdf"
style=meadow;
ods pdf startpage=no;
proc freq data=sashelp.class;
   tables age;
run;

proc means data=sashelp.class;
   var height weight;
run;

ods pdf startpage=now;
proc gplot data=sashelp.class;
   plot height*weight;
run;
quit;

ods pdf close;

If not, then there may be much sleuthing to find what you may be setting somewhere that interferes.

 

Ask a Question
Discussion stats
  • 2 replies
  • 140 views
  • 1 like
  • 2 in conversation