Combined my Thanksgiving Pumpkin Pie Plot code and @Rick_SAS's 2016 SGPLOT BY-statement animation trick to quickly cobble together a twinkle-twinkle-little-star wreath. Happy Holidays, all!
* Fun w/SAS ODS Graphics: Happy Holidays! Twinkle-Twinkle-Little-Stars Wreath (Scatter + Text Plots);
data wreath; /* Generate points for "wreath" graph */
do frame=1 to 25; /* Randomly change colors of stars for each frame of GIF to make them twinkle */
tx=0; ty=0; msg="HAPPY*HOLIDAYS!"; output; tx=.; ty=.; /* Happy Holidays! message in center of wreath */
do theta=0 to 2*constant("pi")+.1 by (2*constant("pi"))/60; /* Generate 60 points around a circle for stars on wreath */
do r=1 to .7 by -.075; /* Five con-centric circles of stars */
x=r*cos(theta); /* A little trigonometry to get x-coordinate */
y=r*sin(theta); /* And y-coordinate */
color=(rand("Integer", 0, 2)); /* Assign a random color - silver, gold, white color ramp */
output;
end;
end;
end;
ods graphics / imagefmt=GIF width=5in height=5in; /* Record wreath images */
options nobyline papersize=('5 in', '5 in') animduration=.2 animloop=yes animoverlay printerpath=gif animation=start nodate nonumber;
ods printer file='~/xmaswreath/wreath.gif'; /* Animated GIF filename */
proc sgplot noautolegend aspect=1 noborder nowall pad=0; /* Generate a wreath! */
by frame; /* One image per frame to make stars twinkle */
styleattrs backcolor=CX102e05; /* Xmas tree green background color */
symbolchar name=uniStar char='2605'x; /* Unicode value for 5-pointed star */
scatter x=x y=y / markerattrs=(symbol=uniStar size=22pt) colormodel=(silver gold white) colorresponse=color; * Generate stars;
text x=tx y=ty text=msg / backlight=1 contributeoffsets=none textattrs=(size=24pt weight=bold color=cxdcf0ef) splitchar='*' splitpolicy=splitalways contributeoffsets=none; * "Happy Holidays!" message;
xaxis display=none; yaxis display=none; /* Hide axes */
run;
options printerpath=gif animation=stop; /* Stop recording images */
ods printer close;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.