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

Pie Chart New Year's Eve Countdown TimerPie Chart New Year's Eve Countdown Timer

 

A stopwatch-inspired SAS ODS Graphics pie chart New Year's Eve countdown timer. Happy New Year, all!

 

* Fun w/SAS ODS Graphics: Pie Chart New Year's Eve Countdown Timer;

proc format;                         * HH:SS stopwatch time format;
picture stopwatch low-high='99:99';
                                     * Generate data to plot;
data countdown;                      * Two observations every 10th of a second for pie chart wedges;
length text $ 20;                    * One obs with seconds elapsed, the other with seconds remaining; 
do frame=10 to -1.5 by -.1;          * 10 second countdown + 1.5 seconds extra for Happy New Year greeting;
  if frame>=0.01 then text=put(ceil(frame),stopwatch5.); else text="Happy New Year!";
  cat="Elapsed  "; secs=10-frame; if 0.01<secs then output; * Output elapsed + remaining time "wedges";
  cat="Remaining"; secs=frame;    if 0.01<secs then output; * Wedge values <=0 are a pie chart no-no!;
end;
           
proc template;                       * Template for New Years Eve countdown timer chart (pie chart + oval + text);                         
define statgraph countdown;               
dynamic _byval2_;                    * Time to display is in the TEXT variable (second BY variable); 
begingraph / subpixel=on border=false datacolors=(dagray silver) backgroundcolor=black pad=0in; 
layout region / border=false backgroundcolor=black outerpad=.5in; * Half-inch "margins";
piechart category=cat response=secs / outlineattrs=(color=dagray) datalabelcontent=none centerfirstslice=false start=90 categorydirection=clockwise display=(fill); * Pie chart of time elapsed/remaining; 
drawoval x=50 y=50 width=75 height=75 / display=(fill) fillattrs=(color=black) layer=front; * Blackout center of pie chart to create ring effect (DIY donut chart);
drawtext textattrs=(size=80pt color=white weight=bold) _byval2_ / x=50 y=50 width=75 layer=front justify=center; * Display time remaining + Happy New Year message;
endlayout;
endgraph;
end; 
run;

options nobyline;                                                   * Animated GIF initialization;
ods _all_ close;
options papersize=('5 in', '5 in') printerpath=gif animation=start 
        nodate nonumber animloop=YES animduration=.1 NOANIMOVERLAY; * One frame every 1/10th second;
ods printer file='/folders/myfolders/HappyNewYear.gif';             * Animated GIF file name;
ods graphics / width=5in height=5in imagefmt=GIF border=off;        * 5 x 5 inch image;

proc sgrender data=countdown template=countdown; * One frame for each tenth of a second;
by frame text notsorted;

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

 

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 0 replies
  • 3576 views
  • 6 likes
  • 1 in conversation