Desktop productivity for business analysts and programmers

Printing four graphs on to one page.

Posts: 41

Printing four graphs on to one page.



I've written a macro which creats graphs of distributions of variables. However, what happens is that each graph gets printed to one page. What I would like to do is merge the four grpahs on to one page so I can stick it into a word document.


Any help at amending my code would be most welcome.


%macro dists;

%do year = 2011 %to 2015;

********Employee Pay at the individual level vs survey equiv*****************;
data temp&year.;
set combined_sample_&year._7(keep = year pay spay);
array temp{*} pay spay;
do i = 1 to dim(temp);
	temp(i) = round(temp(i),500);

proc summary data = temp&year. nway;
class year spay;
var spay;
output n= out = comb1a&year.;
proc summary data = temp&year. nway;
class year spay;
var pay;
output n= out = comb1b&year.;
data comb2&year.;
merge comb1a&year.
		comb1b&year.(rename = (pay = spay_freq_ = regfreq));
by year spay;

data comb2&year.;
set comb2&year.;
if spay= 0 then delete;run;

proc sgpanel data = comb2&year.;
panelby year;
vbar spay/ response = regfreq stat = percent legendlabel = "Register sample";
vbar spay/ response = _freq_ stat = percent legendlabel = "Survey sample" barwidth=0.5 transparency=0.6;
colaxis fitpolicy = rotatethin;
title "Distributions of Employee Income by Individual - Admin vs Survey, matched sample &year.";
proc corr data= temp&year.; var pay spay;run;

Trusted Advisor
Posts: 1,621

Re: Printing four graphs on to one page.

Look at the ODS LAYOUT GRIDDED command.

Super User
Super User
Posts: 7,407

Re: Printing four graphs on to one page.

You could also write the template yourself, you can get started on the template by simply adding:

proc sgpanel data = comb2&year. tmplout="c:\temp.txt";

Once run, this writes the Graph Template Language code to the file temp.txt.  You can use this as the basis of creating a gridded graph with various overlays and such like - in fact all the latest graphing procedures use this GTL behind the scenes.  You can learn further at:


Which has examples of pretty much any graphic you can think of.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation