<?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: gchart change bar color in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66783#M2295</link>
    <description>I would do this by copying rate1 to a new column (we'll say rate2) and put a user-defined format on rate using your range specifications. Then, specify two PATTERN statements with the colors you want (yellow first, then red). Sort your data by rate2 from least to greatest. Set rate2 as the SUBGROUP variable on your VBAR statement. Hopefully, that will give you the result you want.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dan</description>
    <pubDate>Wed, 10 Mar 2010 20:22:47 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2010-03-10T20:22:47Z</dc:date>
    <item>
      <title>gchart change bar color</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66782#M2294</link>
      <description>How can I change the bar color based upon the value of rate1?&lt;BR /&gt;
For example, if rate1=&amp;gt;2 I would like the bar to be red and if 0&lt;RATE1&gt;&amp;lt;2 then I would like the bar to be yellow.&lt;BR /&gt;
proc gchart data=goals;&lt;BR /&gt;
vbar bu&lt;BR /&gt;
discrete sumvar=rate1; &lt;BR /&gt;
maxis=axis1&lt;BR /&gt;
raxis=axis2&lt;BR /&gt;
gaxis=axis3&lt;BR /&gt;
run;&lt;BR /&gt;
Thank you.&lt;/RATE1&gt;</description>
      <pubDate>Wed, 10 Mar 2010 20:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66782#M2294</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-10T20:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: gchart change bar color</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66783#M2295</link>
      <description>I would do this by copying rate1 to a new column (we'll say rate2) and put a user-defined format on rate using your range specifications. Then, specify two PATTERN statements with the colors you want (yellow first, then red). Sort your data by rate2 from least to greatest. Set rate2 as the SUBGROUP variable on your VBAR statement. Hopefully, that will give you the result you want.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dan</description>
      <pubDate>Wed, 10 Mar 2010 20:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66783#M2295</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2010-03-10T20:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: gchart change bar color</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66784#M2296</link>
      <description>Unfortunately, gchart does not let you directly specify specific colors for specific values or ranges of values (you could do that in SAS/AF charts with the "color range object", but not in SAS/Graph charts).&lt;BR /&gt;
&lt;BR /&gt;
The easiest way I know of to do that, is to add an extra variable to your data set, and use if/else statements to assign a value to that variable using if/else statements based on the &amp;gt;= rules you mentioned.&lt;BR /&gt;
&lt;BR /&gt;
Then in the gchart, use the subgroup= option, and specify that new variable.  The values of this variable will get mapped to the colors in the pattern statement (you have to get a little 'tricky' if your data does not always contain obsns for all the desired colors, by the way).&lt;BR /&gt;
&lt;BR /&gt;
Here is an example, showing the basics:&lt;BR /&gt;
&lt;BR /&gt;
data goals;&lt;BR /&gt;
input bu rate1;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 2.6&lt;BR /&gt;
2 .5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data goals; set goals;&lt;BR /&gt;
if rate1&amp;gt;=2 then colorval=1;&lt;BR /&gt;
else colorval=2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
pattern1 v=solid c=red;&lt;BR /&gt;
pattern2 v=solid c=yellow;&lt;BR /&gt;
&lt;BR /&gt;
proc gchart data=goals;&lt;BR /&gt;
vbar bu / discrete sumvar=rate1 subgroup=colorval &lt;BR /&gt;
 refline=2 clipref nolegend; &lt;BR /&gt;
run;</description>
      <pubDate>Wed, 10 Mar 2010 20:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/gchart-change-bar-color/m-p/66784#M2296</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2010-03-10T20:34:29Z</dc:date>
    </item>
  </channel>
</rss>

