BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
15 REPLIES 15
Chevell_sas
SAS Employee
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
deleted_user
Not applicable
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??
Chevell_sas
SAS Employee
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;
deleted_user
Not applicable
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?
Eric_SAS
SAS Employee
Instead of greplay, you may want to take a look at the html panel tagset.

http://support.sas.com/rnd/base/topics/odsmarkup
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
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?
deleted_user
Not applicable
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
Cynthia_sas
SAS Super FREQ
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
abigaildomingo
Calcite | Level 5

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;

SanjayAhir
Obsidian | Level 7

Hi,

 

I am using PROC SGPLOT to create graph. How can i create graph catalog in work library with sgplot procedure so I can use that in proc greplay procedure. like other procedure have gout = option.

Cynthia_sas
SAS Super FREQ
Hi:
Please do not bury your new posting in an 11 year old previous posting. You cannot use GREPLAY with PROC SGPLOT. PROC SGPLOT belongs to ODS GRAPHICS and GREPLAY belongs to SAS/GRAPH. ODS GRAPHICS images are NOT stored in a SAS/GRAPH catalog.

I suggest you make a new posting on your topic and show the code you've tried or explain your task in detail.

Cynthia
deleted_user
Not applicable
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
Ahmad
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 15 replies
  • 7319 views
  • 2 likes
  • 7 in conversation