BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DME790
Pyrite | Level 9

Hi all,

 

I'm trying to use ODS PDF and ODS Layout Gridded to place graphs side by side on A3.

 

I have the following code but the graphs are very small and they don't sit side by side.

 

I have tried different code and this gets me close.

 

Any help appreciated.

 

data test;
input event_dt :yymmdd. group $ Simplification $ ENTERED ANSWERED ABANDONED Agent;
format event_dt yymmdd10.;

DATALINES;
2018-07-09 AAA PreSimp 127 118 8 25
2018-07-10 AAA PreSimp 106 99 6 29
2018-07-11 AAA PreSimp 108 97 11 24
2018-07-12 AAA PreSimp 131 113 18 30
2018-07-13 AAA PreSimp 120 106 13 26
2018-07-16 AAA PreSimp 105 96 8 29
2018-07-17 AAA PreSimp 86 69 15 24
2018-07-18 AAA PreSimp 105 89 16 30
2018-07-19 AAA PreSimp 110 97 12 22
2018-07-20 AAA PreSimp 72 65 7 26
2018-07-23 AAA PreSimp 96 89 7 25
2018-07-24 AAA PreSimp 101 92 7 28
2018-07-25 AAA PreSimp 103 92 11 27
2018-07-26 AAA PreSimp 92 84 7 30
2018-07-27 AAA PreSimp 92 86 5 21
2018-07-30 AAA PostSimp 85 77 8 20
2018-07-30 AAA PostSimp 85 77 8 29
;
RUN;



data attrmap;
retain id "myid";
input value :&$10. fillcolor $8.;
datalines;
Pre Simp   VIBG
Post Simp  BIBG
;
run;


ods PDF file="/sasdata/clk/dev/SERVPERFCO/SDPAGENUSER/BIS/Data/SASLib/0.Blended/CAR/misc/AAA_results.PDF";
options  leftmargin=.5in rightmargin=.5in orientation=landscape nocenter;
ods listing close;

ods layout gridded
	columns=2 width=2in;


Proc SGPLOT data=test noborder dattrmap=attrmap;
	Title "Entered";
	VBAR EVENT_DT / Response=ENTERED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
	yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Entered';
RUN;

ods layout gridded
	columns=2 width=2in;

Proc SGPLOT data=test noborder dattrmap=attrmap;
	Title "Answered";
	VBAR EVENT_DT / Response=ANSWERED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
	yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Answered';
RUN;

ods layout gridded
	columns=2 ;

Proc SGPLOT data=test noborder dattrmap=attrmap;
	Title "Abandoned";
	VBAR EVENT_DT / Response=ABANDONED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
	yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Abandoned';
RUN;

ods layout gridded
	columns=2 ;
Proc SGPLOT data=test noborder dattrmap=attrmap;
	Title "Agent";
	VBAR EVENT_DT / Response=Agent  Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
	yaxis display=(noline noticks) grid values=(0 to 50 by 5) offsetmin=0 label='Agent';
RUN;


title;
ods layout end;
ODS PDF close;

Cheers

 

Dean

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

This works for me:

goptions dev=actximg;
              
options papersize=A3 orientation=landscape leftmargin=1cm rightmargin=1cm; 

ods _ALL_ close;
ods PDF file="%sysfunc(pathname(WORK))\results.PDF";
ods layout gridded columns=3 order_type=row_major column_gutter=1cm advance=output;
                                                                          
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;   
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;  
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;  
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;

ods layout end;
ods PDF close;

Capture.GIF

 

I wonder why there is this message though:

WARNING: WIDTH exceeds available space for PDF destination. Setting WIDTH=4.726667in.

 

 

View solution in original post

11 REPLIES 11
DME790
Pyrite | Level 9

Update,

 

I have changed the code to the following. 

 

In Results - SAS Report view the graphs appear side by side.

 

When you pen the PDF file the graphs are below each other.

 

Any suggestions appreciated.

 

ods PDF file="Test.PDF" notoc style=color;
ods layout start columns=2;
	Options papersize= ("11.69in", "16.54in") orientation=landscape;
	ods region width=6in;
		ods graphics / width=6in height=3in;

		Proc SGPLOT data=test noborder dattrmap=attrmap;
			Title "Entered";
			VBAR EVENT_DT / Response=ENTERED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
			yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Entered';
		RUN;

		Proc SGPLOT data=test noborder dattrmap=attrmap;
			Title "Answered";
			VBAR EVENT_DT / Response=ANSWERED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
			yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Answered';
		RUN;

	ods region width=6in;

		Proc SGPLOT data=test noborder dattrmap=attrmap;
			Title "Abandoned";
			VBAR EVENT_DT / Response=ABANDONED Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
			yaxis display=(noline noticks) grid values=(0 to 150 by 10) offsetmin=0 label='Abandoned';
		RUN;

		Proc SGPLOT data=test noborder dattrmap=attrmap;
			Title "Agent";
			VBAR EVENT_DT / Response=Agent  Group=Simplification attrid=myid nooutline seglabel seglabelattrs=(weight=Bold color=WHITE size=8 );
			yaxis display=(noline noticks) grid values=(0 to 50 by 5) offsetmin=0 label='Agent';
		RUN;

		title;
ods layout end;
ods pdf close;

Cheers

 

Dean

 

 

 

ChrisNZ
Tourmaline | Level 20

This doesn't make sense:

opions papersize= ("11.69in", "16.54in") orientation=landscape; 
ods region width=6in;

width=5in works.

DME790
Pyrite | Level 9

Hi  @ChrisNZ,

 

Thanks for the response.

 

The below code I'm trying to assign the output to A3 size as the final output I need has 3 x 3 .  Should I be using a different code to output to A3?

 

opions papersize= ("11.69in", "16.54in") orientation=landscape; ods region width=6in;

Cheers

 

Dean

ChrisNZ
Tourmaline | Level 20

This works for me:

goptions dev=actximg;
              
options papersize=A3 orientation=landscape leftmargin=1cm rightmargin=1cm; 

ods _ALL_ close;
ods PDF file="%sysfunc(pathname(WORK))\results.PDF";
ods layout gridded columns=3 order_type=row_major column_gutter=1cm advance=output;
                                                                          
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;   
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;  
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;  
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;
ods region width=12cm; proc sgplot data=SASHELP.CLASS; vbar AGE / response=WEIGHT ; run;

ods layout end;
ods PDF close;

Capture.GIF

 

I wonder why there is this message though:

WARNING: WIDTH exceeds available space for PDF destination. Setting WIDTH=4.726667in.

 

 

DME790
Pyrite | Level 9

Hi @ChrisNZ,

 

Thanks for your help on this one - I ran the code you tried and I don't get an error but the output ends up being on two pages  - I have attached the PDF file.

 

Could it be the 'printer' and/or settings that could play around with the settings?  

ChrisNZ
Tourmaline | Level 20

Your graphs look too tall to fit. Set the height of your graphs.

DME790
Pyrite | Level 9

Hi @ChrisNZ

 

I set the height and now it all fits onto a page.

 

Can I ask what is the purpose of the ODS_ALL_ close; statement and why does it sit after the goptions and options.

 

I thought this would cancel out anything above it?

 

 

goptions dev=actximg;
options papersize=A3 orientation=landscape leftmargin=1cm rightmargin=1cm;
ods _ALL_ close;
ods PDF file="%sysfunc(pathname(WORK))\results.PDF";
ods layout gridded columns=3 order_type=row_major column_gutter=1cm advance=output;
ods region width=12cm height=8.cm ;

Cheers

 

Dean

 

ChrisNZ
Tourmaline | Level 20

Glad to hear!

 

ODS _ALL_ close; closes all  ODS destinations. It does not reset goptions.

 

You can use goptions reset=all for that, although most goptions do not affect  proc SG* outputs.

DME790
Pyrite | Level 9

@ChrisNZ 

 

Thanks for your help Chris - I moved the code over to my program and now it doesn't return anything - blank PDF paper.

 

Going to rewrite my whole code as the code that you helped with works.

 

If you are a Rugby supporter good luck in the Bledisloe Cup this year. 

 

Cheers

 

Dean

DME790
Pyrite | Level 9

@ChrisNZ

 

Hey Chris  - thanks for all your help it is much appreciated.

 

I now have it all working.

 

Cheers

 

Dean

ChrisNZ
Tourmaline | Level 20

Glad it works, and good on you! 🙂

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 6128 views
  • 3 likes
  • 2 in conversation