<?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: How to display only one segment and total sum in stacked bar in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557057#M18104</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date$	X1	Y1	Sum;
cards;
jan 2 3 5
feb 5 1 6
mar 6 4 10
apr 3 4 7
;

data want;
set have;
array chars(*) x1 sum;
do i = 1 to dim(chars);
new=chars(i);
newc=vname(chars(i));
output;
end;
run;


proc sgplot data=want noborder;
  vbar date / response=new group=newc seglabel 
          baselineattrs=(thickness=0)
          outlineattrs=(color=cx3f3f3f);
  xaxis display=(nolabel noline noticks);
  yaxis display=(noline noticks) grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29300iFFDCB55D15EAF141/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2019 10:16:46 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2019-05-08T10:16:46Z</dc:date>
    <item>
      <title>How to display only one segment and total sum in stacked bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557054#M18103</link>
      <description>&lt;P&gt;I am using psglot (vbar ) to display stacked bar. I need to display only one segment label and sum in second.&lt;/P&gt;&lt;P&gt;When i try using calculated var(sum) the range is getting increased.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is sample data.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;date&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;X1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Y1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Sum&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;jan&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;feb&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;mar&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;10&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;apr&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;7&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 09:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557054#M18103</guid>
      <dc:creator>Ishaan</dc:creator>
      <dc:date>2019-05-08T09:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only one segment and total sum in stacked bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557057#M18104</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date$	X1	Y1	Sum;
cards;
jan 2 3 5
feb 5 1 6
mar 6 4 10
apr 3 4 7
;

data want;
set have;
array chars(*) x1 sum;
do i = 1 to dim(chars);
new=chars(i);
newc=vname(chars(i));
output;
end;
run;


proc sgplot data=want noborder;
  vbar date / response=new group=newc seglabel 
          baselineattrs=(thickness=0)
          outlineattrs=(color=cx3f3f3f);
  xaxis display=(nolabel noline noticks);
  yaxis display=(noline noticks) grid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29300iFFDCB55D15EAF141/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 10:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557057#M18104</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-08T10:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only one segment and total sum in stacked bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557066#M18105</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;This I am already getting. If you look into&amp;nbsp;Y axis,&amp;nbsp;the value has increased from 7 to 10 for apr data.&lt;/P&gt;&lt;P&gt;If you look into apr data. sum of x and y are 7. Y axis value should not increase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 11:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557066#M18105</guid>
      <dc:creator>Ishaan</dc:creator>
      <dc:date>2019-05-08T11:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only one segment and total sum in stacked bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557110#M18106</link>
      <description>&lt;P&gt;IN the data step from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;, I think this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; chars&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; x1 &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; chars&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; x1 y1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which will give the answer you expect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 13:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557110#M18106</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-05-08T13:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to display only one segment and total sum in stacked bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557121#M18108</link>
      <description>&lt;P&gt;Sorry, I misunderstood your request, so ignore my previous reply. To do what you want is a special case different from displaying the segment value using SEGLABEL. Your trying to show the cumulative values in the bar. To do this, you will need to do some data processing outside of SGPLOT. Here are the basic steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Transpose your data as described by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;, but using the X1 and Y1 variables.&lt;/P&gt;
&lt;P&gt;2. Pre-summarize your data using PROC SUMMARY or PROC MEANS.setting CLASS to be DATE and NEWC.&lt;/P&gt;
&lt;P&gt;3. Using that data, calculate the middle value in each segment (we'll call that var "middle"). At the same time, accumulate the sums for each bar segment and put it in a variable called "seglabel".&lt;/P&gt;
&lt;P&gt;4. Render using SGPLOT with something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=whatever;&lt;/P&gt;
&lt;P&gt;vbarparm category=date response=sumvar / group=newc;&lt;/P&gt;
&lt;P&gt;text x=date y=middle text=seglabel;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 14:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-display-only-one-segment-and-total-sum-in-stacked-bar/m-p/557121#M18108</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-05-08T14:07:14Z</dc:date>
    </item>
  </channel>
</rss>

