Hi,
I am using ODS layout to put 3 graphs (on a single page) in PDF format in a way that I want my Graph 1 (main graph) to be on the top of the page and then Graph 2 and Graph 3 Side by side just below Graph 1, something like this:
GRAPH_1
GRAPH_2 GRAPH_3
following code is putting all of the graphs on top of each other, something like this
GRAPH_1
GRAPH_2
GRAPH_3
Please advice how to fix it, here is the code:
goptions reset=all htext=1.0 htitle=1;
OPTIONS NODATE NOCENTER number orientation=portrait leftmargin=0.1 rightmargin=0.1 FONT=ARIAL;
ODS PDF FILE="\\Server_name\using Grid.pdf";
ODS layout start colums=2;
ODS region height=4in column_span=2;
/*graph 1*/
SYMBOL1 INTERPOL=JOIN HEIGHT=3pt VALUE=DOT CV=CX370000 CO=MAROON LINE=1 WIDTH=2 CI=CXA60000;
PATTERN1 COLOR=CXBCBC78;
Legend1 FRAME LABEL=(FONT='Arial/Bold' justify=center 'Volumes');
Legend2 FRAME LABEL=(FONT='Arial/Bold' justify=center 'Hrs');
Axis1 STYLE=3 WIDTH=1 MINOR=NONE LABEL=('Volumes');
Axis2 STYLE=1 WIDTH=1 MINOR=NONE LABEL=(FONT='Arial/Bold' justify=center 'Scheduled Days');
Axis3 STYLE=1 WIDTH=1 MINOR=NONE LABEL=(f='Arial/Bold' 'Hrs') ;
TITLE;
TITLE1 "Title 1";
PROC GBARLINE DATA=WORK.Table_1;
BAR DAY_DATE / discrete SUMVAR=VOLUME
TYPE=SUM CLIPREF FRAME SUM COUTLINE=BLACK RAXIS=AXIS1 MAXIS=AXIS2 HREF=0 CREF=BLACK LEGEND=Legend1;
PLOT / SUMVAR=HLD_TIME TYPE=SUM AXIS=AXIS3 LEGEND=Legend2;
format volume comma10.0;
format HLD_TIME comma10.0;
RUN;
ODS region height=1in width=1in column_span=1;
/*graph 2*/
title1 'Title';
SYMBOL1 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL2 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL3 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL4 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL5 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL6 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
SYMBOL7 INTERPOL=JOIN HEIGHT=10pt VALUE=NONE LINE=1 WIDTH=2 CV = _STYLE_;
Legend1 FRAME;
Axis1 STYLE=1 WIDTH=1 MINOR=NONE label=('Volumes');
Axis2 STYLE=1 WIDTH=1 MINOR=NONE label=(f='Arial/Bold' justify=center 'Scheduled Days');
PROC GPLOT DATA = WORK.Table_2
;
PLOT VOLUME * DAY_DATE =COMMODITY_CATEGORY / VAXIS=AXIS1 HAXIS=AXIS2 FRAME LEGEND=LEGEND1;
RUN;
ODS region height=1in width=1in column_span=1;
/*graph 3*/
title1 'Title';
Axis1 STYLE=1 WIDTH=1 MINOR=NONE label=('Hrs');
Axis2 STYLE=1 WIDTH=1 MINOR=NONE label=(f='Arial/Bold' justify=center 'Scheduled Days');
PROC GPLOT DATA = WORK.Table_3;
PLOT HOLD_TIME * DAY_DATE =COMMODITY_CATEGORY / VAXIS=AXIS1 HAXIS=AXIS2 FRAME LEGEND=LEGEND1;
RUN;
format HOLD_TIME comma10.1;
ODS LAyout end;
ODS PDF close;
Hi,
one way that would work nicely would be to use PROC GREPLAY.
First, for each of your graphs (graph 1, graph2, graph3) you will need to assign a name to them. You can do that by simply adding the
name = "graph1" option for each of your graphs.(please make sure to name them differently, such as graph1, graph2 and graph3).
You also need to modify the size of your window by using
goptions hsize = 6in vsize = 6in (for each of your three graphs)
Once that is accomplished, you can then use the GREPLAY procedure (please note the change in window size, again)
goptions reset = all;
options orientation = landscape;
ods pdf file = "&your_path.\test.pdf";
goptions device = pdf rotate = landscape gsfmode = replace
hsize = 12in vsize = 12in;
proc greplay igout = work.gseg
tc = sashelp.templt template = u1d2s
nofs nobyline ;
treplay 1:graph1 2:graph2 3:graph3;
run;quit;
ods pdf close;
I hope this helps.
Best of luck!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.