This example generates
an animated GIF using RUN-group processing. RUN-group processing is
used to show the 1993 sales data in a specific product order: desks,
tables, chairs, sofas, and beds.
The following display
shows the first image of the animated GIF only.
The animation iterates
through the sales data for Canada, Germany, and the U.S.A. The animation
waits two seconds between each image and iterates through the animation
four times. The animation stops after the fourth iteration and displays
the first graph (desks).
The images are generated
using the GCHART procedure with RUN-group processing and WHERE clauses
to select individual products. Transparency is enabled for each image,
so that the Web browser background shows through the unoccupied areas
of each image. PUT statements are then used to generate an HTML file
that enables you to view the animation with a Web browser. The <BODY>
tag in the HTML code specifies a Web browser background color of #F2F2CF,
which shows through the image.
You can change the delay
between each image by changing the DELAY= graphics option. You can
change the number of iterations by changing or removing the ITERATIONS=
graphics option. You can also remove the TRANSPARENCY graphics option
or change it to NOTRANSPARENCY to see the effect that transparency
has on the image.
Here is the example
program code.
/* Create file references for the output */
filename gifout "gifanim2.gif"; /* Image output */
filename htmout "gifanim2.html"; /* HTML output */
/* Close the ODS HTML destination */
ods html close;
/* Open ODS LISTING and specify the graph style */
ods listing style=highcontrast;
/* Delete the previously created graphs before creating new ones */
proc greplay igout=Work.Gseg nofs;
delete _all_;
run; quit;
/* Set graphics options */
goptions reset=all device=gifanim gsfmode=replace gsfname=gifout noborder
transparency /* Let the browser background show through */
disposal=background /* Restore the background between images */
delay=200 /* Wait 2 seconds between each image */
/* (200 x 0.01s) */
iterations=4 /* Run the animation four times */
gsfname=gifout gsfmode=replace;
/* Generate the graphs using RUN-group processing */
title1 "1993 Sales";
proc gchart data=sashelp.prdsale(where=(year=1993));
title2 "Desks";
vbar3d country / sumvar=actual;
where product="DESK";
run;
/* Set the GSFMODE= graphics option to append the remaining graphs */
goptions gsfmode=append;
title2 "Tables";
vbar3d country / sumvar=actual;
where product="TABLE";
run;
title2 "Chairs";
vbar3d country / sumvar=actual;
where product="CHAIR";
run;
title2 "Sofas";
vbar3d country / sumvar=actual;
where product="SOFA";
run;
/* For the last graph, set the GEPILOG= graphics option to */
/* append the trailer */
GOPTIONS GEPILOG="3B"X;
/* Generate the last graph */
title2 "Beds";
vbar3d country / sumvar=actual;
where product="BED";
run;
quit;
/* Create the HTML file to view the animated GIF */
data _null_ ;
file htmout ;
put "<HTML>";
put "<HEAD>";
put "<TITLE> GIFANIM </TITLE>";
put "</HEAD>";
put "<BODY STYLE='background:#F2F2CF'>";
put "<IMG STYLE='border:none' src='gifanim2.gif'>";
put "</BODY>";
put "</HTML>";
run;
quit;
/* Close the LISTING destination and open the HTML destination */
ods listing close;
ods html;