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 ?
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 ;
papersize = ("4in", "4in")
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.