<?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 proc sgplot hbar: Changing the color of the bar at a specified value in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644481#M19820</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set with mean values (mean) and an order variable (p).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data temp;
input p mean;
datalines;
1 41
2 29
3 24
4 24
5 20
6 19
7 19
8 18
9 18
10 16
11 15
12 10 
13 7 
14 6
;
run; &lt;/PRE&gt;
&lt;P&gt;I want to produce horizontal bars with p on the y axis and the values of mean on the x axis, so I use proc sgplot with hbar (changing the default color of the bars to green)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=temp noautolegend noborder;
hbar p / response=mean fillattrs=(color=green);
run;&lt;/PRE&gt;
&lt;P&gt;The result is&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="SGPlot13.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38966iC4654A51E8E7C7ED/image-size/small?v=v2&amp;amp;px=200" role="button" title="SGPlot13.png" alt="SGPlot13.png" /&gt;&lt;/span&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This results looks fine to me, however, what can I do when I want that all bars below a mean value of 10 (mean &amp;lt; 10) appear in the color "white"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bye, Daniel&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>Fri, 01 May 2020 10:39:52 GMT</pubDate>
    <dc:creator>Daniel_Paul</dc:creator>
    <dc:date>2020-05-01T10:39:52Z</dc:date>
    <item>
      <title>proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644481#M19820</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set with mean values (mean) and an order variable (p).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data temp;
input p mean;
datalines;
1 41
2 29
3 24
4 24
5 20
6 19
7 19
8 18
9 18
10 16
11 15
12 10 
13 7 
14 6
;
run; &lt;/PRE&gt;
&lt;P&gt;I want to produce horizontal bars with p on the y axis and the values of mean on the x axis, so I use proc sgplot with hbar (changing the default color of the bars to green)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=temp noautolegend noborder;
hbar p / response=mean fillattrs=(color=green);
run;&lt;/PRE&gt;
&lt;P&gt;The result is&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="SGPlot13.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38966iC4654A51E8E7C7ED/image-size/small?v=v2&amp;amp;px=200" role="button" title="SGPlot13.png" alt="SGPlot13.png" /&gt;&lt;/span&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This results looks fine to me, however, what can I do when I want that all bars below a mean value of 10 (mean &amp;lt; 10) appear in the color "white"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bye, Daniel&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>Fri, 01 May 2020 10:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644481#M19820</guid>
      <dc:creator>Daniel_Paul</dc:creator>
      <dc:date>2020-05-01T10:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644482#M19821</link>
      <description>&lt;P&gt;You want them to be white with a white background?&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 10:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644482#M19821</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-05-01T10:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644483#M19822</link>
      <description>&lt;P&gt;Only the fill color shoud be white, the border should be black.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 10:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644483#M19822</guid>
      <dc:creator>Daniel_Paul</dc:creator>
      <dc:date>2020-05-01T10:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644489#M19823</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37291"&gt;@Daniel_Paul&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
input p mean;
if mean &amp;lt; 10 then flag = 1;
else flag = 0;
datalines;
1 41
2 29
3 24
4 24
5 20
6 19
7 19
8 18
9 18
10 16
11 15
12 10 
13 7 
14 6
;
run; 

proc sgplot data=temp noautolegend noborder ;
	hbar p / response=mean colorresponse=flag colormodel=(green white);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-05-01 à 13.00.15.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38967i42DFFFC5C4C850DE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2020-05-01 à 13.00.15.png" alt="Capture d’écran 2020-05-01 à 13.00.15.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 11:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644489#M19823</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-01T11:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644490#M19824</link>
      <description>&lt;P&gt;That's it, thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 11:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644490#M19824</guid>
      <dc:creator>Daniel_Paul</dc:creator>
      <dc:date>2020-05-01T11:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644491#M19825</link>
      <description>You're welcome!</description>
      <pubDate>Fri, 01 May 2020 11:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644491#M19825</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-01T11:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644566#M19826</link>
      <description>&lt;P&gt;Alternatively one could make the code a little bit more flexible using formats&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 17:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644566#M19826</guid>
      <dc:creator>HansGelders</dc:creator>
      <dc:date>2020-05-01T17:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot hbar: Changing the color of the bar at a specified value</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644600#M19827</link>
      <description>&lt;P&gt;Just for fun: an other way to do it using Gchart&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;value ColorM&lt;BR /&gt;0 - &amp;lt; 10 = white&lt;BR /&gt;10 - &amp;lt; 20 = yellow&lt;BR /&gt;20 - &amp;lt; 30 = lightgreen&lt;BR /&gt;Other = lightblue&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;length Mean_Color $12;&lt;BR /&gt;input P Mean;&lt;BR /&gt;Mean_Color = put(mean,ColorM.);&lt;BR /&gt;datalines;&lt;BR /&gt;1 41&lt;BR /&gt;2 29&lt;BR /&gt;3 24&lt;BR /&gt;4 23&lt;BR /&gt;5 20&lt;BR /&gt;6 19&lt;BR /&gt;7 19&lt;BR /&gt;8 18&lt;BR /&gt;9 18&lt;BR /&gt;10 16&lt;BR /&gt;11 15&lt;BR /&gt;12 13&lt;BR /&gt;13 7&lt;BR /&gt;14 6&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;goptions device=png;&lt;BR /&gt;goptions noborder;&lt;BR /&gt;ODS LISTING CLOSE;&lt;BR /&gt;ODS HTML path="/home/hgelders/examples" body="Chart_conditional_coloring..htm" ;&lt;BR /&gt;&lt;BR /&gt;goptions gunit=pct htitle=4 ftitle="albany amt/bold" htext=2.5&lt;BR /&gt;ftext="albany amt/bold";&lt;BR /&gt;goptions ctext=gray33;&lt;BR /&gt;axis1 label=none value=(height=2);&lt;BR /&gt;axis2 label=('MEAN') order=(0 to 45 by 5) minor=(number=1) offset=(0, 0);&lt;/P&gt;&lt;P&gt;data _Null_; set temp;&lt;BR /&gt;by p notsorted;&lt;BR /&gt;if first.p then call execute(cats('pattern',_N_,'09'x,'color=',Mean_Color,';'));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;title1 ls=1.5 "Gchart with conditional coloring";&lt;/P&gt;&lt;P&gt;proc gchart data=my_data;&lt;BR /&gt;hbar p / discrete type=sum sumvar=mean nostats maxis=axis1 raxis=axis2&lt;BR /&gt;subgroup=p patternid=subgroup width=2.2 gspace=0.2 autoref clipref cref=graycc coutline=black&lt;BR /&gt;nolegend ; run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;ODS HTML CLOSE;&lt;BR /&gt;ODS LISTING;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 19:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-hbar-Changing-the-color-of-the-bar-at-a-specified/m-p/644600#M19827</guid>
      <dc:creator>HansGelders</dc:creator>
      <dc:date>2020-05-01T19:51:09Z</dc:date>
    </item>
  </channel>
</rss>

