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

wreath.gif

 

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;

 

2 REPLIES 2
MichelleHomes
Meteorite | Level 14
Impressive! Nothing like a bit of Christmas trigonometric twinkle! 🌟
//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 944 views
  • 9 likes
  • 3 in conversation