Since you output to a PDF, you can set some options like papersize and margins. You could use a A3 papersize, so there is more space for the graph, but still print it as A4. I would set the height and width using mm, as you can measure on the paper with a ruler. ODS LAYOUT has support for COLUMN_GUTTER=dimension and ROW_GUTTER=dimension
Here is a sample to test things out. I used macros for some of the options to make it easier to change
ods _all_ close;
options
papersize="A3"
topmargin=1cm
bottommargin=1cm
leftmargin=1cm
rightmargin=1cm
orientation=landscape
nodate nonumber;
;
ods graphics / reset=all width=90mm height=135mm outputfmt=png;
ods pdf file="%sysfunc(pathname(work))/layout_gridded.pdf";
ods layout gridded columns=4 column_gutter=0;
%macro dataLabel;
datalabel=model
labelfar
%mend;
%macro displayStats;
displaystats=(n mean median max datamax min datamin iqr range std q1 q3)
%mend;
%macro datalabelAttrs;
datalabelattrs=(size=6pt color=blue Style=Normal Weight=Normal) boxwidth=1
%mend;
ods region;
proc sgplot data=sashelp.cars;
vbox invoice /
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox horsepower/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_city/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_highway/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods layout end;
ods pdf close;
The PDF produced is attached.
You could combine these 6 box into one picture :
How about using ODS LAYOUT, see sample below.
ods _all_ close;
ods graphics / width=80mm height=80mm outputfmt=static;
ods pdf file="c:\temp\layout_gridded.pdf";
ods layout gridded columns=2;
ods region;
proc sgplot data=sashelp.cars;
vbox invoice;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox horsepower;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_city;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_highway;
run;
ods layout end;
ods pdf close;
I use startpage=no but I still have the multiple pages :
options device=SASPRTC nodate nonumber orientation=portrait ;
ods pdf style=Sapphire startpage=no;
proc sgplot data=bdd;
vbox NBMEN20/datalabel=LIBGEO displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
yaxis label="Nombre de ménages";
run;
proc sgplot data=bdd_
vbox NBPERSC2/datalabel=LIBGEO displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
yaxis label="Nombre de personnes";
run;
proc sgplot data=bdd;
vbox MED0 /datalabel=LIBGEO displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
yaxis label="Médiane";
run;
footnote j=left "Source de données : xxx " ;
footnote;
ods pdf close;
I would use PROC SGPANEL with a panelby statement and a vbox statement.
https://support.sas.com/kb/69/825.html
Ciao,
Koen
I used BrunoMueller 's code and got this :
ods graphics / width=150px height=150px outputfmt=static; ods pdf file="c:\temp\layout_gridded.pdf"; ods layout gridded columns=4 ; ods region; proc sgplot data=sashelp.cars; vbox invoice; run; ods region; proc sgplot data=sashelp.cars; vbox horsepower; run; ods region; proc sgplot data=sashelp.cars; vbox mpg_city; run; ods region; proc sgplot data=sashelp.cars; vbox mpg_highway; run; ods layout end; ods pdf close;
Thank you, unfortunately this code does not work when I add the statistics :
ods graphics / width=150px height=150px outputfmt=static;
ods pdf file="xxx\layout_gridded.pdf";
options device=SASPRTC nodate nonumber ;
ods layout gridded columns=4 ;
ods region;
proc sgplot data=sashelp.cars;
vbox invoice/datalabel=model displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox horsepower/datalabel=model displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_city/datalabel=model displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_highway/datalabel=model displaystats=(n mean median max datamax min datamin iqr range std q1 q3) datalabelattrs=(size=10pt Family="Arial" color=blue Style=Normal Weight=Normal) boxwidth=1;
run;
ods layout end;
ods pdf close;
Since you output to a PDF, you can set some options like papersize and margins. You could use a A3 papersize, so there is more space for the graph, but still print it as A4. I would set the height and width using mm, as you can measure on the paper with a ruler. ODS LAYOUT has support for COLUMN_GUTTER=dimension and ROW_GUTTER=dimension
Here is a sample to test things out. I used macros for some of the options to make it easier to change
ods _all_ close;
options
papersize="A3"
topmargin=1cm
bottommargin=1cm
leftmargin=1cm
rightmargin=1cm
orientation=landscape
nodate nonumber;
;
ods graphics / reset=all width=90mm height=135mm outputfmt=png;
ods pdf file="%sysfunc(pathname(work))/layout_gridded.pdf";
ods layout gridded columns=4 column_gutter=0;
%macro dataLabel;
datalabel=model
labelfar
%mend;
%macro displayStats;
displaystats=(n mean median max datamax min datamin iqr range std q1 q3)
%mend;
%macro datalabelAttrs;
datalabelattrs=(size=6pt color=blue Style=Normal Weight=Normal) boxwidth=1
%mend;
ods region;
proc sgplot data=sashelp.cars;
vbox invoice /
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox horsepower/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_city/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods region;
proc sgplot data=sashelp.cars;
vbox mpg_highway/
%dataLabel
%displayStats
%dataLabelAttrs
;
run;
ods layout end;
ods pdf close;
The PDF produced is attached.
You could use NOGFOOTNOTE to get this.
ods pdf file="c:\temp\layout_gridded.pdf" nogfootnote;
Dive into keynotes, announcements and breakthroughs on demand.
Explore 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.