<?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 Re: Adding sample size N to stacked bar chart summing to 100% in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645841#M19851</link>
    <description>&lt;P&gt;I suggest you use &lt;A href="https://go.documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=n0ka2y1m7pmaqdn1ijnwzp8jljoc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;the YAXISTABLE statement&lt;/A&gt; to display the sample size and any other statistics.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2014/11/02/bar-with-statistics/" target="_self"&gt;Here's an example.&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2020 12:09:23 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-05-07T12:09:23Z</dc:date>
    <item>
      <title>Adding sample size N to stacked bar chart summing to 100%</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645766#M19850</link>
      <description>&lt;P&gt;Hi, I am creating a horizontal stacked bar chart with percentage on the x-axis and supply item on the y-axis where each segment of the bar shows on-hand supply of that item (length of time before factory runs out of item, 4 groups =&amp;nbsp;0 days, 1 day, 2 days, 3 days). Reporting of supply data is optional, so different supply&amp;nbsp;items may have different sample sizes. I would like to include the sample size for the number of factories represented in each full bar (sum the number of factories across the 4 possible segments of each bar). Because this is a stacked bar chart with 4 groups included in each bar, the datalabel option displays 4 columns summarizing sample size for each. I tried to force SAS to include sample size for just one of the 4 segments by setting 3 values to missing but missing values are still displayed (see photo). Based on the photo shown, I would like to keep the "0 days" column (and will rename "Number of Factories"). Is there a way to 1) suppress datalabel columns where values are "." or 2) apply a where statement to datalabel (such as, datalabel=num_factories(where supply_length='0 days') or 3)&amp;nbsp;create and display another&amp;nbsp;summary variable that sums supply_count across the 4 segments (supply_count/num_factories=percent). The code used to create the example chart is displayed here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;sgplot&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=test &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;dattrmap&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=attrmap; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;hbar&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; supply / &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;response&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=percent &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;group&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=supply_length &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;groupdisplay&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=stack &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;attrid&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=myid &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;datalabel&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=fac_count &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;datalabelpos&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=right &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;nooutline&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;keylegend&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; /&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;title&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'On-hand supply availability'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;xaxis&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;grid&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;values&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; to &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; by &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;label&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"Percentage"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;yaxis&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;discreteorder&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=data &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;label&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"Supply Item"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Supply availability stacked bar chart example.jpg" style="width: 641px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39146iE5E6E937361D1EFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Supply availability stacked bar chart example.jpg" alt="Supply availability stacked bar chart example.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Dataset example stacked bar.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39147i6339A9F57DDFAD5F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dataset example stacked bar.jpg" alt="Dataset example stacked bar.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 02:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645766#M19850</guid>
      <dc:creator>Clary_CO</dc:creator>
      <dc:date>2020-05-07T02:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sample size N to stacked bar chart summing to 100%</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645841#M19851</link>
      <description>&lt;P&gt;I suggest you use &lt;A href="https://go.documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=n0ka2y1m7pmaqdn1ijnwzp8jljoc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;the YAXISTABLE statement&lt;/A&gt; to display the sample size and any other statistics.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2014/11/02/bar-with-statistics/" target="_self"&gt;Here's an example.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 12:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645841#M19851</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-07T12:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sample size N to stacked bar chart summing to 100%</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645862#M19852</link>
      <description>&lt;P&gt;Thank you! Just tried the yaxistable statement with nomissingchar option and get the N I wanted (thanks!), however, the legend disappears and I get the error message "DISCRETELEGEND statement with DISPLAYCLIPPED=FALSE is getting clipped. The legend will not be drawn." I tried adding the discretelegend option and now have 2 legends displayed. Do you know how to maintain the original legend on bottom once the yaxistable statement is added?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Legend.jpg" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39159i87B9340F22520344/image-size/large?v=v2&amp;amp;px=999" role="button" title="Legend.jpg" alt="Legend.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 13:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645862#M19852</guid>
      <dc:creator>Clary_CO</dc:creator>
      <dc:date>2020-05-07T13:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sample size N to stacked bar chart summing to 100%</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645867#M19853</link>
      <description>&lt;P&gt;Yes. Read the documentation for the KEYLEGEND statement. Use the NAME= option to specify the statements that you want to appear in the legend. You might also need to use the NOAUTOLEGEND option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot NOAUTOLEGEND ...;
hbar supply / name="bar" ...;

keylegend "bar" / ...;p
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 May 2020 13:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-sample-size-N-to-stacked-bar-chart-summing-to-100/m-p/645867#M19853</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-05-07T13:18:34Z</dc:date>
    </item>
  </channel>
</rss>

