The SAS Output Delivery System and reporting techniques

Multiple Graphs on a single page

Reply
N/A
Posts: 0

Multiple Graphs on a single page

I'm using gplot and ODS to create some pdf reports.

Is there a way to force multiple graphs on a single page when you're using a by variable in your proc gplot?
SAS Employee
Posts: 88

Re: Multiple Graphs on a single page

Take a look at the below TS Doc which has a wealth of information which should address this question.

http://support.sas.com/techsup/technote/ts659/ts659.html#B3b
N/A
Posts: 0

Re: Multiple Graphs on a single page

Thanks Chevelle,

What I'm trying to do seems to be a hybrid of the topics discussed here. This document talks about 'how to create multiple graphs using BY processing' and talks about 'creating multiple graphs on one page using multiple procedures.'

What I'm trying to do is get multiple graphs on one page using one procedure. Any pointers??
SAS Employee
Posts: 88

Re: Multiple Graphs on a single page

Another alternative may be to use the GREPLAY to replay the graphs to a single page. This works for the simple example below.

proc catalog c=work.gseg kill;
run;
quit;

data widgets;
input Region $ Type $ Sales;
cards;
East Gadgets 5250
East Gizmos 4200
East Widgets 4930
West Gadgets 4600
West Gizmos 2700
West Widgets 5500
;
run;

goptions reset = all
device = SASPRTC
target = SASPRTC
nodisplay
ftext = 'Helvetica'
ftitle = 'Helvetica/bold'
htitle = 4
htext = 2.5;

Title 'Hello World';
Footnote1 "Driver is &Sysdevic - Release is &Sysvlong";

proc gchart data=widgets;
vbar type / sumvar = sales
subgroup = type maxis=axis1 width=12 space=6;
by region;
axis1 value=(angle=0 rotate=0);
pattern1 v=s c=CX00CC99;
pattern2 v=s c=CXCCCCFF;
pattern3 v=s c=LIBG;

run;
quit;

ods listing close;

ods pdf file='c:\temp\greplay.pdf';

goptions reset=goptions device=sasprtc target=sasprtc;

proc greplay igout=work.gseg nofs tc=sashelp.templt
template=V2;
treplay 1:1 2:2;

run;
quit;

ods pdf close;
ods listing;
N/A
Posts: 0

Re: Multiple Graphs on a single page

The problem I am running into in trying to use GREPLAY and ODS to put multiple graphs on single page is that after running GREPLAY my graphs are squished. There appears to be enough space on the page for each graph. Any suggestions as to how to remedy this?
SAS Employee
Posts: 95

Re: Multiple Graphs on a single page

Instead of greplay, you may want to take a look at the html panel tagset.

http://support.sas.com/rnd/base/topics/odsmarkup
SAS Super FREQ
Posts: 8,740

Re: Multiple Graphs on a single page

Sometimes your graphs get squished when you do a GREPLAY because you have to adjust the orientation of the graph using the goptions statement and the rotate= option. Are you using one of the SAS/Graph templates for the replay??? See the use of rotate=portrait in this example
[pre]proc sort data=sashelp.shoes out=shoes;
where region in ('Western Europe', 'Canada')
and (product contains 'Dress' or
product contains 'Boot' or
product contains 'Casual');
by region;
run;

** first example will use greplay for these 2 charts;
proc gchart data=shoes;
title 'Average Sales in Western Europe';
where region = 'Western Europe';
VBAR3D Product /
sumvar=sales
type=MEAN
DISCRETE
FRAME
name="wesal"
;
label Sales="Avg";
run;
quit;


proc gchart data=shoes;
title 'Average Sales in Canada';
where region = 'Canada';
VBAR3D Product /
sumvar=sales
type=MEAN
DISCRETE
FRAME
name="cansal"
;
label Sales="Avg";
run;
quit;

** now use greplay...you are replaying images;
** that already have style applied;
ods rtf file='c:\temp\grafods1.rtf';
ods pdf file='c:\temp\grafods1.pdf';
ods html path='c:\temp' (url=none)
body='grafods1.html'
style=sasweb;
goptions reset=all rotate=portrait;

proc greplay igout=work.gseg
tc=sashelp.templt template=v2s nofs;
treplay 1:cansal 2:wesal;
run;
quit;
ods _all_ close;
[/pre]
if you used rotate=landscape, then the graphs would be squished.
cynthia
N/A
Posts: 0

Re: Multiple Graphs on a single page

I've been trying to use ODS LAYOUT to place multiple tables (from Proc Report) on a single page. I'm finding that using ODS LAYOUT in Enterprise Guide forces my session to disconnect from the server. Any thoughts?
N/A
Posts: 0

Re: Multiple Graphs on a single page

I looked at TS-659, but am still having difficulty getting my 12 pages with six graphs on a page produced using proc greplay output as a pdf file using the ODS. How do I use GREPLAY and ODS to generate a multi-page pdf file of 12 pages with six graphs on a page?
Thanks,
Mike
SAS Super FREQ
Posts: 8,740

Re: Multiple Graphs on a single page

Hi:
First, you need to understand how GREPLAY works and whether it's the right procedure for the job. If you run the code above, in my previous post, you will get a PDF file of 1 page with 2 graphs replayed on that 1 page. The 2 graphs are replayed on the page because I used a predefined graph replay template called V2S in my PROC GREPLAY statement:
[pre]
proc greplay igout=work.gseg
tc=sashelp.templt template=v2s nofs;
treplay 1:cansal 2:wesal;
run;
quit;
[/pre]

And then the TREPLAY statement says to replay the Canada graph in area 1 and the Western Europe graph in area 2 of the template. I do not remember whether SAS/Graph has a predefined template for 6 graphs on a page -- I think that would be one you'd have to define yourself (using the TDEF statement). So your first task is to get 1 page with 6 graphs and then move on to getting 12 pages with 6 graphs per page.

If you are going to try to create the page with 6 graphs using GREPLAY, then you have to define a 6 graph per page SAS/Graph template using the TDEF statement. After you define your SAS/graph template, then your code might look something like this to get 1 page with 6 graphs:
[pre]
proc greplay igout=work.gseg
tc=mylib.mytemps template=my6 nofs;
treplay 1:graf1 2:graf2 3:graf3 4:graf4 5:graf5 6:graf6;
run;
quit;
[/pre]


You can use one of the predefined SAS/Graph templates as a starting point for defining your template. You can see the available predefined SAS/Graph templates by running this code:
[pre]

proc greplay tc=sashelp.templt nofs;
list tc;
run;
quit;

[/pre]

Some references that may help you with defining your own graph template are:
SAS/Graph documentation
http://support.sas.com/kb/25/589.html
http://www2.sas.com/proceedings/sugi22/INFOVIS/PAPER170.PDF
http://www.lexjansen.com/pharmasug/2004/technicaltechniques/tt11.pdf
http://www.nesug.info/Proceedings/nesug98/invi/p128.pdf

You may eventually find that you need more help with this task than you can find on the forum. Your best bet for help with SAS/Graph and GREPLAY or SAS/Graph and ODS LAYOUT is to contact Tech Support.

cynthia
N/A
Posts: 1

Re: Multiple Graphs on a single page

Hi Cynthia,

I have the same problem with mgm. I used the same code in example 24939 with a few modifications to fit my data and currently I have 6 graphs in one page. My problem is that I have 304 graphs created using gplot and the "by variety" statement. I wish to distribute these graphs into 6 graphs for the 51 pages we're planning to print instead of just having the first 6 graphs printed into one page. I don't know which part of the program to modify:

goptions reset=all;

options mprint macrogen symbolgen;

goptions dev=ps hby=0;

%let across=3;

%let down=2;

%let npanels=%eval(&down*&across);

goptions reset=goptions device=png target=png;

proc greplay nofs igout=work.gseg;

delete _all_;

run;

quit;

data garea;

  rc=ginit();                    /* Initialize DSGI                */

  call gask('hsize',hsize,rc);   /* Get default HSIZE for driver   */

  hsze=hsize/&across;            /* Calculate horiz panel size     */

  call symput('hsize',left(trim(hsze))); /* Create HSIZE macro var */

  call gask('vsize',vsize,rc);   /* Get default VSIZE for driver   */

  vsze=vsize/&down;              /* Calculate vert panel size      */

  call symput('vsize',left(trim(vsze))); /* Create VSIZE macro var */

  rc=gterm();                    /* Terminate DSGI */

run;

goptions nodisplay hsize=8.3333 vsize=6.25;

proc sort data=Annotated;

by Variety Watering SumT;

run;

symbol1 r=2 i=join v=none;

proc gplot data=Annotated uniform;

plot predit_aero*SumT predit_flood*SumT/annotate=Annotated overlay legend=legend1;

by Variety;

run;

quit;

data numgraf;

  rc=gset('catalog','work','gseg');     /* Open the WORK.GSEG catalog*/

  rc=ginit();

  call gask('numgraph',grsegcnt,rc);    /* Get number of graphs in catalog*/

  if grsegcnt<&npanels then num=grsegcnt;  /* If there are more graphs than */

  else num=304;                   /* panels, replay only as many graphs as there are panels.*/

  call symput('numgrph',left(trim(num))); /* Number of graphs to replay */

  ymult=100/&down;                       /* Calculate Y increment for panels */

  xmult=100/&across;                     /* Calculate X increment for panels */

  rc=gterm();                            /* Terminate DSGI */

run;

data coord;

  set numgraf;

  do x=0 to (100-xmult) by xmult;  /* Calculate the X coordinate values */

    llx=x;

    ulx=x;

    urx=x+xmult;

    lrx=x+xmult;

    do y=0 to (100-ymult) by ymult;  /* Calculate the Y coordinate values */

      lly=y;

      uly=y+ymult;

      ury=y+ymult;

      lry=y;

      output;

    end;

  end;

run;

proc sort data=coord;

  by descending y;

run;

data mccoord;

  set coord end=eof;

  call symput('llx'||left(_n_),llx);

  call symput('ulx'||left(_n_),ulx);

  call symput('urx'||left(_n_),urx);

  call symput('lrx'||left(_n_),lrx);

  call symput('lly'||left(_n_),lly);

  call symput('uly'||left(_n_),uly);

  call symput('ury'||left(_n_),ury);

  call symput('lry'||left(_n_),lry);

  if eof then call symput('total',_n_);

run;

%macro tempdef;

%do i=1 %to &total;

   &i   / llx=&&llx&i     lly=&&lly&i

       ulx=&&ulx&i     uly=&&uly&i

       urx=&&urx&i     ury=&&ury&i

       lrx=&&lrx&i     lry=&&lry&i

   %end;

%mend tempdef;

%macro tplay;

%do i=1 %to &numgrph;

&i:&i

%end;

%mend tplay;

goptions reset=goptions target=ps;

proc greplay nofs igout=work.gseg tc=work.templt;

  tdef spec&npanels

%tempdef;         /* Invoke macro TEMPDEF to create template */

template spec&npanels;

treplay

%tplay;           /* Invoke macro TPLAY to replay graphs  */

run;

quit;

N/A
Posts: 0

Re: Multiple Graphs on a single page

Cynthia,

Thanks for your help. I was dynamically defining the template, based on the code in Sample 24939, and I was thrown off by where to place the ODS statements around the macro. Thanks to your replies I was able to figure that out and now have my 12 pages with six graphs to a page in a pdf file!
Thanks again,
Mike
Contributor
Posts: 43

Re: Multiple Graphs on a single page

HI mgm can you please share how you solved this problem as i am running into the same proble and cant seem to get what i am trying to do, i Have more than 100 graphs and i want 10 graphs per page , i am also using the by statement in Gplot , can you please help me with this.

Thanks

N/A
Posts: 0

Re: Multiple Graphs on a single page

is there a way to create multiple pages without gplot specifying each graph? (if you have 100 graphs can you run it through without coding 1:gplo1 2:gplot1 etc)

Also when outgraphing from treplay how can i change the name so that it isn't called template when its saved in a folder?
Ask a Question
Discussion stats
  • 13 replies
  • 4443 views
  • 2 likes
  • 6 in conversation