Creating Animated GIF Images and SVG
Documents
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 343
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
destination:
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 336.
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:
344 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
options.
Table 15.22 Animation System Options and Valid Universal Printers
Description Option Name
Valid Universal
Printers
Starts or stops the creation of an animation
file.
ANIMATION GIF and SVG
Specifies the amount of time that each
frame in an animation is held in view.
ANIMDURATION= GIF and SVG
Creating Animated GIF Images and SVG Documents 345
Description Option Name
Valid Universal
Printers
Specifies whether the animation loop is
played continuously or is played once, or
specifies a specific number of times that
the animation loop is repeated.
ANIMLOOP=YES sets a continuous loop.
ANIMLOOP=NO completes one loop.
ANIMLOOP=n specifies a specific
number of times to loop.
For SVG documents, use
ANIMLOOP=YES and ANIMLOOP=NO.
Setting ANIMLOOP=n where n > 0 for
SVG documents completes only one loop
for the document.
ANIMLOOP= GIF and SVG
Specifies whether animation frames are
overlaid or if they are played sequentially.
If you overlay frames, your frames would
require some level of transparency for the
output not to appear overwritten.
ANIMOVERLAY GIF and SVG
Specifies whether an SVG animation starts
immediately in the web browser.
If you specify NOSVGAUTOPLAY, start
the animation by clicking .
SVGAUTOPLAY SVG
Specifies the number of seconds for an
SVG frame to fade into view.
SVGFADEIN= SVG
Specifies whether an SVG frame overlaps
the previous frame or if each frame is
played sequentially when a frame is fading
in and out.
SVGFADEMODE= SVG
Specifies the number of seconds for an
SVG frame to fade out of view.
SVGFADEOUT= SVG
Example: Creating an Animated SVG Document
The data set sashelp.prdsale contains office and furniture sales data for the years 1993
and 1994. This example uses the SGPLOT procedure to plot a vertical bar that displays
the actual sales numbers of office and furniture products for Canada, Germany, and the
United States. The plot uses a vertical bar for each country. Each vertical bar shows the
data for the different products. The example groups the data by quarters for each year,
creating eight charts. When the animation plays, each SVG frame is a chart for one of
the quarters. The chart displays a color for each season, and the product sales values
change in each vertical bar. To see the animation play for this example, go to
support.sas.com. Under Knowledge Base, select Samples & SAS Notes. Search for
SVG animation, In the search results, look for the program seasons.sas.
346 Chapter 15 Printing with SAS
Create a data set for each quarter for the years 1993 and 1994. Each DATA step uses
a WHERE clause to create a data set by year and quarter. The KEEP option in the SET
statement specifies the variables that are in each of the data sets.
data work.q1y93 (where=(year=1993 and quarter=1));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q2y93 (where=(year=1993 and quarter=2));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q3y93 (where=(year=1993 and quarter=3));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q4y93 (where=(year=1993 and quarter=4));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q1y94 (where=(year=1994 and quarter=1));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q2y94 (where=(year=1994 and quarter=2));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q3y94 (where=(year=1994 and quarter=3));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
data work.q4y94 (where=(year=1994 and quarter=4));
set sashelp.prdsale(keep=Actual Country Product Quarter Year);
run;
Create a style for each season. The four TEMPLATE procedures create a style for each
season by specifying seasonal colors for the different parts of the chart. The colors for
the vertical bars are not part of the style because they are automatically generated by the
SGPLOT procedure.
proc template;
define style winter;
parent = Styles.meadow;
style body from body;
style GraphColors from GraphColors /
"gborderlines" = cx000000
"greferencelines" = cx000000
"gaxis" = cx000000
"gwalls" = cx83838C
;
style GraphBackground /
Color = cxB3B2BF
;
end;
Creating Animated GIF Images and SVG Documents 347
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.76.164