<?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: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206901#M7705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At v9.3, you can use Attribute Maps to assign colors to specific group values. For the example below, I flipped the category and group variables so that I had fewer colors to define &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data shoes;&lt;/P&gt;&lt;P&gt;set sashelp.shoes;&lt;/P&gt;&lt;P&gt;where region in ('Africa', 'Middle East', 'United States', 'Canada');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data attrmap;&lt;/P&gt;&lt;P&gt;retain id "myid";&lt;/P&gt;&lt;P&gt;input value $ 1-13 fillcolor $ 15-20;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;Africa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blue&lt;/P&gt;&lt;P&gt;Middle East&amp;nbsp;&amp;nbsp; green&lt;/P&gt;&lt;P&gt;United States yellow&lt;/P&gt;&lt;P&gt;Canada&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; black&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=shoes dattrmap=attrmap;&lt;/P&gt;&lt;P&gt;vbar product / response=sales group=region groupdisplay=stack stat=sum attrid=myid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SGPlot.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9660_SGPlot.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Mar 2015 17:56:18 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2015-03-20T17:56:18Z</dc:date>
    <item>
      <title>PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206900#M7704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I need some help using custom colors in Vertical Bar Charts.&lt;/P&gt;&lt;P&gt;I am using SGPLOT / VBAR statement and version is SAS 9.3.&lt;/P&gt;&lt;P&gt;Here is the simple example of what I have. But I would like to use user defined colors (let's say blue green yellow black brown etc etc).&lt;/P&gt;&lt;P&gt;Is there a quick and simple way to do that? Thank you for all your help.&lt;/P&gt;&lt;P&gt;P.S.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data shoes;&lt;BR /&gt;set sashelp.shoes;&lt;BR /&gt;where region in ('Africa', 'Middle East', 'United States', 'Canada');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=shoes;&lt;BR /&gt;vbar region / response=sales group=product groupdisplay=stack stat=sum;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="example.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9659_example.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 17:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206900#M7704</guid>
      <dc:creator>P_S_</dc:creator>
      <dc:date>2015-03-20T17:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206901#M7705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At v9.3, you can use Attribute Maps to assign colors to specific group values. For the example below, I flipped the category and group variables so that I had fewer colors to define &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data shoes;&lt;/P&gt;&lt;P&gt;set sashelp.shoes;&lt;/P&gt;&lt;P&gt;where region in ('Africa', 'Middle East', 'United States', 'Canada');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data attrmap;&lt;/P&gt;&lt;P&gt;retain id "myid";&lt;/P&gt;&lt;P&gt;input value $ 1-13 fillcolor $ 15-20;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;Africa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blue&lt;/P&gt;&lt;P&gt;Middle East&amp;nbsp;&amp;nbsp; green&lt;/P&gt;&lt;P&gt;United States yellow&lt;/P&gt;&lt;P&gt;Canada&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; black&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=shoes dattrmap=attrmap;&lt;/P&gt;&lt;P&gt;vbar product / response=sales group=region groupdisplay=stack stat=sum attrid=myid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SGPlot.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9660_SGPlot.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 17:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206901#M7705</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-03-20T17:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206902#M7706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, one more thing -- set the LINECOLOR to BLACK in the dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data attrmap;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;retain id "myid" linecolor "black";&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;input value $ 1-13 fillcolor $ 15-20;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cards;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Africa&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blue&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Middle East&amp;nbsp;&amp;nbsp; green&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;United States yellow&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Canada&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; black&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206902#M7706</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-03-20T18:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206903#M7707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Controlling the colors of group bars can be done through Proc Template&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; define style styles.barcolor;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Style GraphData 1 fom GraphData1/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Contrast Color = blue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Color = blue;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Do for each color in the bar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference this style in the style=barcolor output for instance&lt;/P&gt;&lt;P&gt;ods html style=barcolor;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206903#M7707</guid>
      <dc:creator>lisagros</dc:creator>
      <dc:date>2015-03-20T18:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206904#M7708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is easier than Proc template with the added benefit that&amp;nbsp; if you have dynamic parameters you can fix the colors for a specific id - ie Canada is always red, and US always blue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now to convert my all my templates to that method as we migrate to 9.4!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206904#M7708</guid>
      <dc:creator>lisagros</dc:creator>
      <dc:date>2015-03-20T18:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206905#M7709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DanH,&lt;/P&gt;&lt;P&gt;This is great example in this case. But the problem is I have many variables that I need to create stacked bar chart on and each of the variable has different values and are not consistent between variables.&lt;/P&gt;&lt;P&gt;This will create a problem for me as I will need to define colors for lots of values.&lt;/P&gt;&lt;P&gt;I have used GCHART before and have defined colors in pattern statement and the graph would automatically pick up the colors.&lt;/P&gt;&lt;P&gt;pattern1 value=s color=red ;&lt;/P&gt;&lt;P&gt;pattern2 value=s color=green ;&lt;/P&gt;&lt;P&gt;pattern3 value=l5 color=black;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I was thinking something similar to that in SGPLOT. Is that an option?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206905#M7709</guid>
      <dc:creator>P_S_</dc:creator>
      <dc:date>2015-03-20T18:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206906#M7710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For SAS 9.4 this is trivial. We have a STYLEATTRS statement in the SG procedures where you can define a list of data colors for fills, lines, and markers. Since you said your version was SAS 9.3, I tried to give you a solution where your would not have to modify a style template. However, creating an ODS style with your custom colors is an option if this is something you need to consistently reproduce.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 19:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206906#M7710</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-03-20T19:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206907#M7711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi DanH,&lt;/P&gt;&lt;P&gt;Yes I am still using 9.3. Can you please share an example of creating the ODS style with the custom color? That solution might work in my case. I want to give that a try.&lt;/P&gt;&lt;P&gt;And by the way I am outputting the plots to PDF destination.&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 19:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206907#M7711</guid>
      <dc:creator>P_S_</dc:creator>
      <dc:date>2015-03-20T19:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT : How to use Custom Colors in Stacked Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206908#M7712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%MODSTYLE is an easy way to create a style from a parent with specific group colors.&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2012/06/14/quick-and-easy-with-modstyle/" title="http://blogs.sas.com/content/graphicallyspeaking/2012/06/14/quick-and-easy-with-modstyle/"&gt;http://blogs.sas.com/content/graphicallyspeaking/2012/06/14/quick-and-easy-with-modstyle/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 20:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-use-Custom-Colors-in-Stacked-Bar-Chart/m-p/206908#M7712</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2015-03-20T20:59:23Z</dc:date>
    </item>
  </channel>
</rss>

