An Introduction to PROC GREPLAY Marc Jacobs, AT&T, Basking Ridge, NJ April 20, 1993 PROC GREPLAY is a procedure for redisplaying graphs created using SAS/GRAPH software. With this procedure you can redisplay your graphs on different devices, combine several graphs on a single page or screen, or compose a visual presentation. PROC GREPLAY can help you to make more effective grapbics. PROC GREPLAY can be run in batch, line mode or as a full screen, interactive procedure. Tbis tutorial will get you started using PROC GREPLAY interactively in the SAS display manager. Tbis is a good way to get started. It is assumed that you have some familiarity with SAS, SAS/GRAPH and the display manager. The focus here is not on creating the graphs but on how to make more effective use of those graphs you are already producing. What got me started using PROC GREPLAY was the desire to view a graph on screen before printing without having to run the procedure that created the graph twice. Tbis is useful if your graph required a great deal of processing to create or when they take a long time to print. I also wanted to present more than one graph on a page. With PROC GREPLAY you replay graphs created with other procedures that you have saved in a catalog. Getting started Start by creating a few graphs and saving them in a catalog. In my examples I've used PROC GMAP to produce a few maps of the boroughs of New York City. Once you have the appropriate map dataset the maps are easy to produce. The data on bagel consumption is imaginary. Don't worry about how the graphs themselves were created as any graphs will do. The point here is what you can do with your graphs after they've been generated. proc format; value cntfrnt 5='Bronx' 47=' Brooklyn' 61=' Manhattan' 81=' Queens' 85='Staten Island'; value bglfmt low-2='low' 3-6=' Medium' 7-high=' High' goptions targetdevice=ps device=xcolor rotate=landscape; patternl c=gray88 v=ms; pattern2 c=graybb v=ms; pattern3 c=grayee v=msi proc gmap map=hvs.nyc_r data=bagels geut=nycdata.nyc1; by county; where county in (5,61,47,81); id tract; chore bagels I levels=3 des='bagels by borough'; format bagels bglfmt. county cntfmt. label county='oo'xi run; proc gmap map=hvs.nyc_r data=bagels gout=nycdata.nyc1; where county in (5,61,47,81); id tract; choro bagels I levels=3 des='bagels, NYC'i format bagels bglfmt. county cntfmt. label county='oo'x; 1366
run; proc gslide gout=nydata. nycl des=' title w/apologi'es'; titld h=5 f=centx j=l, New York City' h=4 f=centx j=r 'Bagel Consumption'; footnotel h=3 f=centx j=l 'Prepared by Marc Jacobs' h=2 j=r 'Apologies to Staten Islanders'; run; To save the graphs in. a catalog add the gout= option to the SAS/GRAl'H procedure. These graphs were saved in a permanent catalog nydata. nycl. Once the program has run, the catalog nycdata. nycl will have four maps from the first PROC GMAP (one for each of the by variable, county), a fifth from the second GMAP procedure, and a sixth from the GSLIDE procedure. Look at the goptions statement While you can set the options differently to suit your printer and display, I've chosen these options because my target device, ps, is the postscript printer where I will ultimately produce my output. I can view the graphs on my xcolordisplay and see how they will look on paper. Without the targetdevice option I may find that my graph changed a little when printed. I often also use the nodisplay goption as well. This allows the program to run without interruption for printing or screen displays. PROC GREPLAY Now that you have a catalog of SAS graphs, your ready to start PROC GREPLAY. In the display manager just run proc greplay; to open the replay window. You can enter some of the required information along with the proc greplay command or enter it into the menu. Put the name of the catalog with your graphs in the igout field A list of all the catalog members will appear. When you created the graphs, you had the option of assigning names and descriptions to each of your graphs with the name= and des= options. This helps to make managing and keeping track of catalog entries easier. To display a graph, just put an s in the Sel (select) field next to the entry of your choice, and (gently) bit return. If you want to print the graph, change the Device field to the device name for your printer, put s in the Sel (select) field, and again bit return. To replay them in sequence put s 1, s 2,..., s 3 in the Sel field in the order you desire. Templates Perhaps the most useful feature of PROC GREPLAY is the ability to replay your graphs into templates. A template is a way of dividing your page or screen into different sections or panels. For example, you may want to place two graphs together on a page. With a template you can divide the page into two panels. These can be side by side, top and bottom, or in any position you choose. You then replay a graph into each panel. You can design your own templates or you can make use of the many templates that come with SAS/GRAl'H software. They can be located in the sashelp. tempi t catalog. Browse through these and see if there are templates to suit your purposes. To design your own, enter the name of the catalog where you will save your templates in the TC field, then go to the template edit screen by typing template at the greplay command prompt or chose template catalog from the pull-down menus. After the template window opens, choose edit from the pmenus or type it at the command prompt. Enter a name for the template and you can begin creating your design. You can divide the page into several panels but if the panels are too small you may shrink your graphs to illegibility. There can be space between them or they can overlap. One template that I often use is a single panel covering the entire page and four smaller panels, two across, but leaving space at the top and bottom. I use this to display four graphs with one common title. The one full page panel is for a title and footiiote that corresponds to all four graphs. This is more pleasing than having four graphs with the same title repeated. The panels are defined by a simple coordinate system. The lower left comer of the page is 0,0 and the upper right is 100,100. The template design window has a certain intelligence to aid. you in defining coor- 1367
dinates but it really isn't very difficult. For example, the full page panel has the coordinates (0,0; 0,100; 100,100; 100,0) and a smaller panel in the lower left comer has coordinates (0,10; 0,50; 50,50; 50,10). The y-coordinate starts at 10 instead of 0 to leave room for a footnote. Designing templates is an area where you can be a little creative. The panels need not be rectangular; odd-shaped windows can produce interesting effects. Keep in mind, though, that by changing the x,y scale of your graph you can distort your graph, stretching or shrinking an axis. You can put a frame around a panel by entering a color in the color field. The scale field scales the coordinates, shrinking or expanding a panel. Xlate moves the panel up, down, right, or left by the amount you enter. Rotate will reassign the coordinates so that your graph will be rotated on the page. I found this to be useful for switching between portrait and landscape orientations. Normally, you define the orientation with the rota t e= goption before starting PROC GREPLAY. If you are working in landscape mode then the coordinate 0,0 will be the lower left corner of a page in landscape orientation. To create a panel in portrait orientation while the goptions are set to landscape, ie. to rotate your graph, move the corners of the panel. For example if 0,0 was the lower left then make 0,0 the upper left. Shift all the other corners in the same direction. If this is confusing, try it on paper. Write the coordinates in the comers, then turn the page 90 degrees. Once you have finished your template, preview it in the template preview window. The preview is just the empty outline of your panels. The templates can be saved in a catalog for use with other graphs in other SAS sessions. example, I put the titles from the the gslide procedure in the full page panel, panel 1. The four maps go into panels 2 through 5. Hit return and the graph is ready. PROC GREPLAY is one of the easiest SAS/GRAPH procedure and one of the most useful. You may find it a bit tricky at first but persistence has its rewards. An afternoon spent experimenting can save you a great deal of time later when preparing your graphs for presentation. A few extras Like me, you probably intend your graph to be displayed on paper or overhead transparency, and less often on a display monitor. It is much better to set the targetdevice to the device on which you intend to produce your fina1 result before you create your graphs. It is also a good idea to define a common style that you can apply to all your graphs. Find the title and footnote size and and font that suits your taste. Standardize you axis and legend statements if possible. Sticking with a style helps to keep your graphs looking more consistent across panels. References SAS Institute Inc (1992), SAS;GRAPH Software, Reference, vols 1 &: 2, Version 6, First Edition, Cary, NC: SAS Institute Inc. Acknowledgments SAS and SAS/GRAPH are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. <Ill indicates USA registration. Putting it all together Now that you have your graphs and templates ready, you can start putting things together. Go back to the greplay window, saving your template along.the way. Enter the name of the template catalog in the tc field and the template name in the temp 1 ate field. Instead of entering s in the Se 1 field put the number of the panel in which you want the graph to display. For 1368
Figure 1: Proc Greplay window 1369
FIgure 2: template window 1370 ~-
PRO( @[PlM: T[N~'lAT[ D[SIGN rm Figure 3: template design window 1371
Figure 4: template preview window 1372