<?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: Vertical bar using sgplot and color by cohort in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826432#M326437</link>
    <description>&lt;P&gt;Try adding option "&amp;nbsp;groupdisplay=cluster "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc summary data=sashelp.heart nway;
class ageatstart;
var weight;
output out=have sum=;
run;

data have;
 set have;
 if ageatstart&amp;lt;30 then flag=1;
  else if ageatstart&amp;lt;50 then flag=2;
   else flag=3;
run;

proc sgplot data=have;
vbarparm category=ageatstart response=weight/group=flag  datalabel=weight groupdisplay=cluster;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1659360258895.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73970i042EFF2D0DE3BA3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1659360258895.png" alt="Ksharp_0-1659360258895.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 13:24:16 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-08-01T13:24:16Z</dc:date>
    <item>
      <title>Vertical bar using sgplot and color by cohort</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826418#M326427</link>
      <description>&lt;P&gt;Team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used the following code to and got the following plot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=data;&lt;/P&gt;&lt;P&gt;vbar n/response=result&amp;nbsp; datalabel=result_1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sairampulipati_0-1659355442973.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73967iDEE01DC4E22BAA81/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sairampulipati_0-1659355442973.png" alt="Sairampulipati_0-1659355442973.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now I wanted to color those bars by cohort, if I am using the same code by adding after group=cohort after vbar n / then colors are getting applied but unfortunately datalabels are not getting applied. Can anyone help me with that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=data;&lt;/P&gt;&lt;P&gt;vbar n/ group=cohort&amp;nbsp; response=result&amp;nbsp; datalabel=result_1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sairampulipati_1-1659355718700.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73968iE33BACBE1603CBCB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sairampulipati_1-1659355718700.png" alt="Sairampulipati_1-1659355718700.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 12:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826418#M326427</guid>
      <dc:creator>Sairampulipati</dc:creator>
      <dc:date>2022-08-01T12:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical bar using sgplot and color by cohort</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826432#M326437</link>
      <description>&lt;P&gt;Try adding option "&amp;nbsp;groupdisplay=cluster "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc summary data=sashelp.heart nway;
class ageatstart;
var weight;
output out=have sum=;
run;

data have;
 set have;
 if ageatstart&amp;lt;30 then flag=1;
  else if ageatstart&amp;lt;50 then flag=2;
   else flag=3;
run;

proc sgplot data=have;
vbarparm category=ageatstart response=weight/group=flag  datalabel=weight groupdisplay=cluster;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1659360258895.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73970i042EFF2D0DE3BA3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1659360258895.png" alt="Ksharp_0-1659360258895.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 13:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826432#M326437</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-01T13:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical bar using sgplot and color by cohort</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826433#M326438</link>
      <description>Thank you so much.</description>
      <pubDate>Mon, 01 Aug 2022 13:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vertical-bar-using-sgplot-and-color-by-cohort/m-p/826433#M326438</guid>
      <dc:creator>Sairampulipati</dc:creator>
      <dc:date>2022-08-01T13:31:25Z</dc:date>
    </item>
  </channel>
</rss>

