BookmarkSubscribeRSS Feed
PilOSU
Obsidian | Level 7

I have a large amount of proc SGPLOT statements that are all making graphs. I am trying to use ODS PDF to get them to appear one on 8x10 page, where there is 3 columns with 6 rows, and then another potential data set may require 4 columns with 6 rows. I have attached the code that i have been using but I am having a lot of trouble sizing the tables to all fit into one piece of paper. They are either too large and extend to more than one page, or are too small and unreadable.

 

What options do i need to play with to make them fit all on one page?

 

ODS PDF file="C:\Paper ready graphs\Paper_V1.pdf" startpage=never;
ODS layout start width=10in height=8in columns=3 rows=6  column_gutter=.5in row_gutter=.8in row_heights=(3.5in 3.5in);;


ODS region row=1 column=1; *width=1.2in height=1.6in;
Proc sgplot data=work.group_1_plot;
	Title "Group 1";
	series x= time y=baseline /markers markerattrs=(Symbol=square);
	series x=time y=pH /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="pH" grid;
	run;

	ODS region row=1 column=2; 
Proc sgplot data=work.group_2_plot;
	Title "Group 2";
	series x= time y=baseline /markers markerattrs=(Symbol=square);
	series x=time y=pH /markers markerattrs=(symbol=circle);
	refline 9 / axis=x Label="A line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="pH" grid;
	run;

	ODS region row=1 column=3;
Proc sgplot data=work.group_3_plot;
	Title "Group 3";
	series x= time y=baseline /markers markerattrs=(Symbol=square);
	series x=time y=pH /markers markerattrs=(symbol=circle);
	refline 24 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="pH" grid;
	run;

	*row 2;

ODS region row=2 column=1 ;
	Proc sgplot data=work.group_1_plot;
	Title "Group 1";
	series x= time y=baseline /markers markerattrs=(Symbol=square);
	series x=time y=PCO2 /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection Since Surgery (hours)"; 
	yaxis Label="PCO2" grid;
	run;
*
*
* (all the code for the proc sgplot looks repetitive until the end);

quit;
		ods layout end;
ods PDF close;
12 REPLIES 12
ballardw
Super User

You don't describe any problems you are having or show a document.

 

One thing that may be  needed is to set the system option PAPERSIZE prior to the ODS PDF to create logical page big enough to hold all of the output.

 

Frankly, when comes to "fit on a page" issues, code without data is not very testable.

PilOSU
Obsidian | Level 7

I can't post the PDF as its sensitive information, but Only one Large graph is being posted on each PDF page, versus all graphs (18 of them) being on one page just in much smaller versions... I'm not sure if i need to play around with the height/width of the graphs to make them all fit, but the problem seems like when they are too big they just get pushed to the next page versus being all on one. 

 

 

PaigeMiller
Diamond | Level 26

How about ODS LAYOUT GRIDDED with the option ADVANCE=PROC ??

 

However the idea of fitting 18 or 24 plots on one page seems to run into perceptual boundaries, if you make the plots too small, their usefulness diminshes, and the message gets lost. In fact, if I was the intended audience for a display of 18-24 plots on one page, I would not be happy. I would revise your goal to at most 10 plots on one page. I personally find a 2x2 grid or a 2x3 grid works well for me.

--
Paige Miller
ballardw
Super User

What are your ODS Graphics settings? That controls the size that the graphs want to use , which can conflict with the ODS Layout sizes.

 

Hint: If the actual values are "sensitive" make up dummy data with the same characteristics with "sensitive" values replaced with basically meaningless codes like Companyname = 'XXXXX' and 'YYYYY' or similar.

PilOSU
Obsidian | Level 7

Sorry for the delay. Here is the code i am using with datasets... so in this code im trying to fit 2 columns with 3 rows (6 tables total), but im trying to extrapolate this to the real dataset where there are 3 groups (instead of two) that have 12 variables (i.e. Baseline_A, A, Baseline_B, B,...Baseline_F, F) (18 tables total) 

I have also attached the PDF file that it creates. 

 

 

Data dummy_code_g1;
	input time Baseline_A A Baseline_B B Baseline_C C;
	datalines;
	0 1 2 2 7 80 40
	3 2 3 1 6 50 40
	6 2 4 1 5 50 40
	9 2 5 1 4 50 40
	12 2 6 1 3 50 40
	15 2 7 1 2 50 40
	18 2 8 1 3 50 40
	21 2 9 1 4 50 40
	24 2 8 1 5 50 40
	;run;

Data dummy_code_g2;
	input time Baseline_A A Baseline_B B Baseline_C C;
	datalines;
	0 2 8 6 1 87 42
	3 3 7 1 2 50 42
	6 3 6 1 3 50 42
	9 3 5 1 4 50 42
	12 3 4 1 5 50 42
	15 3 3 1 4 50 42
	18 3 2 1 4 50 42
	21 3 1 1 4 50 42
	24 3 4 1 4 50 42
	;run;


ODS graphics / reset=all;
ODS PDF file="Dummy_graph.pdf" startpage=no;
ODS layout start columns=3 rows=6;*  width=10in height=8in column_gutter=.5in row_gutter=.8in row_heights=(3.5in 3.5in);;
title;

ODS region row=1 column=1;
Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline A Values";
	series x= time y=baseline_A /markers markerattrs=(Symbol=square);
	series x=time y=A /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="A" grid;
	Label baseline_A = 'Baseline A' A = 'Group 1 Average';
	run;

Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline B Values";
	series x= time y=baseline_B /markers markerattrs=(Symbol=square);
	series x=time y=B /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="B" grid;
	Label baseline_B = 'Baseline B' B = 'Group 1 Average';
	run;

Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline C Values";
	series x= time y=baseline_C /markers markerattrs=(Symbol=square);
	series x=time y=C /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="C" grid;
	Label baseline_C = 'Baseline C' C = 'Group 1 Average';
	run;
	*group 2;

Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline A Values";
	series x= time y=baseline_A /markers markerattrs=(Symbol=square);
	series x=time y=A /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="A" grid;
	Label baseline_A = 'Baseline A' A = 'Group 2 Average';
	run;

Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline B Values";
	series x= time y=baseline_B /markers markerattrs=(Symbol=square);
	series x=time y=B /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="B" grid;
	Label baseline_B = 'Baseline B' B = 'Group 2 Average';
	run;

Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline C Values";
	series x= time y=baseline_C /markers markerattrs=(Symbol=square);
	series x=time y=C /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="C" grid;
	Label baseline_C = 'Baseline C' C = 'Group 2 Average';
	run;

	ods layout end;
ods PDF close;

 

Reeza
Super User

I would probably leverage the COLUMNS option in ODS PDF to enable this a bit more easily. Did a macro as it's easier to loop a bunch of graphs. You should adjust your graphics option to get rid of any extraneous space and trim the borders etc to get more fit in. 

 

Data dummy_code_g1;
	input time Baseline_A A Baseline_B B Baseline_C C;
	datalines;
	0 1 2 2 7 80 40
	3 2 3 1 6 50 40
	6 2 4 1 5 50 40
	9 2 5 1 4 50 40
	12 2 6 1 3 50 40
	15 2 7 1 2 50 40
	18 2 8 1 3 50 40
	21 2 9 1 4 50 40
	24 2 8 1 5 50 40
	;run;


%macro generate_graphs();
options orientation=portrait;

/* 8.5 X 11 page */
/* 0.5 inch margins */
/* 7.5 inch X 10 inch */



ODS PDF file="/home/fkhurshed/Demo1/Dummy_graph.pdf" startpage=no columns=3;


ODS graphics / height=2.5in width=2.5in;

%do i=1 %to 10;
Proc sgplot data=work.dummy_code_g1;
	Title "Group &i. average values vs Baseline A Values";
	series x= time y=baseline_A /markers markerattrs=(Symbol=square);
	series x=time y=A /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="A" grid;
	Label baseline_A = 'Baseline A' A = 'Group 1 Average';
	run;
%end;

ods pdf close;

%mend;

%generate_graphs();

	
	

 

 

PilOSU
Obsidian | Level 7

This macro did not provide the right output as all the graphs are graphing the same data, additionally there are only three groups, that i want to be displayed in each column downwards, and then each row is a different variable, to get a comparison of the data as you look across the groups.

 

And the variables are not in a particular order such as A..B..C in the real dataset so I dont think a macro would work easily here. 

Reeza
Super User

The code was provided as an example/illustration of the solution only.

 

You'll need to extend it to meet your requirements and I agree a macro is not the likely best approach but I didn't want to type out or copy/paste 10 SGPLOT set of code to demonstrate it. You can use this to get the layout and sizing right and then replace the code with your graphing code as needed.

PilOSU
Obsidian | Level 7

Thanks for the advice, I'm definitely getting closer to the final product, but I think i'm missing something within the ODS step b/c something is going wrong. It seems to only be making two rows now. I am hoping to have group1/2/3 A values in row 1, group 1/2/3 B values in row two, and group 1/2/3 values in row 3. 

Additionally no helpful information in the Log. 

 

 

Data dummy_code_g1;
	input time Baseline_A A Baseline_B B Baseline_C C;
	datalines;
	0 1 2 2 7 80 40
	3 2 3 1 6 50 40
	6 2 4 1 5 50 40
	9 2 5 1 4 50 40
	12 2 6 1 3 50 40
	15 2 7 1 2 50 40
	18 2 8 1 3 50 40
	21 2 9 1 4 50 40
	24 2 8 1 5 50 40
	;run;

Data dummy_code_g2;
	input time Baseline_A A Baseline_B B Baseline_C C;
	datalines;
	0 2 8 6 1 87 42
	3 3 7 1 2 50 42
	6 3 6 1 3 50 42
	9 3 5 1 4 50 42
	12 3 4 1 5 50 42
	15 3 3 1 4 50 42
	18 3 2 1 4 50 42
	21 3 1 1 4 50 42
	24 3 4 1 4 50 42
	;run;

ODS _all_ reset;
ODS PDF file="Dummy_graph.pdf" startpage=no columns=3;
ODS graphics / height=2in width=2in;


Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline A Values";
	series x= time y=baseline_A /markers markerattrs=(Symbol=square);
	series x=time y=A /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="A" grid;
	Label baseline_A = 'Baseline A' A = 'Group 1 Average';
	run;


Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline B Values";
	series x= time y=baseline_B /markers markerattrs=(Symbol=square);
	series x=time y=B /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="B" grid;
	Label baseline_B = 'Baseline B' B = 'Group 1 Average';
	run;


Proc sgplot data=work.dummy_code_g1;
	Title "Group 1 average values vs Baseline C Values";
	series x= time y=baseline_C /markers markerattrs=(Symbol=square);
	series x=time y=C /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="C" grid;
	Label baseline_C = 'Baseline C' C = 'Group 1 Average';
	run;
	*group 2;

Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline A Values";
	series x= time y=baseline_A /markers markerattrs=(Symbol=square);
	series x=time y=A /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="A" grid;
	Label baseline_A = 'Baseline A' A = 'Group 2 Average';
	run;

Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline B Values";
	series x= time y=baseline_B /markers markerattrs=(Symbol=square);
	series x=time y=B /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="B" grid;
	Label baseline_B = 'Baseline B' B = 'Group 2 Average';
	run;


Proc sgplot data=work.dummy_code_g2;
	Title "Group 2 average values vs Baseline C Values";
	series x= time y=baseline_C /markers markerattrs=(Symbol=square);
	series x=time y=C /markers markerattrs=(symbol=circle);
	refline 3 / axis=x Label="A Line";
	xaxis values=(0 3 6 9 12 15 18 21 24) grid
		Label= "Time of Collection"; 
	yaxis Label="C" grid;
	Label baseline_C = 'Baseline C' C = 'Group 2 Average';
	run;

ods PDF close;

 

 

Reeza
Super User

It goes down a column then across so you need to arrange your code to account for that order.....

PilOSU
Obsidian | Level 7
That worked! But the graphs for the original data that I have are not fitting on one page, is there a way to specify the size of each graph so it can fit all 18 graphs on each page? Maybe something with the width/height or the text font?
Reeza
Super User

The ODS GRAPHICS statement with height/width is what is controls the size.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 12 replies
  • 1755 views
  • 0 likes
  • 4 in conversation