<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fun With SAS ODS Graphics: Pac-Man inspired New Year's Eve 2019 Pie Chart countdown timer in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/523903#M17597</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PacMan.gif" style="width: 288px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25915i167C65F0C117FD36/image-size/large?v=v2&amp;amp;px=999" role="button" title="PacMan.gif" alt="PacMan.gif" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To mark the close of the old year and beginning of the new, here's a short program for a &lt;A href="https://en.wikipedia.org/wiki/Pac-Man" target="_self"&gt;Pac-Man&lt;/A&gt; inspired New Year's Eve countdown timer. Who says you shouldn't use Pie Charts?&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; Happy New Year, all!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw, for a compilation of past Fun-With-SAS-ODS-Graphics posts, check out &lt;A href="https://communities.sas.com/t5/Graphics-Programming/quot-Oh-There-s-No-Place-Like-SAS-ODS-Graphics-for-the-Holidays/m-p/523237" target="_self"&gt;Oh, There’s No Place Like SAS ODS Graphics for the Holidays!&lt;/A&gt; Silly, yes, but also illustrates some techniques you may find useful for creating &lt;A href="https://support.sas.com/resources/papers/proceedings15/3432-2015.pdf" target="_self"&gt;reproducible and scalable graphics&lt;/A&gt; in your Day Job!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Fun With SAS ODS Graphics: Pac-Man inspired New Years Eve 2019 Pie Chart countdown timer;

data slices;                                 * Create SAS data for pie charts;
do r=1 to 10;                                * 10-9-8-7-6-5-4-3-2-1 countdown (seconds);
do p=0 to 20 by 2.5, 20 to 0 by -2.5;        * 18 charts for each second (mouth closed=0% to wide-open=20%, and back again!);    
  n+1;                                       * Assign unique # to each chart (2 slices/chart);
  slice=1; pct=p;     output;                * 1st slice for "mouth";
  slice=2; pct=100-p; output;                * 2nd slice for remainder;
end;
end;

proc template;                               * Template for New Years Eve countdown timer chart (pie chart + text);                         
define statgraph pacman;                
mvar Yr remainSec unicodeSec xLoc Msg;       * Parameters: year, remaining seconds, Unicode secs, x-location (%), Happy New Year message;
begingraph / subpixel=on border=false datacolors=(black CXFFFF00) backgroundcolor=black pad=0in; * Like game, make "Pac-Man" yellow, with black "mouth";
layout region / border=false backgroundcolor=black outerpad=1in; * Provide some padding for text;
piechart category=slice response=pct / datalabelcontent=none centerfirstslice=true display=(fill); 
drawtext textattrs=(size=36pt color=CX00ff00 weight=bold) Yr / y=100 anchor=top widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Green year;
drawtext textattrs=(size=16pt color=CX00ff00 weight=bold) remainSec / y=5 anchor=bottom widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Green seconds remaining;
drawtext textattrs=(size=24pt color=CXFFFF00 weight=bold family="Arial Unicode MS") {unicode unicodeSec} / y=50.5 anchor=right x=xLoc widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Yellow "dots" with seconds remaining;
drawtext textattrs=(size=24pt color=CX1919A6 weight=bold) Msg / justify=center y=50 anchor=center x=50 widthunit=percent width=50 yspace=graphpercent xspace=graphpercent; * Blue-ish Happy New Year message;
endlayout;
endgraph;
end; 
run;

ods _all_ close;                             * Animated GIF setup (pause for 1.5 secs on 1st frame);                       
options papersize=('3 in', '3 in') printerpath=gif animation=start nodate nonumber animduration=1.5 animloop=NO NOANIMOVERLAY;
ods printer file='/folders/myfolders/PacMan.gif'; * Animated GIF image filename;
ods graphics / height=3in width=3in imagefmt=gif antialias; 

%macro genframes;                            /* Generate 180-frame coundown (10 seconds * 18 frames/second) */ 
%do s=10 %to 1 %by -1;                       /* Generate set of 18 frames for each second in 10-second countdown */
  %let UnicodeSec="%scan(2460 2461 2462 2463 2464 2465 2466 2467 2468 2469, &amp;amp;s, ' ')"x; /* Unicode values for animated dots filled with remaining secs (10, 9, ..., 1) */
  %let RemainSec="Time Remaining: 00:%sysfunc(putN(&amp;amp;s,z2.))"; /* Display remaining secs at bottom of image */
  %do c=1 %to 18;                            /* Generate frames for one second interval */                           
    %let n=%eval((&amp;amp;s-1)*18+&amp;amp;c);              /* Determine pie chart # (used to select data generated earlier) */
    %let xLoc=%scan(100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66, &amp;amp;c, ' '); /* X-coordinates (%'s) for animated dot that show seconds remaining */
    proc sgrender data=slices(where=(n=&amp;amp;n)) template=pacman; /* Create pie charts! */
    run; 
    options animduration=.056;               /* Try to make total duration of 10 seconds-ish (180 images x .056 sec/image) */
  %end;
%end;
%mend;

%let Yr="2018";                              * Display old year (2018);
%let Msg="";                                 * No Happy New Year message until end;
%genframes;                                  * Issue macro call to generate 180 frames!;

options animduration=1.5;                    * Display "GAME OVER" frame at bottome of screen for 1.5 seconds;
%let RemainSec="GAME OVER";
proc sgrender data=slices(where=(n=180)) template=pacman; * Create pie chart|;
run;

options animduration=3;                      * For 3 seconds, show final frame...;
%let Yr="2019";                              * Display new year (2019) at top of screen;
%let Msg="HAPPY NEW YEAR!";                  * Display "HAPPY NEW YEAR" over pie chart in middle of screen; 
%let RemainSec="PRESS START";                * Display "PRESS START" at bottom of screen;
proc sgrender data=slices(where=(n=180)) template=pacman; * Create pie chart!;
run;

options printerpath=gif animation=stop;      * Animated GIF wrap-up;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Dec 2018 01:00:54 GMT</pubDate>
    <dc:creator>tc</dc:creator>
    <dc:date>2018-12-31T01:00:54Z</dc:date>
    <item>
      <title>Fun With SAS ODS Graphics: Pac-Man inspired New Year's Eve 2019 Pie Chart countdown timer</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/523903#M17597</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PacMan.gif" style="width: 288px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25915i167C65F0C117FD36/image-size/large?v=v2&amp;amp;px=999" role="button" title="PacMan.gif" alt="PacMan.gif" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To mark the close of the old year and beginning of the new, here's a short program for a &lt;A href="https://en.wikipedia.org/wiki/Pac-Man" target="_self"&gt;Pac-Man&lt;/A&gt; inspired New Year's Eve countdown timer. Who says you shouldn't use Pie Charts?&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; Happy New Year, all!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw, for a compilation of past Fun-With-SAS-ODS-Graphics posts, check out &lt;A href="https://communities.sas.com/t5/Graphics-Programming/quot-Oh-There-s-No-Place-Like-SAS-ODS-Graphics-for-the-Holidays/m-p/523237" target="_self"&gt;Oh, There’s No Place Like SAS ODS Graphics for the Holidays!&lt;/A&gt; Silly, yes, but also illustrates some techniques you may find useful for creating &lt;A href="https://support.sas.com/resources/papers/proceedings15/3432-2015.pdf" target="_self"&gt;reproducible and scalable graphics&lt;/A&gt; in your Day Job!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Fun With SAS ODS Graphics: Pac-Man inspired New Years Eve 2019 Pie Chart countdown timer;

data slices;                                 * Create SAS data for pie charts;
do r=1 to 10;                                * 10-9-8-7-6-5-4-3-2-1 countdown (seconds);
do p=0 to 20 by 2.5, 20 to 0 by -2.5;        * 18 charts for each second (mouth closed=0% to wide-open=20%, and back again!);    
  n+1;                                       * Assign unique # to each chart (2 slices/chart);
  slice=1; pct=p;     output;                * 1st slice for "mouth";
  slice=2; pct=100-p; output;                * 2nd slice for remainder;
end;
end;

proc template;                               * Template for New Years Eve countdown timer chart (pie chart + text);                         
define statgraph pacman;                
mvar Yr remainSec unicodeSec xLoc Msg;       * Parameters: year, remaining seconds, Unicode secs, x-location (%), Happy New Year message;
begingraph / subpixel=on border=false datacolors=(black CXFFFF00) backgroundcolor=black pad=0in; * Like game, make "Pac-Man" yellow, with black "mouth";
layout region / border=false backgroundcolor=black outerpad=1in; * Provide some padding for text;
piechart category=slice response=pct / datalabelcontent=none centerfirstslice=true display=(fill); 
drawtext textattrs=(size=36pt color=CX00ff00 weight=bold) Yr / y=100 anchor=top widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Green year;
drawtext textattrs=(size=16pt color=CX00ff00 weight=bold) remainSec / y=5 anchor=bottom widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Green seconds remaining;
drawtext textattrs=(size=24pt color=CXFFFF00 weight=bold family="Arial Unicode MS") {unicode unicodeSec} / y=50.5 anchor=right x=xLoc widthunit=percent width=100 yspace=graphpercent xspace=graphpercent; * Yellow "dots" with seconds remaining;
drawtext textattrs=(size=24pt color=CX1919A6 weight=bold) Msg / justify=center y=50 anchor=center x=50 widthunit=percent width=50 yspace=graphpercent xspace=graphpercent; * Blue-ish Happy New Year message;
endlayout;
endgraph;
end; 
run;

ods _all_ close;                             * Animated GIF setup (pause for 1.5 secs on 1st frame);                       
options papersize=('3 in', '3 in') printerpath=gif animation=start nodate nonumber animduration=1.5 animloop=NO NOANIMOVERLAY;
ods printer file='/folders/myfolders/PacMan.gif'; * Animated GIF image filename;
ods graphics / height=3in width=3in imagefmt=gif antialias; 

%macro genframes;                            /* Generate 180-frame coundown (10 seconds * 18 frames/second) */ 
%do s=10 %to 1 %by -1;                       /* Generate set of 18 frames for each second in 10-second countdown */
  %let UnicodeSec="%scan(2460 2461 2462 2463 2464 2465 2466 2467 2468 2469, &amp;amp;s, ' ')"x; /* Unicode values for animated dots filled with remaining secs (10, 9, ..., 1) */
  %let RemainSec="Time Remaining: 00:%sysfunc(putN(&amp;amp;s,z2.))"; /* Display remaining secs at bottom of image */
  %do c=1 %to 18;                            /* Generate frames for one second interval */                           
    %let n=%eval((&amp;amp;s-1)*18+&amp;amp;c);              /* Determine pie chart # (used to select data generated earlier) */
    %let xLoc=%scan(100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66, &amp;amp;c, ' '); /* X-coordinates (%'s) for animated dot that show seconds remaining */
    proc sgrender data=slices(where=(n=&amp;amp;n)) template=pacman; /* Create pie charts! */
    run; 
    options animduration=.056;               /* Try to make total duration of 10 seconds-ish (180 images x .056 sec/image) */
  %end;
%end;
%mend;

%let Yr="2018";                              * Display old year (2018);
%let Msg="";                                 * No Happy New Year message until end;
%genframes;                                  * Issue macro call to generate 180 frames!;

options animduration=1.5;                    * Display "GAME OVER" frame at bottome of screen for 1.5 seconds;
%let RemainSec="GAME OVER";
proc sgrender data=slices(where=(n=180)) template=pacman; * Create pie chart|;
run;

options animduration=3;                      * For 3 seconds, show final frame...;
%let Yr="2019";                              * Display new year (2019) at top of screen;
%let Msg="HAPPY NEW YEAR!";                  * Display "HAPPY NEW YEAR" over pie chart in middle of screen; 
%let RemainSec="PRESS START";                * Display "PRESS START" at bottom of screen;
proc sgrender data=slices(where=(n=180)) template=pacman; * Create pie chart!;
run;

options printerpath=gif animation=stop;      * Animated GIF wrap-up;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 01:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/523903#M17597</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2018-12-31T01:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Fun With SAS ODS Graphics: Pac-Man inspired New Year's Eve 2019 Pie Chart countdown timer</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/523912#M17598</link>
      <description>&lt;P&gt;Nice work, TC.&amp;nbsp; Good to see a natural use case for CenterFirstSlice option.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 06:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/523912#M17598</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2018-12-31T06:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Fun With SAS ODS Graphics: Pac-Man inspired New Year's Eve 2019 Pie Chart countdown timer</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/524015#M17602</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ResemblesPacMan.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25930i5149A46C0F64EE3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="ResemblesPacMan.png" alt="ResemblesPacMan.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lest the above give people the idea it takes lots of code to render a pie chart with SAS, here's all it takes to recreate the famous &lt;A href="https://boingboing.net/2006/11/02/hilarious-piechartvi.html" target="_self"&gt;"Percentage of Chart Which Resembles Pac-Man" joke&lt;/A&gt; using the &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2018/11/26/the-sgpie-procedure/" target="_self"&gt;SGPIE procedure&lt;/A&gt; (pre-production) that's included with SAS 9.4M6. And, if you want more options, check out the &lt;A href="https://documentation.sas.com/?docsetId=grstatgraph&amp;amp;docsetTarget=n156iuqrtmfqk5n1f8yye5xkgkir.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;GTL PIECHART statement examples&lt;/A&gt;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Fun w/SAS ODS Graphics - Recreate "Percentage of Chart Which Resembles Pac-Man" pie chart joke w/PROC SGPIE
  Original circa-2006 joke at https://boingboing.net/2006/11/02/hilarious-piechartvi.html;

data slices;                         * Generate pie chart data;
input pct 1-3 slice $25.;
datalines;
80 Resembles Pac-Man
20 Does not resemble Pac-Man
;
proc sgpie data=slices;              * Create chart;
title "Percentage of Chart Which Resembles Pac-Man";
styleattrs datacolors=(yellow deeppink);
pie slice / response=pct startangle=180 datalabeldisplay=none sliceorder=data; 
label slice='';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Jan 2019 21:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-Pac-Man-inspired-New-Year-s-Eve-2019/m-p/524015#M17602</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2019-01-01T21:45:28Z</dc:date>
    </item>
  </channel>
</rss>

