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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.