BookmarkSubscribeRSS Feed
feierfly
Fluorite | Level 6

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;

 

 


Capture.PNG
2 REPLIES 2
ballardw
Super User

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?

ballardw
Super User

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 691 views
  • 1 like
  • 2 in conversation