<?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 w/SAS ODS Graphics: Stars-and-Stripes-Forever Donut Charts in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475504#M16426</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ParadeChart.png" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21578i961252C0804C5F8F/image-size/large?v=v2&amp;amp;px=999" role="button" title="ParadeChart.png" alt="ParadeChart.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After reading &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13856"&gt;@Jay54&lt;/a&gt;'s &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2018/06/25/pie-charts-redux/" target="_self"&gt;Pie Charts Redux&lt;/A&gt;, spotting &lt;A href="https://www.target.com/p/10-25-10ct-flag-print-dinner-paper-plate/-/A-53131822" target="_self"&gt;Flag Print Dinner Paper Plates&lt;/A&gt; at Target, and seeing &lt;A href="https://thefirstyearblog.com/american-flag-donuts/" target="_self"&gt;American Flag Doughnuts&lt;/A&gt;, what was I supposed to do - not try to create a (two-outcome) Stars-and-Stripes-Forever Donut Chart macro? Have a nice 4th of July!&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, Stars-and-Stripes-Forever Donut Charts;

%macro RedWhiteAndBlueDonut(YES=, DONUTHOLE=);        /* Specify % for Yes wedge and text to apppear in center */
ods graphics on / height=5in width=5in;  
data stars(keep=x y);                                 /* Generate x/y points for white stars on blue background */
do y=-15 to 15;                                       /* 31 rows of 31 stars */                                       
  do x=-15 to 15;
    output;                                           
  end;
end;    

data stripes(keep=spolygon sx sy red);                /* Generate x/y points for polygons for stripes */
pi=constant('pi');
pctyes=&amp;amp;YES/100;                                      /* Convert to decimal */

if pctyes&amp;lt;.4999 then do;                              /* Stripes for top half of circle if needed (YES&amp;lt;50%) */
  red=1;                                              /* Alternate red and white stripes */
  do stripe=.25 to 16.25 by 1;                        /* Top semicirlce, center YES wedge at top middle */
    StartRadians=90/360*2*pi-.50*pctyes*2*pi;         /* Need to create diagonal edges for polygon stripes along wedges */
    spolygon+1;                                       /* Stripe plygons for left side of NO wedge */
    sy=stripe;          sx=-15;   output;             /* Upper left x/y point */
    sy=stripe;          sx=-(abs(sy)/sin(startradians))*cos(startradians);  output; /* Upper right x/y point */
    sy=max(stripe-1,0); sx=-(abs(sy)/sin(startradians))*cos(startradians);  output; /* Lower right x/y point */
    sy=max(stripe-1,0); sx=-15; output;               /* Lower left x/y point */
    spolygon+1;                                       /* Stripe polygons for right side of NO wedge */
    sy=stripe;          sx=(abs(sy)/sin(startradians))*cos(startradians);   output; /* Upper left x/y point */
    sy=stripe;          sx=15;  output;               /* Upper right x/y point */
    sy=max(stripe-1,0); sx=15;  output;               /* Lower right x/y point */
    sy=max(stripe-1,0); sx=(abs(sy)/sin(startradians))*cos(startradians); output; /* Lower left x/y point */  
    red=^red;                                         /* Alternate red and white stripes */
  end;
end;

lowerwedge=min(1-pctyes,.49999);                      /* Stripes for lower half of circle if needed (YES&amp;lt;100%) */                   
if lowerwedge&amp;gt;0 then do;
  red=0;                                              /* Alternate red and white stripes */
  do stripe=-14.75 to .25 by 1;                       /* Bottom semicirlce, center NO wedge at bottom middle */
    StartRadians=90/360*2*pi-.50*lowerwedge*2*pi;     /* Need to create diagonal edges for polygon stripes along wedges */ 
    spolygon+1;                                       /* Stripe polygons for NO wedge */
    sy=min(stripe,0); sx=-(abs(sy)/sin(startradians))*cos(startradians); output; /* Upper left x/y point */
    sy=min(stripe,0); sx=-sx;  output;                /* Upper right x/y point */
    sy=(stripe-1);    sx=(abs(sy)/sin(startradians))*cos(startradians);  output; /* Lower right x/y point */
    sy=(stripe-1);    sx=-sx; output;                 /* Lower left x/y point */
    red=^red;
  end;
  end;

data text;                                            /* Text for donut hole */
tx=0; ty=0; text="&amp;amp;DonutHole"; output;

data StarsAndStripes;                                 /* Combine stars, stripes, text */
set stars stripes text;

data mapStripes;                                      /* Attribute map to assign colors to stripes */
ID="Red"; value=1; linecolor="CXB22234"; fillcolor="CXB22234"; output;
ID="Red"; value=0; linecolor="WHITE"; fillcolor="WHITE"; output;

                                                     /* Draw stars-and-stripes-forever donut chart! */
proc sgplot data=StarsAndStripes noautolegend noborder pad=0 nowall dattrmap=mapStripes;
styleattrs backcolor=CX3C3B6E;                       /* "Old Glory Blue" background color */
symbolchar name=uniStar char='2605'x;                /* Unicode value for 5-pointed star */
xaxis display=none offsetmin=0 offsetmax=0 values=(-15 15); * Supress axes display;
yaxis display=none offsetmin=0 offsetmax=0 values=(-15 15);
scatter x=x y=y / markerattrs=(symbol=unistar color=CXFFFFFF size=18pt); * Stars (White);   
polygon x=sx y=sy id=spolygon / group=red fill nooutline attrid=Red;  * Stripes (Red &amp;amp; White);
ellipseparm semimajor=9 semiminor=9 / slope=0        /* Inner circle of donut (white) */
       xorigin=0 yorigin=0 fill fillattrs=(color=white);
ellipseparm semimajor=9 semiminor=9 / slope=0        /* Inner circle line */
       xorigin=0 yorigin=0 lineattrs=(color=black thickness=1pt);       
text x=tx y=ty text=text / splitchar='*' strip splitpolicy=splitalways textattrs=(size=16pt weight=bold); * Donut hole text;
ellipseparm semimajor=20 semiminor=20 / slope=0      /* Outer circle with really thick line to "crop" stars/stripes image into circle */
       xorigin=0 yorigin=0 lineattrs=(color=white thickness=128pt);       
run;
%mend;

* Fun Facts about the 4th of July: themuse.com/advice/34-fun-facts-about-the-4th-of-july;

%RedWhiteAndBlueDonut(YES=32, DONUTHOLE=WATCH*4TH OF JULY PARADE?*YES: 32%  NO: 68%);
%RedWhiteAndBlueDonut(YES=63, DONUTHOLE=ATTEND*FIREWORKS DISPLAY?*YES: 63%  NO: 37%);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FireworksChart.png" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21580i351C35BD3CF5E4BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="FireworksChart.png" alt="FireworksChart.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jul 2018 23:15:07 GMT</pubDate>
    <dc:creator>tc</dc:creator>
    <dc:date>2018-07-04T23:15:07Z</dc:date>
    <item>
      <title>Fun w/SAS ODS Graphics: Stars-and-Stripes-Forever Donut Charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475504#M16426</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ParadeChart.png" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21578i961252C0804C5F8F/image-size/large?v=v2&amp;amp;px=999" role="button" title="ParadeChart.png" alt="ParadeChart.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After reading &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13856"&gt;@Jay54&lt;/a&gt;'s &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2018/06/25/pie-charts-redux/" target="_self"&gt;Pie Charts Redux&lt;/A&gt;, spotting &lt;A href="https://www.target.com/p/10-25-10ct-flag-print-dinner-paper-plate/-/A-53131822" target="_self"&gt;Flag Print Dinner Paper Plates&lt;/A&gt; at Target, and seeing &lt;A href="https://thefirstyearblog.com/american-flag-donuts/" target="_self"&gt;American Flag Doughnuts&lt;/A&gt;, what was I supposed to do - not try to create a (two-outcome) Stars-and-Stripes-Forever Donut Chart macro? Have a nice 4th of July!&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, Stars-and-Stripes-Forever Donut Charts;

%macro RedWhiteAndBlueDonut(YES=, DONUTHOLE=);        /* Specify % for Yes wedge and text to apppear in center */
ods graphics on / height=5in width=5in;  
data stars(keep=x y);                                 /* Generate x/y points for white stars on blue background */
do y=-15 to 15;                                       /* 31 rows of 31 stars */                                       
  do x=-15 to 15;
    output;                                           
  end;
end;    

data stripes(keep=spolygon sx sy red);                /* Generate x/y points for polygons for stripes */
pi=constant('pi');
pctyes=&amp;amp;YES/100;                                      /* Convert to decimal */

if pctyes&amp;lt;.4999 then do;                              /* Stripes for top half of circle if needed (YES&amp;lt;50%) */
  red=1;                                              /* Alternate red and white stripes */
  do stripe=.25 to 16.25 by 1;                        /* Top semicirlce, center YES wedge at top middle */
    StartRadians=90/360*2*pi-.50*pctyes*2*pi;         /* Need to create diagonal edges for polygon stripes along wedges */
    spolygon+1;                                       /* Stripe plygons for left side of NO wedge */
    sy=stripe;          sx=-15;   output;             /* Upper left x/y point */
    sy=stripe;          sx=-(abs(sy)/sin(startradians))*cos(startradians);  output; /* Upper right x/y point */
    sy=max(stripe-1,0); sx=-(abs(sy)/sin(startradians))*cos(startradians);  output; /* Lower right x/y point */
    sy=max(stripe-1,0); sx=-15; output;               /* Lower left x/y point */
    spolygon+1;                                       /* Stripe polygons for right side of NO wedge */
    sy=stripe;          sx=(abs(sy)/sin(startradians))*cos(startradians);   output; /* Upper left x/y point */
    sy=stripe;          sx=15;  output;               /* Upper right x/y point */
    sy=max(stripe-1,0); sx=15;  output;               /* Lower right x/y point */
    sy=max(stripe-1,0); sx=(abs(sy)/sin(startradians))*cos(startradians); output; /* Lower left x/y point */  
    red=^red;                                         /* Alternate red and white stripes */
  end;
end;

lowerwedge=min(1-pctyes,.49999);                      /* Stripes for lower half of circle if needed (YES&amp;lt;100%) */                   
if lowerwedge&amp;gt;0 then do;
  red=0;                                              /* Alternate red and white stripes */
  do stripe=-14.75 to .25 by 1;                       /* Bottom semicirlce, center NO wedge at bottom middle */
    StartRadians=90/360*2*pi-.50*lowerwedge*2*pi;     /* Need to create diagonal edges for polygon stripes along wedges */ 
    spolygon+1;                                       /* Stripe polygons for NO wedge */
    sy=min(stripe,0); sx=-(abs(sy)/sin(startradians))*cos(startradians); output; /* Upper left x/y point */
    sy=min(stripe,0); sx=-sx;  output;                /* Upper right x/y point */
    sy=(stripe-1);    sx=(abs(sy)/sin(startradians))*cos(startradians);  output; /* Lower right x/y point */
    sy=(stripe-1);    sx=-sx; output;                 /* Lower left x/y point */
    red=^red;
  end;
  end;

data text;                                            /* Text for donut hole */
tx=0; ty=0; text="&amp;amp;DonutHole"; output;

data StarsAndStripes;                                 /* Combine stars, stripes, text */
set stars stripes text;

data mapStripes;                                      /* Attribute map to assign colors to stripes */
ID="Red"; value=1; linecolor="CXB22234"; fillcolor="CXB22234"; output;
ID="Red"; value=0; linecolor="WHITE"; fillcolor="WHITE"; output;

                                                     /* Draw stars-and-stripes-forever donut chart! */
proc sgplot data=StarsAndStripes noautolegend noborder pad=0 nowall dattrmap=mapStripes;
styleattrs backcolor=CX3C3B6E;                       /* "Old Glory Blue" background color */
symbolchar name=uniStar char='2605'x;                /* Unicode value for 5-pointed star */
xaxis display=none offsetmin=0 offsetmax=0 values=(-15 15); * Supress axes display;
yaxis display=none offsetmin=0 offsetmax=0 values=(-15 15);
scatter x=x y=y / markerattrs=(symbol=unistar color=CXFFFFFF size=18pt); * Stars (White);   
polygon x=sx y=sy id=spolygon / group=red fill nooutline attrid=Red;  * Stripes (Red &amp;amp; White);
ellipseparm semimajor=9 semiminor=9 / slope=0        /* Inner circle of donut (white) */
       xorigin=0 yorigin=0 fill fillattrs=(color=white);
ellipseparm semimajor=9 semiminor=9 / slope=0        /* Inner circle line */
       xorigin=0 yorigin=0 lineattrs=(color=black thickness=1pt);       
text x=tx y=ty text=text / splitchar='*' strip splitpolicy=splitalways textattrs=(size=16pt weight=bold); * Donut hole text;
ellipseparm semimajor=20 semiminor=20 / slope=0      /* Outer circle with really thick line to "crop" stars/stripes image into circle */
       xorigin=0 yorigin=0 lineattrs=(color=white thickness=128pt);       
run;
%mend;

* Fun Facts about the 4th of July: themuse.com/advice/34-fun-facts-about-the-4th-of-july;

%RedWhiteAndBlueDonut(YES=32, DONUTHOLE=WATCH*4TH OF JULY PARADE?*YES: 32%  NO: 68%);
%RedWhiteAndBlueDonut(YES=63, DONUTHOLE=ATTEND*FIREWORKS DISPLAY?*YES: 63%  NO: 37%);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FireworksChart.png" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21580i351C35BD3CF5E4BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="FireworksChart.png" alt="FireworksChart.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 23:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475504#M16426</guid>
      <dc:creator>tc</dc:creator>
      <dc:date>2018-07-04T23:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/SAS ODS Graphics: Stars-and-Stripes-Forever Donut Charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475506#M16427</link>
      <description>&lt;P&gt;I love how you shared your inspiration for the Stars-and-Stripes donut charts and the very cool code!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Always impressed with your SAS ODS Graphics fun. &lt;img id="robothappy" class="emoticon emoticon-robothappy" src="https://communities.sas.com/i/smilies/16x16_robot-happy.png" alt="Robot Happy" title="Robot Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for sharing - especially on your holiday!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Michelle&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 00:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475506#M16427</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2018-07-05T00:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/SAS ODS Graphics: Stars-and-Stripes-Forever Donut Charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475514#M16428</link>
      <description>&lt;P&gt;I wish everyone, including myself, commented their code this well!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 03:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/475514#M16428</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-05T03:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fun w/SAS ODS Graphics: Stars-and-Stripes-Forever Donut Charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/571112#M18407</link>
      <description>&lt;P&gt;SAS giving us a way to &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/SAS-should-support-double-slash-comments-at-the-right-of-a-code/idi-p/274846" target="_self"&gt;add end-of-line comments&lt;/A&gt; would definitely help better commenting.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 22:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Fun-w-SAS-ODS-Graphics-Stars-and-Stripes-Forever-Donut-Charts/m-p/571112#M18407</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-03T22:35:42Z</dc:date>
    </item>
  </channel>
</rss>

