<?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 do I display labels only on specfied bars in customized bar chart? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630166#M186512</link>
    <description>&lt;P&gt;Don't use Amount as the label. Create a label variable that is either a formatted value of Amount or is blank.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test2;
	set test;
	retain label_position;
	by name; 
	if first.name then do;
		label_position=amount;
		end;
	else do; 
		label_position+amount;
		end;
   if Type="." then MyLabel="     ";
   else MyLabel=put(Amount, Best5.);

run;

proc sgplot data=Test2;
  styleattrs datacolors=(orange green red white);
  vbarparm category=Name response=Amount / group=Type nooutline;
    *seglabel seglabelfitpolicy=none seglabelattrs=(weight=bold);
  text x=name y=label_position text=MyLabel; 
  xaxis display=(nolabel);
  yaxis labelpos=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Mar 2020 17:13:17 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-03-06T17:13:17Z</dc:date>
    <item>
      <title>How do I display labels only on specfied bars in customized bar chart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630165#M186511</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;recently I've found a post with a way to create a customized bar chart:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Creating-a-customized-waterfall-graph/m-p/326830#M72859&amp;nbsp;" target="_self"&gt;https://communities.sas.com/t5/SAS-Programming/Creating-a-customized-waterfall-graph/m-p/326830#M72859&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;mentioned, that you can add labels to bars using TEXT statement, this is my modified code and output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test;
length Name $13. Type $1.; 
input Name $13. Amount Type $1.;
if missing(type) then type=".";
datalines;
CY15           97.9 A
CY15           35.1 B
CY15           38.9 C
CY16          102.0 A
CY16           43.2 B
CY16           44.6 C
CY17          106.8 A
CY17           49.9 B
CY17           46.7 C
Co. A:Row     203.4 .
Co. A:Row       6.0 A
Co. A:US      209.6 .
Co. A:US        5.5 A
Co. A:Dom     215.1 .
Co. A:Dom       3.0 A
Co. B:Dom+Int 218.1 .
Co. B:Dom+Int   9.6 B
Co. C:Dom+Int 227.7 .
Co. C:Dom+Int   4.1 C
CY18          121.3 A
CY18           59.5 B
CY18           50.8 C
;

proc sort data=test;
	by name;
run; 

data test2;
	set test;
	retain label_position;
	by name; 
	if first.name then do;
		label_position=amount;
		end;
	else do; 
		label_position+amount;
		end;
run;

proc sgplot data=Test2;
  styleattrs datacolors=(orange green red white);
  vbarparm category=Name response=Amount / group=Type nooutline;
    *seglabel seglabelfitpolicy=none seglabelattrs=(weight=bold);
  text x=name y=label_position text=Amount; 
  xaxis display=(nolabel);
  yaxis labelpos=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="graph.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36641iC8601742DCD2B14A/image-size/large?v=v2&amp;amp;px=999" role="button" title="graph.JPG" alt="graph.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My question is: Is it possible to&amp;nbsp;display only the labels of the colored (non-white) bars?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally I'd like to display just the labels of the colored bars and place them either in the middle of the bar (if it fits inside) or outside of it (if it doesn't). But I'd be more than happy if I could just hide the labels of the white bars.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 17:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630165#M186511</guid>
      <dc:creator>LuciaCekanakova</dc:creator>
      <dc:date>2020-03-06T17:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display labels only on specfied bars in customized bar chart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630166#M186512</link>
      <description>&lt;P&gt;Don't use Amount as the label. Create a label variable that is either a formatted value of Amount or is blank.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test2;
	set test;
	retain label_position;
	by name; 
	if first.name then do;
		label_position=amount;
		end;
	else do; 
		label_position+amount;
		end;
   if Type="." then MyLabel="     ";
   else MyLabel=put(Amount, Best5.);

run;

proc sgplot data=Test2;
  styleattrs datacolors=(orange green red white);
  vbarparm category=Name response=Amount / group=Type nooutline;
    *seglabel seglabelfitpolicy=none seglabelattrs=(weight=bold);
  text x=name y=label_position text=MyLabel; 
  xaxis display=(nolabel);
  yaxis labelpos=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Mar 2020 17:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630166#M186512</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-03-06T17:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I display labels only on specfied bars in customized bar chart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630258#M186570</link>
      <description>&lt;P&gt;That is so simple, I can't believe I didn't think of it &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 22:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-display-labels-only-on-specfied-bars-in-customized-bar/m-p/630258#M186570</guid>
      <dc:creator>LuciaCekanakova</dc:creator>
      <dc:date>2020-03-06T22:19:33Z</dc:date>
    </item>
  </channel>
</rss>

