Creating Animated GIF Images and SVG
About Animated GIF Images and SVG Documents
When you create a multi-page GIF image or SVG document using the ODS PRINTER
destination, you can animate the GIF image or SVG document that is created by setting
SAS system options. Each page in the GIF image or SVG document creates one frame in
the output file. The system options enable you to configure these animation attributes:
start or stop creating an animated file
the amount of time that a frame is in view
whether frames are overlaid or are played sequentially
the number of times an animation loop is repeated
Creating Animated GIF Images and SVG Documents 323
for SVG documents only, whether to immediately start the animation when the
document is loaded in the web page
for SVG documents only, whether a frame fades in and out of view and if during the
fade-in and fade-out time, the frames are overlaid or played sequentially
SAS/GRAPH is required to create animated files for the ODS HTML5, ODS HTML,
and the ODS LISTING destinations. For more information, see SAS/GRAPH: Reference.
You set the options using the OPTIONS statement before opening the ODS PRINTER
options printerpath=gif animation=start animduration=5 animloop=yes noanimoverlay;
ods printer file='myfile.gif';
In this OPTIONS statement, the ANIMATION option starts creating the animation file,
the ANIMDURATION option specifies that each frame is held for 5 seconds. The
ANIMLOOP option specifies to continuously repeat the animation loop. The
NOANIMOVERLAY option specifies that each frame is played sequentially.
When the PRINTERPATH= option is set to SVG, you can use the SVG animation
options to configure the fade-in and fade-out attributes and the autoplay attribute. The
animation options that begin with SVG do not affect GIF images.
After you set the options and opened the PRINTER destination, proceed with your SAS
code to create each frame in your file. The animation frame is created when you run SAS
procedures. You can use animation options in between procedures to change the duration
that a frame is held in view and the fade-in and fade-out times. For example, you can
hold a particular frame in view for a longer period of time. You would use the OPTIONS
ANIMDURATION= statement before a procedure to increase the time that the frame is
held in view. Specify ANIMATION=STOP to end the creation of the animation file. Use
the ODS PRINTER CLOSE statement to close the file.
T I P Be sure to specify ANIMATION=STOP after you create the frames for your
animation file. If ANIMATION=START remains set, you might create an animation
file unintentionally for subsequent procedure statements.
To embed the file in a web page or to create a link to the file from a web page, see “SVG
Documents in HTML Files” on page 316.
When an animated file is displayed in a browser, the animation control buttons can be
used to reset ( ) the animation, to pause ( ) the animation, and to play ( ) the
animation. You can toggle SVG Controls to show or hide the control buttons. Here is
one frame of an animated SVG document with the control buttons:
324 Chapter 15 Printing with SAS
If you are creating SVG files that will be viewed on an iPad, a best practice is to use the
SVGVIEW Universal Printer for optimal sizing.
You can view animated SVG files using Internet Explorer 9 or later. You can view
animated GIF files in releases prior to Internet Explorer 9.
Animation System Options
You use the animation system options to configure the attributes of an animation GIF or
SVG file. All of the system options can be configured for SVG documents. The options
that begin with SVG are not applicable for GIF images. Here are the animation system
Table 15.22 Animation System Options and Valid Universal Printers
Description Option Name
Valid Universal
Starts or stops the creation of an animation
Specifies the amount of time that each
frame in an animation is held in view.
Creating Animated GIF Images and SVG Documents 325

Get SAS 9.4 Language Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.