BookmarkSubscribeRSS Feed
tc
Lapis Lazuli | Level 10 tc
Lapis Lazuli | Level 10

HappyEaster2022.gif

 

A SAS ODS Graphics (polygon+spline+text plots) Happy Easter to all!

* Fun With SAS ODS Graphics: Easter Egg Dyeing;

data points;                                                         * Create points for "egg" made from an ellipse and a circle;
poly=1;                                                              * One polygon of points;
do x=-.75, -.75 to .75 by .01, .75;                                  * Top is a vertical half-ellipse (width=.75, height=1);
  y=sqrt(1-x**2/.75**2);
  if y^=. then output;                                               * Polygons don't like missing values, kids!;
end;
do x=.75, .75 to -.75 by -.01, -.75;                                 * Bottom is a semi-circle (r=.75, generate points right to left for polygon);
  y=-sqrt(.75**2-x**2);
  if y^=. then output;                                               * Polygons don't like missing values, kids!;
end;
x=.; y=.; xT=0; yT=.25/2; text="Happy*Easter!"; output;              * Centered Happy Easter! message;

%macro colorEggs;
%do transparency=0 %to 100 %by 2;                                    * Generate frames with varying levels of transparency;
%if &transparency=0 | &transparency=100 %then options animduration=1; %else options animduration=.12;; * Display first/last frame for 1 second, others for .12 second;
proc sgplot data=points aspect=1 noborder noautolegend nowall;       * Generate Easter Egg - polygon plot of half-ellipse + semi-circle points, spline plot border, text plot message;
polygon x=x y=y id=poly / nooutline fill nooutline fillattrs=(color=purple
        transparency=%sysevalf((100-&transparency)/100));            * "Egg" polygon;           
spline x=x y=y / lineattrs=(color=purple thickness=2pt);             * Draw smoother egg outline using spline plot;
text x=xT y=yT text=text / position=center vcenter=bbox splitchar='*' contributeoffsets=none
                           splitpolicy=splitalways textattrs=(size=48pt weight=bold color=white) strip; * Happy Easter! message;
xaxis display=none min=-.925 max=.925 offsetmax=.001 offsetmin=.001; * Limit x/y axis bounds;
yaxis display=none min=-.80 max=1.05 offsetmax=.001 offsetmin=.001;
run;
%end;
%mend;
                                                                     * Create animated GIF from frames;
options papersize=('5 in', '5 in') printerpath=gif animation=start 
        nodate nonumber animloop=YES animduration=1 NOANIMOVERLAY; 
ods printer file='~/HappyEaster2022.gif';              
ods graphics / reset antialias border=no height=5in width=5in imagefmt=gif border=off;

%colorEggs;                                                         * Generate Easter Egg animated GIF;

options printerpath=gif animation=stop;                             * Wrap-up animated GIF creation;                         
run;
ods printer close;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 0 replies
  • 702 views
  • 4 likes
  • 1 in conversation