Consider this program that creates an animated gif. The file size is ~1.25MB
It can be compressed about 83% by external processes (https://gifcompressor.com/)
Are there any SAS options for directly creating a compressed anim gif ?
Program
data have; do angle = 0 to 1080 by 15; theta = 2 * constant('PI') / 360 * angle; r = theta; x = r * cos(theta); y = r * sin(theta); output; end; run; filename animgif "spiral.gif"; filename htmlout "spiral.html"; /* HTML output */ proc stream outfile=htmlout; BEGIN <HTML><HEAD><TITLE>Animated spiral</TITLE></HEAD><BODY> <IMG src='spiral.gif'> </BODY></HTML> ;;;; ods _all_ close; ods graphics / width=600 height=600; *ods graphics / imagename="spiral" reset=index(1) outputfmt=gif; options printerpath=gif animation=start animduration=0.10 animloop=yes noanimoverlay ; ods printer file=animgif; options animation=start; proc sql; create table spiral as select each.angle as frame, self.x, self.y, self.theta from have as self join have as each on each.theta >= self.theta order by frame, self.theta ; proc sgplot data=spiral; by frame; series x=x y=y; scatter x=x y=y / markerattrs=(symbol=circle); xaxis min=-20 max=20; yaxis min=-20 max=20; run; proc sort data=spiral; by descending frame theta; run; proc sgplot data=spiral; by descending frame; series x=x y=y; scatter x=x y=y / markerattrs=(symbol=circle); xaxis min=-20 max=20; yaxis min=-20 max=20; run; options animation=stop; ods printer close;
Turns out GIF device is not so easy. The GIF dpi is 96.
Setting the Resolution of Your Graph doc says:
About Setting the Resolution
Note: Devices other than those listed (PNG, PNGT, PNG300, SVG, SVGT, SVGVIEW, or SVGZ) do not honor the IMAGE_DPI= option.
Using the XPIXELS=, XMAX=, YPIXELS=, and YMAX= Graphics Options to Set the Resolution for the Traditional Devices
The resolution of GIF and BMP images is fixed and cannot be changed using this method.
The only improvement I could get was to ensure the papersize matched the ods graphics size.
ods graphics / width=4in height=4in ;
options
papersize = ("4in", "4in")
printerpath=gif
animation=start
animduration=0.10
animloop=yes
noanimoverlay
;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.