Chapter Contents

Previous

Next
SAS/GRAPH Software: Reference

Animating GIF Files (DEV=GIFANIM)

The GIFANIM driver provides a mechanism for combining GIF images created with SAS/GRAPH procedures that allow you to create GIF animations for reports you publish on the Web. The behavior of the driver is controlled by graphics options that enable you to set such things as delay time, iteration count, transparency, and disposal methods.

Before using the GIFANIM device driver, you should become familiar with the animation process, the controls available, and certain limitations. The driver counts on you to control the process so that the animated sequence will be constructed properly.

For an example, see Example 6: Creating a GIF Animation File.


GIF Animation Process

The process involved with creating an animated GIF with the GIFANIM driver requires that you, the animator, take control of the job sequence and ensure that the resulting data stream is constructed properly. The GIFANIM data stream has three parts: Header, Body, and Trailer. Each portion of the data stream is equally important and must be present. Otherwise, an incomplete or unreadable animation sequence will result.

Preparing the Header

When creating a new animated GIF data stream, you must issue GOPTIONS GSFMODE=REPLACE prior to the invocation of the first SAS/GRAPH procedure in the SAS job. The driver will then construct a new data stream by writing a valid GIF header and graphic data from the first procedure.

Preparing the Body

After the first SAS/GRAPH procedure has been executed, you must construct the body of the GIF animation. You can think of the Body as all the graphic images between the first and last image. Set GOPTIONS GSFMODE=APPEND to signal the GIFANIM driver to suppress the header information and to begin appending graphic data to the current data stream. The GOPTIONS GSFMODE=APPEND statement must appear somewhere between the first and second SAS/GRAPH procedures.

Note:   If you use BY-group processing on the first graphics procedure to generate multiple graphs, they are automatically appended to the same GIF file. Thus, you do not need GSFMODE=APPEND for that first procedure. If you do not use a second graphics procedure to append additional graphs to the GIF file, you do not need this Body section in your program.  [cautionend]

Preparing the Trailer

The final step is to mark the end of the animation by appending a GIF trailer ('3B'x) to the data stream. The way to do this depends on whether the last procedure uses BY-group processing.

After the animation is complete, issue a GOPTIONS RESET=ALL statement to prepare for succeeding SAS jobs.


GIFANIM Device Driver Controls

You can control the GIFANIM device driver with these GOPTIONS settings:

ITERATION=iteration-count
specifies the number of times to repeat the animation loop, or whether to loop infinitely. An iteration of 0 specifies an infinite loop.

GSFMODE=REPLACE | APPEND
specifies whether the graphics output should replace the contents of an existing file or be appended to it. In addition, the GIFANIM driver uses the value of GSFMODE to determine when to write the GIF header.

DELAY=delay-time
controls the amount of time between graphs in the animation sequence. A delay time of 1 specifies a delay of .01 seconds.

DISPOSAL = NONE | BACKGROUND | PREVIOUS | UNSPECIFIED
specifies what happens to the graphic after it is displayed.

USERINPUT | NOUSERINPUT
enables or disables user input during image animation if supported by the browser displaying the animation.

TRANSPARENCY | NOTRANSPARENCY
specifies whether the background of the image should appear to be transparent when the image is displayed in the browser.

For a complete description of these options, see Graphics Options and Device Parameters Dictionary.

Note:   Beginning with Version 7, some of the options that control the GIFANIM driver's behavior are different from earlier releases.  [cautionend]


Changing the Size of the Output

If the default size of the GIFANIM device is not suitable for your needs, you can modify GOPTIONS HSIZE= and VSIZE= accordingly. The following SAS macro has been provided so that you can set HSIZE= and VSIZE= indirectly in pixel units:

%macro IMGSIZE(w=1280, h=1024, dpi=100,
               rows=43, cols=83);

   %if &dpi <=0 %then
      %put DPI must be greater than zero.;
   %else %do;
      goptions hsize=%sysevalf(&w/&dpi)in
               vsize=%sysevalf(&h/&dpi)in
               hpos=&cols vpos=&rows
   %end;

%mend IMGSIZE;

For example, to create an image that is 373 pixels wide and 280 pixels high, submit this macro call:

%imgsize(w=373, h=280);

Here are some key points to remember when using the %IMGSIZE macro:


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.