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;

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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