Hi ,
I have an issue with increasing the graph size. I have used the following code to build the matrix plot. The margins has to be as shown in the graph which I could apply. however, when i give the titles and footnotes, the graphic area becomes small. Also I tried to adjust the width and height on ' ODS graphics on ', but seems like it is giving WARNING when it is beyond "width=800px height=600px". Can anyone help me with the graph size? Thanks !
The current output and the code below:
ods path reset;
ODS path show;
ODS path (PREPEND) work.TEMPLAT(update);
*** TITLES, FOOTNOTES AND PAGE NUMBERING ***;
goptions reset=all;
*** NON-STANDARD CODE ***;
%local MacroVersion;
%let MacroVersion = 1;
%include "&g_refdata/tr_putlocals.sas";
%tu_putglobals();
*** SPECIFY SYSTEM OPTIONS ***;
options orientation=landscape nonumber nodate;
*** SPECIFY GRAPHICS OPTIONS ***;
ods graphics / noborder;
*** DIRECT TEMPLATE STYLE TO WORK TEMPLATE STORE ***;
ods path(prepend) work.templat;
%tu_header();
%tu_footer(dsetout = footer);
data _null_;
set sashelp.vtitle end=last;
where type eq 'T';
call symput('TITLE'||strip(put(_n_,8.)),strip(text));
if last then call symput('NUMTITLE',strip(put(_n_,8.)));
run;
%do i=1 %to &numtitle;
title&i
%if &i le 2 %then J=LEFT font=Arial;
font=Arial "&&title&i"
%if &i eq 1 %then J=RIGHT font=Arial "Page 1 of 1" ;
%*if &i eq 2 and %nrbquote(&datadate) ne %then J=RIGHT "Data as of &datadate";
;
%end ;
data _null_;
set sashelp.vtitle end=last;
where type eq 'F';
call symput('FOOT'||strip(put(number,8.)),strip(text));
if last then call symput('NUMFOOT',strip(put(number,8.)));
run;
%put numfoot=&numfoot;
%put foot1=&foot1;
%if &numfoot eq 1 %then Footnote1 j=left font=Arial "&foot1" ;
%else %do i=1 %to &numfoot;
footnote&i font=Arial J=left "&&foot&i" h=8;
%end;
%local NumVar;
/*--Data set is required--*/
%if %length(&Data) eq 0 %then %do;
%put The parameter 'Data' is required - Macro Terminated.;
%goto finished;
%end;
/*--Var1, Var2 and Var3 are required--*/
%if %length(&var1) eq 0 or %length(&var2) eq 0 or %length(&var3) eq 0 %then %do;
%put The parameters 'Var1', 'Var2' and 'Var3' are required - Macro Terminated.;
%goto finished;
%end;
%let NumVar=2;
/*--Var4 is provided--*/
%if %length(&var4) ne 0 %then %do;
%let NumVar=3;
%end;
/*--Var5 is provided--*/
%if %length(&var4) ne 0 and %length(&var5) ne 0 %then %do;
%let NumVar=4;
%end;
%let refl1a=1.25;
%let refl2a=2.5;
%let refl3a=5;
%let refl4a=10;
%let refl1b=1.1;
%let refl2b=1.6;
%let refl3b=2.6;
%let refl4b=5;
;
options orientation=landscape nodate nonumber leftmargin=1.25in rightmargin=1.25in topmargin=1in bottommargin=1in ;
ods pdf file="&g_outfile..PDF" nogtitle /*nogfootnote*/ bookmarkgen=no ;
ods graphics on ; */ width=800px height=600px border=off ;
proc template;
define statgraph CompactMatrix_4_Out;
dynamic _ShowUpper;
begingraph ;
layout lattice / columns=&NumVar rows=&NumVar rowgutter=5 columngutter=5
rowdatarange=union columndatarange=union;
/*--Set common row options--*/
rowaxes;
rowaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
rowaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
%if &NumVar gt 2 %then %do;;
rowaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize)
logopts=(tickvaluepriority=true tickvaluelist=(.1 1 10 50));
%end;
%if &NumVar gt 3 %then %do;
rowaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
%end;
endrowaxes;
/*--Set common column options--*/
columnaxes;
columnaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
columnaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
%if &NumVar gt 2 %then %do;
columnaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
%end;
%if &NumVar gt 3 %then %do;
columnaxis / type=log tickvalueattrs=(size=&TickValueFontSize) labelattrs=(size=&AxisLabelFontSize);
%end;
endcolumnaxes;
/*--Draw individual scatter plots in first row if needed--*/
layout overlay;
scatterplot y=&var2 x=&var1 / group=&group name="trt" markerattrs=(symbol=circlefilled size=10px color=blue);
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* Bili. */
referenceline x=&refl1b / lineattrs=(color=lightgray);
referenceline x=&refl2b / lineattrs=(color=lightgray);
referenceline x=&refl3b / lineattrs=(color=lightgray);
referenceline x=&refl4b / lineattrs=(color=lightgray);
endlayout;
layout overlay; entry ''; endlayout;
%if &NumVar gt 2 %then %do;
layout overlay; *entry '';
discretelegend "trt" / border=FALSE;
endlayout;
%end;
%if &NumVar gt 3 %then %do;
layout overlay; entry ''; endlayout;
%end;
/*--Draw individual scatter plots in second row if needed--*/
layout overlay;
scatterplot y=&var3 x=&var1 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
*referenceline y=1; *referenceline y=&CCL3;
*referenceline x=1; *referenceline x=&CCL1;
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* Bili. */
referenceline x=&refl1b / lineattrs=(color=lightgray);
referenceline x=&refl2b / lineattrs=(color=lightgray);
referenceline x=&refl3b / lineattrs=(color=lightgray);
referenceline x=&refl4b / lineattrs=(color=lightgray);
endlayout;
layout overlay;
scatterplot y=&var3 x=&var2 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* AST, ALT, Alk.Phos */
referenceline x=&refl1a / lineattrs=(color=lightgray);
referenceline x=&refl2a / lineattrs=(color=lightgray);
referenceline x=&refl3a / lineattrs=(color=lightgray);
referenceline x=&refl4a / lineattrs=(color=lightgray);
endlayout;
%if &NumVar gt 2 %then %do;
layout overlay; entry ''; endlayout;
%end;
%if &NumVar gt 3 %then %do;
layout overlay; entry ''; endlayout;
%end;
/*--Draw individual scatter plots in third row if needed--*/
%if &NumVar gt 2 %then %do;
layout overlay;
scatterplot y=&var4 x=&var1 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* Bili. */
referenceline x=&refl1b / lineattrs=(color=lightgray);
referenceline x=&refl2b / lineattrs=(color=lightgray);
referenceline x=&refl3b / lineattrs=(color=lightgray);
referenceline x=&refl4b / lineattrs=(color=lightgray);
endlayout;
layout overlay;
scatterplot y=&var4 x=&var2 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* AST, ALT, Alk.Phos */
referenceline x=&refl1a / lineattrs=(color=lightgray);
referenceline x=&refl2a / lineattrs=(color=lightgray);
referenceline x=&refl3a / lineattrs=(color=lightgray);
referenceline x=&refl4a / lineattrs=(color=lightgray);
endlayout;
layout overlay;
scatterplot y=&var4 x=&var3 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
/* AST, ALT, Alk.Phos */
referenceline y=&refl1a / lineattrs=(color=lightgray);
referenceline y=&refl2a / lineattrs=(color=lightgray);
referenceline y=&refl3a / lineattrs=(color=lightgray);
referenceline y=&refl4a / lineattrs=(color=lightgray);
/* AST, ALT, Alk.Phos */
referenceline x=&refl1a / lineattrs=(color=lightgray);
referenceline x=&refl2a / lineattrs=(color=lightgray);
referenceline x=&refl3a / lineattrs=(color=lightgray);
referenceline x=&refl4a / lineattrs=(color=lightgray);
endlayout;
%if &NumVar gt 3 %then %do;
layout overlay; entry ''; endlayout;
%end;
%end;
/*--Draw individual scatter plots in fourth row if needed--*/
%if &NumVar gt 3 %then %do;
layout overlay;
scatterplot y=&var5 x=&var1 / group=&group markerattrs=(symbol=circlefilled size=10px color=blue);
endlayout;
layout overlay;
scatterplot y=&var5 x=&var2 / group=&group;
endlayout;
layout overlay;
scatterplot y=&var5 x=&var3 / group=&group;
endlayout;
layout overlay;
scatterplot y=&var5 x=&var4 / group=&group;
endlayout;
%end;
endlayout;
endgraph;
end;
run;
/*--Render the graph--*/
proc sgrender data=&data template=CompactMatrix_4_Out ;
run;
ods pdf close;
Let's try a couple of experiments...
First, drop the footnote and see if you can make the graph bigger by using the WIDTH and HIEGHT options on the ODS Graphics statement.
If that works, try passing the footnote into PROC SGRENDER as DYNAMIC and render it in your template as an ENTRYFOOTNOTE.
Let me know your findings.
Thanks!
Dan
If you get log message about output size and Java VM Memory, you can try running SAS with increased Java memory.
https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lesysoptsref/n0yykr3ywhym1cn12vkjnvurxzcq.htm
-jreoptions \(-Xmx512m -Xms256m\)
Given the aspect ratio of your graph, it might work better in portrait instead of landscape. Can you try that?
Hi,
I have used entry title and the below is the maximum i could do. The footnotes now cannot be started from the beginning of ods, it now starts from the beginning of the plot. not sure if footnote like is accepted by our stats. One point i noticed is the individual panels are not square. I tried to is and math the width and height of the ods file, but failed to do . my present output and the code below:
options orientation=landscape nodate nonumber leftmargin=.71in rightmargin=.71in topmargin=1in bottommargin=.01in ;
ods pdf file="&g_outfile..PDF" nogtitle /*nogfootnote*/ bookmarkgen=no ;
ods graphics on /width=900px height=700px border=off ;
.
.
.
.
.
.
entryfootnote textattrs=(size=.0001pt color=white) "." ;
entryfootnote textattrs=(size=.0001pt color=white) "." ;
entryfootnote textattrs=(size=.0001pt color=white) "." ;
entryfootnote textattrs=(size=.0001pt color=white) "." ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot1" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot2" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot3" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot4" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot5" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot6" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot7" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot8" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_foot9" ;
entryfootnote halign=left textattrs=(size=10pt ) "&g_userid: &g_pgmpth &sysdate9 &systime" ;
.
.
.
Now that the footnotes are part of the graph, space is taken from the bottom, causing the cells to not be square. Is orientation=landscape a requirement?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.