<?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: By The Light of the Halloween Moon in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-By-The-Light-of-the-Halloween-Moon/m-p/409001#M13989</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="witch.gif" style="width: 384px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16342iC2E54C93C3335833/image-size/large?v=v2&amp;amp;px=999" role="button" title="witch.gif" alt="witch.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another holiday, another installment of SAS ODS Graphics meets &lt;A href="http://www.math-aids.com/Graphing/Four_Quadrant_Graphing_Characters.html" target="_self"&gt;Math-Aids Four Quadrant Graphing Characters Worksheets&lt;/A&gt;. This one’s a GTL animated GIF remix of &lt;A href="https://communities.sas.com/t5/SAS-Analytics-U/Create-fun-Halloween-pics-with-math-and-SAS-University-Edition/m-p/232316" target="_self"&gt;an SGPLOT remix&lt;/A&gt; of &lt;A href="https://blogs.sas.com/content/sastraining/2015/10/26/create-halloween-images-and-learn-sas-basics/" target="_self"&gt;a 2015 SAS/GRAPH Halloween Witch&lt;/A&gt;&amp;nbsp;(ever notice how SAS visualizations &lt;A href="https://twitter.com/cjdinger/status/925065268392538112" target="_self"&gt;come in threes&lt;/A&gt;?). Happy Halloween, kids!&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: Animated witch from points in math-aids.com graphing worksheet;

data Witch(keep=shapeID shapenum x y polyX polyY xmin xmax ymin ymax);
length shapeID $ 20. shapenum x y 8;
retain shapeID shapenum;                                
infile cards dsd dlm=',' truncover;  * "Cards" contain points to plot from math-aids.com;
input;
put "i=" _infile_;
if _infile_=:'Shape' then do;
  shapeID=_infile_;
  shapenum=scan(shapeID,2);
  end;
else
  do;
    i=1;
    do while(scan(_infile_, i, ' ,')^='');
      x=scan(_infile_, i, ', ');
      y=scan(_infile_, i+1, ', ');
      i+2;                                      
      polyX=x;                   * Use polygons to color witch shapes on final slide;
      polyY=y;
      xmin=-20; xmax=20;                  * "Dummy" points for consistent image size;
      ymin=-20; ymax=20;
      output;
    end;
  end;
cards;
Shape 1
-1,11 1,8 2,6 1.5,5.5 2,5 2.5,5.5 3,5 2.5,4.5 1,4.5 0,4
-1,3 -2,1 -3,-1 -3,-2 -2.5,-2.5 -1,-2 -1,-2.5 -2,-3 -4,-3.5
-4.5,-3.5 -5,-3 -6.5,-4 -13,-3 -13.5,-5 -13,-7 -12,-8.5 -10,-7
-7,-5 -6,-4.5 -4.5,-5 -4.5,-4.5 -3.5,-4 -1.5,-3.5 -1,-4.5 -1.5,-5
-2,-5 -2.5,-4.5 -3.5,-4.5 -4.5,-6 -5.5,-8 -4,-7 -2,-6 2,-5.5
4,-4.5 4.5,-4 4,-3.5 3.5,-2.5 7,-2 13,-0.5 13,0.5 11,0 9,-0.5
6,-0.5 4,0 3.5,1 3.5,3 5,3 4.5,4 5.5,3.5 6,4.5 7,5 6.5,5.5
5.5,6 5,7 5.5,7.5 5.5,8 5,7.5 4.5,7.5 4,8 2,9 -1,11
Shape 2
2.5,-0.5 4,-1.5 2.5,-2 2.5,-.5
;
                                          * Create annotation data set to draw lines;
data line(keep=function drawspace x1 y1 x2 y2 polyX polyY linecolor);
set witch;
by shapeID notsorted;
function='line';
drawspace='datavalue';
x1=lag(x);
y1=lag(y);
x2=x;
y2=y;
linecolor='black';
if ^first.shapeID;

%macro gentemplate(final=Y);                                      * Draw the witch!;
proc template;
define statgraph witchtemplate;
  begingraph
  %if &amp;amp;final=Y %then / backgroundcolor=black;;        * Last slide? Paint it black!;
    dynamic linenum;
    layout overlayequated / 
      walldisplay=none 
      xaxisopts=(display=none offsetmin=0.001 offsetmax=0.001 viewmin=-20 viewmax=20)
      yaxisopts=(display=none offsetmin=0.001 offsetmax=0.001 viewmin=-20 viewmax=20);
    scatterplot x=x y=y / markerattrs=(size=0);
    scatterplot x=xmin y=ymin / markerattrs=(size=0);
    scatterplot x=xmax y=ymax / markerattrs=(size=0);
    %if &amp;amp;final=Y %then %do;           * Add orange circle, flood-fill witch (black);
      ellipseparm semimajor=18 semiminor=18 xorigin=0 yorigin=0 slope=0 / 
                  display=all outlineattrs=(color=black) fillattrs=(color=orange);
      polygonplot x=PolyX y=PolyY id=ShapeID / 
                  colorresponse=shapenum colormodel=(black orange)
                  display=(fill) label=none outlineattrs=(color=black);
    %end;                                                             * Line counter;
    entry halign=right linenum / valign=bottom textattrs=(size=32 weight=bold color=lightgray);
    annotate;
    endlayout;
  endgraph;
end;
run;
%mend;

* Create animated GIF with one incremental plot for each line;

ods _all_ close;
options papersize=('4 in', '4 in') printerpath=gif animation=start 
        nodate nonumber animduration=1.8 animloop=YES NOANIMOVERLAY;
ods printer file='/folders/myfolders/witch.gif';
ods graphics / width=4in height=4in imagefmt=GIF;

%macro drawlines;
proc sql noprint;
select count(*) into :numlines from line;
quit;                   

%gentemplate(final=Y);                          * Display final image before drawing lines;
options animduration=1.8;
proc sgrender data=Witch template=witchtemplate sganno=line;
dynamic linenum=" "; 

options animduration=.04;                       * Line-by-line drawing;
%gentemplate(final=N); 
%do l=1 %to &amp;amp;numlines;                          * Draw incremental image with lines thus far;  
  proc sgrender data=Witch template=witchtemplate sganno=line(obs=&amp;amp;l);
  dynamic linenum="&amp;amp;l";
%end; 
run; 
%mend;

%drawlines;
options printerpath=gif animation=stop;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Oct 2017 06:26:17 GMT</pubDate>
    <dc:creator>tc</dc:creator>
    <dc:date>2017-10-31T06:26:17Z</dc:date>
    <item>
      <title>Fun With #SAS ODS Graphics: By The Light of the Halloween Moon</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-By-The-Light-of-the-Halloween-Moon/m-p/409001#M13989</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="witch.gif" style="width: 384px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16342iC2E54C93C3335833/image-size/large?v=v2&amp;amp;px=999" role="button" title="witch.gif" alt="witch.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another holiday, another installment of SAS ODS Graphics meets &lt;A href="http://www.math-aids.com/Graphing/Four_Quadrant_Graphing_Characters.html" target="_self"&gt;Math-Aids Four Quadrant Graphing Characters Worksheets&lt;/A&gt;. This one’s a GTL animated GIF remix of &lt;A href="https://communities.sas.com/t5/SAS-Analytics-U/Create-fun-Halloween-pics-with-math-and-SAS-University-Edition/m-p/232316" target="_self"&gt;an SGPLOT remix&lt;/A&gt; of &lt;A href="https://blogs.sas.com/content/sastraining/2015/10/26/create-halloween-images-and-learn-sas-basics/" target="_self"&gt;a 2015 SAS/GRAPH Halloween Witch&lt;/A&gt;&amp;nbsp;(ever notice how SAS visualizations &lt;A href="https://twitter.com/cjdinger/status/925065268392538112" target="_self"&gt;come in threes&lt;/A&gt;?). Happy Halloween, kids!&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: Animated witch from points in math-aids.com graphing worksheet;

data Witch(keep=shapeID shapenum x y polyX polyY xmin xmax ymin ymax);
length shapeID $ 20. shapenum x y 8;
retain shapeID shapenum;                                
infile cards dsd dlm=',' truncover;  * "Cards" contain points to plot from math-aids.com;
input;
put "i=" _infile_;
if _infile_=:'Shape' then do;
  shapeID=_infile_;
  shapenum=scan(shapeID,2);
  end;
else
  do;
    i=1;
    do while(scan(_infile_, i, ' ,')^='');
      x=scan(_infile_, i, ', ');
      y=scan(_infile_, i+1, ', ');
      i+2;                                      
      polyX=x;                   * Use polygons to color witch shapes on final slide;
      polyY=y;
      xmin=-20; xmax=20;                  * "Dummy" points for consistent image size;
      ymin=-20; ymax=20;
      output;
    end;
  end;
cards;
Shape 1
-1,11 1,8 2,6 1.5,5.5 2,5 2.5,5.5 3,5 2.5,4.5 1,4.5 0,4
-1,3 -2,1 -3,-1 -3,-2 -2.5,-2.5 -1,-2 -1,-2.5 -2,-3 -4,-3.5
-4.5,-3.5 -5,-3 -6.5,-4 -13,-3 -13.5,-5 -13,-7 -12,-8.5 -10,-7
-7,-5 -6,-4.5 -4.5,-5 -4.5,-4.5 -3.5,-4 -1.5,-3.5 -1,-4.5 -1.5,-5
-2,-5 -2.5,-4.5 -3.5,-4.5 -4.5,-6 -5.5,-8 -4,-7 -2,-6 2,-5.5
4,-4.5 4.5,-4 4,-3.5 3.5,-2.5 7,-2 13,-0.5 13,0.5 11,0 9,-0.5
6,-0.5 4,0 3.5,1 3.5,3 5,3 4.5,4 5.5,3.5 6,4.5 7,5 6.5,5.5
5.5,6 5,7 5.5,7.5 5.5,8 5,7.5 4.5,7.5 4,8 2,9 -1,11
Shape 2
2.5,-0.5 4,-1.5 2.5,-2 2.5,-.5
;
                                          * Create annotation data set to draw lines;
data line(keep=function drawspace x1 y1 x2 y2 polyX polyY linecolor);
set witch;
by shapeID notsorted;
function='line';
drawspace='datavalue';
x1=lag(x);
y1=lag(y);
x2=x;
y2=y;
linecolor='black';
if ^first.shapeID;

%macro gentemplate(final=Y);                                      * Draw the witch!;
proc template;
define statgraph witchtemplate;
  begingraph
  %if &amp;amp;final=Y %then / backgroundcolor=black;;        * Last slide? Paint it black!;
    dynamic linenum;
    layout overlayequated / 
      walldisplay=none 
      xaxisopts=(display=none offsetmin=0.001 offsetmax=0.001 viewmin=-20 viewmax=20)
      yaxisopts=(display=none offsetmin=0.001 offsetmax=0.001 viewmin=-20 viewmax=20);
    scatterplot x=x y=y / markerattrs=(size=0);
    scatterplot x=xmin y=ymin / markerattrs=(size=0);
    scatterplot x=xmax y=ymax / markerattrs=(size=0);
    %if &amp;amp;final=Y %then %do;           * Add orange circle, flood-fill witch (black);
      ellipseparm semimajor=18 semiminor=18 xorigin=0 yorigin=0 slope=0 / 
                  display=all outlineattrs=(color=black) fillattrs=(color=orange);
      polygonplot x=PolyX y=PolyY id=ShapeID / 
                  colorresponse=shapenum colormodel=(black orange)
                  display=(fill) label=none outlineattrs=(color=black);
    %end;                                                             * Line counter;
    entry halign=right linenum / valign=bottom textattrs=(size=32 weight=bold color=lightgray);
    annotate;
    endlayout;
  endgraph;
end;
run;
%mend;

* Create animated GIF with one incremental plot for each line;

ods _all_ close;
options papersize=('4 in', '4 in') printerpath=gif animation=start 
        nodate nonumber animduration=1.8 animloop=YES NOANIMOVERLAY;
ods printer file='/folders/myfolders/witch.gif';
ods graphics / width=4in height=4in imagefmt=GIF;

%macro drawlines;
proc sql noprint;
select count(*) into :numlines from line;
quit;                   

%gentemplate(final=Y);                          * Display final image before drawing lines;
options animduration=1.8;
proc sgrender data=Witch template=witchtemplate sganno=line;
dynamic linenum=" "; 

options animduration=.04;                       * Line-by-line drawing;
%gentemplate(final=N); 
%do l=1 %to &amp;amp;numlines;                          * Draw incremental image with lines thus far;  
  proc sgrender data=Witch template=witchtemplate sganno=line(obs=&amp;amp;l);
  dynamic linenum="&amp;amp;l";
%end; 
run; 
%mend;

%drawlines;
options printerpath=gif animation=stop;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 06:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-With-SAS-ODS-Graphics-By-The-Light-of-the-Halloween-Moon/m-p/409001#M13989</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2017-10-31T06:26:17Z</dc:date>
    </item>
  </channel>
</rss>

