Out of the bosom of the Air,
Out of the cloud-folds of her garments shaken,
Over the woodlands brown and bare,
Over the harvest-fields forsaken,
Silent, and soft, and slow
Descends the snow.
"Snow-flakes" by Henry Wadsworth Longfellow
Happy holidays to all my readers! In my last post I showed how to create a well-known fractal called the Koch snowflake. The snowflake is aptly named because it has six-fold symmetry. But as Longfellow noted, a real snowflake is not stationary, but descends "silent, and soft, and slow."
As a gift to my readers, I decided to create an animated greeting card entirely in SAS. The animated GIF (click to enlarge) uses some of the SAS techniques that I have blogged about in 2016. The falling and rotating snowflakes were created by using matrix computations in the SAS/IML language. The animated GIF was created by using ODS graphics and PROC SGPLOT.Create an animated greeting card with #SAS Click To Tweet
Techniques used to create the animation
If you want to learn how I created this animated GIF with SAS, read on. I've blogged about all the essential techniques in previous posts:
- Create a Koch snowflake by using SAS/IML software.
- Create the centers of the snowflake by using uniform spacing with random perturbations.
- Use matrix operations to rotate and scale the snowflakes. Use vector operations to translate the snowflakes.
- Use the POLYGON statement in PROC SGPLOT to plot the snowflakes for each frame. For the fill color, I chose an off-white color that has the name "snow." The flakes are semi-transparent so that the text is not obscured.
- Use the TEXT statement in PROC SGPLOT to display the holiday greeting.
- To suppress the axes labels, tick marks, and values, use the DISPLAY=NONE option on the XAXIS and YAXIS statements in PROC SGPLOT.
- Create the animation automatically by using the BY statement in PROC SGPLOT. Prior to calling PROC SGPLOT, you have to set up ODS so that the output is written to an animated GIF file.
You can download the SAS program that creates the greeting card. Let me know if you adapt this program to create other animated images.
If you like SAS statistical programming or want to learn more about it, subscribe to this blog. In most articles I show how to use SAS for serious pursuits like statistical modeling, data analysis, optimization, and more. But programming with SAS can also be fun, and sometimes it takes a less-serious application to make people say, "Wow! That's cool! I didn't know SAS could do that!"
What an awesome way to highlight some techniques described in your previous blog posts with a very cool greeting card! Kudos and Happy Holidays Rick.
The snowflakes are very nice, thank you for posting the code. The verse of Longfellow seems to have fractal properties too, as it is a quote within a quote! The first line is a reference to the famous balcony scene in Shakespeare's Romeo and Juliet. Best wishes for the Holidays Rick.
Code is not working on SAS Studio running on SAS 9.0.4. D you know why.
"Code is not working" is not useful information. Most likely cause: you don't have SAS/IML or you don't have a recent version of SAS.
If you want to pursue this, please post the log and your SAS version to the SAS Support Communities: https://communities.sas.com/
There is no such thing as "SAS 9.0.4", so also post the result of
to that site when you ask your question.