<?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 Setting Bar Colors in SAS 9.2 in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360002#M12565</link>
    <description>&lt;P&gt;I have a proc template within a macro. &amp;nbsp;The data is subset based on the value of VAR (if VAR = 1, or 2, or 3, etc.) &amp;nbsp;This produces a 5-page bar graph with one VAR group on each page. &amp;nbsp;The bars are the same color on each page (red), but I want them to be different colors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read some similar threads in this group, which included using DATACONTRASTCOLORS, but that apparently doesn't work in 9.2 as I got an error when I added it. &amp;nbsp;I need to make the value of the color a macro variable, so I can change it with each call of the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there some way to force bar colors in 9.2?&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2017 14:51:55 GMT</pubDate>
    <dc:creator>VCM</dc:creator>
    <dc:date>2017-05-19T14:51:55Z</dc:date>
    <item>
      <title>Setting Bar Colors in SAS 9.2</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360002#M12565</link>
      <description>&lt;P&gt;I have a proc template within a macro. &amp;nbsp;The data is subset based on the value of VAR (if VAR = 1, or 2, or 3, etc.) &amp;nbsp;This produces a 5-page bar graph with one VAR group on each page. &amp;nbsp;The bars are the same color on each page (red), but I want them to be different colors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read some similar threads in this group, which included using DATACONTRASTCOLORS, but that apparently doesn't work in 9.2 as I got an error when I added it. &amp;nbsp;I need to make the value of the color a macro variable, so I can change it with each call of the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there some way to force bar colors in 9.2?&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 14:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360002#M12565</guid>
      <dc:creator>VCM</dc:creator>
      <dc:date>2017-05-19T14:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Bar Colors in SAS 9.2</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360012#M12566</link>
      <description>&lt;P&gt;You really should show the code for the template, assuming that is a template used by SGrender. If you are using another procedure such as SGplot or Sgpanel show that code. With 9.2 you may want to move to Sgrender to have more control.&lt;/P&gt;
&lt;P&gt;A little example data may help as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If using Sgrender a dynamic variable to pass the color to the template would work.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 15:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360012#M12566</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-19T15:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Bar Colors in SAS 9.2</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360922#M12589</link>
      <description>&lt;P&gt;You should be able to use GROUP=VAR in the VBAR statement. &amp;nbsp;Also set UNIFORM=GROUP in the proc statement. &amp;nbsp;This will make all bars in one graph with BY=VAR.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_  close;
ods html;
proc sort data=sashelp.class out=class;
by  sex;
run;

proc sgplot data=class uniform=group;
  by sex;
  vbar name / response=height group=sex;
run;
ods html close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With GTL, you can use the INDEX= option. &amp;nbsp;Create a new column "Index" with values 1 for Males and 2 for Females. &amp;nbsp;Then set INDEX=index on the BarChart statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 20:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/360922#M12589</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2017-05-23T20:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Bar Colors in SAS 9.2</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/361127#M12592</link>
      <description>&lt;P&gt;Thanks for the input, everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, the code belongs to my client and I'm not able to share a lot of detail--just the overall logic.&lt;/P&gt;&lt;P&gt;Second, this isn't even my project; I just jumped in to help and now my curiousity has gotten the best of me. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output is 6 pages.&amp;nbsp; Page 1&amp;nbsp;is a&amp;nbsp;waterfall&amp;nbsp;all 5&amp;nbsp;values of VAR, each a different color:&lt;/P&gt;&lt;P&gt;VAR = 1 then red&lt;/P&gt;&lt;P&gt;VAR = 2 then blue&lt;/P&gt;&lt;P&gt;VAR = 3 then yellow&lt;/P&gt;&lt;P&gt;VAR-= 4 then green&lt;/P&gt;&lt;P&gt;VAR = 5 then purple&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pages 2 through&amp;nbsp;6 are 1 VAR each, and we want the colors to match what is on page 1; so page 2 (VAR = 1) will be red, page 3 (VAR = 2) will be blue, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that the overall issue is how the macros are set up:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;A proc template is called to create the style "STYLEX", using "replace GraphData1" etc. to set the 5 colors for page 1.&lt;/LI&gt;&lt;LI&gt;A proc template is called to create the format for the page 1 waterfall&lt;/LI&gt;&lt;LI&gt;Proc sgrender creates page 1 from the dataset&lt;/LI&gt;&lt;LI&gt;A macro is created to subset the dataset by value of VAR (if VAR = &amp;amp;val)&lt;/LI&gt;&lt;LI&gt;A proc template (still within the macro) is called to create the format for the pages 2-6 waterfalls&lt;/LI&gt;&lt;LI&gt;Proc sgrender (still within the macro) creates the page&lt;/LI&gt;&lt;LI&gt;Macro is called 5 times, once for each value of VAR&lt;/LI&gt;&lt;LI&gt;Another macro combines all 6 pages into one output--and this macro calls STYLEX.&amp;nbsp; Since pages 2 through 6 only have one value of VAR,&amp;nbsp;each one&amp;nbsp;gets treated like VAR = 1 and is assigned red.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think what we might need to do is find a way to alter that final macro so that we can create each page in a different style, THEN combine them.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 10:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Setting-Bar-Colors-in-SAS-9-2/m-p/361127#M12592</guid>
      <dc:creator>VCM</dc:creator>
      <dc:date>2017-05-24T10:21:05Z</dc:date>
    </item>
  </channel>
</rss>

