<?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: Changing colors in waterfall charts in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234950#M8527</link>
    <description>&lt;P&gt;The best way to do this is to use an attrbutes map and the COLORGROUP option. In the code below, I created a small data step that creates a group column based on positive/negative. I use that color in the WATERFALL chart on the COLORGROUP option. I bound the attrmap to the proc using DATTRMAP and ATTRID. Let me know if you have any questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data posneg;&lt;BR /&gt;retain id "posneg";&lt;BR /&gt;length fillcolor $ 5;&lt;BR /&gt;input value $ fillcolor $;&lt;BR /&gt;cards;&lt;BR /&gt;p green&lt;BR /&gt;n red&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data grouped;&lt;BR /&gt;set chart;&lt;BR /&gt;if (variance_for &amp;lt; 0.0) then group="n";&lt;BR /&gt;else group="p";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=grouped dattrmap=posneg;&lt;BR /&gt;waterfall category=month response=variance_for&lt;BR /&gt;/ stat=mean datalabel DATALABELATTRS=(Size=9 Family=Verdana) FINALBARTICKVALUE= 'YTD Variance' dataskin=pressed&lt;BR /&gt;name='YTD Plan' colorgroup=group attrid=posneg;&lt;BR /&gt;format variance_for f6.0;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2015 00:25:11 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2015-11-17T00:25:11Z</dc:date>
    <item>
      <title>Changing colors in waterfall charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234945#M8526</link>
      <description>&lt;P&gt;I'd like some help and advice on how to dynamically change colors in sgplot depending on the value of the variable (variance_for), i.e. if the value is negative then the bar is red, otherwise green. I use SAS 9.4 third maintenance release, I tried various options in sgplot-waterfall but I can't get it to work.&lt;/P&gt;
&lt;P&gt;My dataset and code are below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data chart;&lt;BR /&gt;input month monyy5. variance_for;&lt;BR /&gt;format month monyy5.;&lt;BR /&gt;cards;&lt;BR /&gt;jan15 41.4&lt;BR /&gt;feb15 -89.4&lt;BR /&gt;mar15 374&lt;BR /&gt;apr15 -90.2&lt;BR /&gt;may15 -592.2&lt;BR /&gt;jun15 -48&lt;BR /&gt;jul15 -68.8&lt;BR /&gt;aug15 -121.9&lt;BR /&gt;sep15 38.2&lt;BR /&gt;oct15 80.1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=chart;&lt;BR /&gt; waterfall category=month response=variance_for&lt;BR /&gt; / stat=mean datalabel DATALABELATTRS=(Size=9 Family=Verdana) FINALBARTICKVALUE= 'YTD Variance' dataskin=pressed &lt;BR /&gt; name='YTD Plan';&lt;BR /&gt; format variance_for f6.0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 23:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234945#M8526</guid>
      <dc:creator>PTD_SAS</dc:creator>
      <dc:date>2015-11-16T23:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Changing colors in waterfall charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234950#M8527</link>
      <description>&lt;P&gt;The best way to do this is to use an attrbutes map and the COLORGROUP option. In the code below, I created a small data step that creates a group column based on positive/negative. I use that color in the WATERFALL chart on the COLORGROUP option. I bound the attrmap to the proc using DATTRMAP and ATTRID. Let me know if you have any questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data posneg;&lt;BR /&gt;retain id "posneg";&lt;BR /&gt;length fillcolor $ 5;&lt;BR /&gt;input value $ fillcolor $;&lt;BR /&gt;cards;&lt;BR /&gt;p green&lt;BR /&gt;n red&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data grouped;&lt;BR /&gt;set chart;&lt;BR /&gt;if (variance_for &amp;lt; 0.0) then group="n";&lt;BR /&gt;else group="p";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=grouped dattrmap=posneg;&lt;BR /&gt;waterfall category=month response=variance_for&lt;BR /&gt;/ stat=mean datalabel DATALABELATTRS=(Size=9 Family=Verdana) FINALBARTICKVALUE= 'YTD Variance' dataskin=pressed&lt;BR /&gt;name='YTD Plan' colorgroup=group attrid=posneg;&lt;BR /&gt;format variance_for f6.0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 00:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234950#M8527</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-11-17T00:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Changing colors in waterfall charts</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234951#M8528</link>
      <description>&lt;P&gt;Thanks Dan, that worked great!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 00:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Changing-colors-in-waterfall-charts/m-p/234951#M8528</guid>
      <dc:creator>PTD_SAS</dc:creator>
      <dc:date>2015-11-17T00:32:25Z</dc:date>
    </item>
  </channel>
</rss>

