<?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 custom colours for stacked bar chart. in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657601#M20034</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code to create the attaced graph&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc template;&lt;/P&gt;&lt;P&gt;define statgraph bar100;&lt;BR /&gt;&lt;BR /&gt;begingraph ;&lt;BR /&gt;layout overlay/ xaxisopts=(display=standard label=" "&lt;BR /&gt;discreteopts=(tickdisplaylist=(&amp;amp;xticks) tickvaluefitpolicy=split tickvaluesplitchar="~") )&lt;BR /&gt;yaxisopts=(display=standard label='Percentage of Patients' linearopts=(viewmin=0 viewmax=100 tickvaluesequence=(start=0 end=100 increment=10) viewmin=0 viewmax=100 tickvalueformat =pct.));&lt;BR /&gt;BARCHARTPARM X = avisn y=percent / group=avalx name="lgnd1" ;&lt;BR /&gt;&lt;BR /&gt;discretelegend "lgnd1" /halign=right across=1 sortorder=DESCENDINGFORMATTED;&lt;BR /&gt;&lt;BR /&gt;endlayout;&lt;BR /&gt;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc sgrender data=all template=bar100;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Query is how to make the custom colours for the stacks?&lt;/P&gt;&lt;P&gt;I tried using&amp;nbsp;&lt;/P&gt;&lt;P&gt;Begingraph //datacolors=(grey pink lightblue blue orange yellow lightred red lightgreen green black)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gave me the colours i mentioned&amp;nbsp; but not as the way i wanted. This pics the colours based on the first xaxis value and so on.&amp;nbsp; I tried sorting data using my group variable avalx but that make the graph wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output without using the datacolours is below:&lt;/P&gt;&lt;P&gt;My intention is to give&amp;nbsp;grey = 00&amp;nbsp; pink=02 lightblue=04&amp;nbsp; blue=08 orange=12 yellow=16 lightred=20 red=24 lightgreen=32 green=48 black=ND&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Manj_0-1591894275170.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42723i31AFD56F50AD2DE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Manj_0-1591894275170.png" alt="Manj_0-1591894275170.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 16:53:11 GMT</pubDate>
    <dc:creator>Manj</dc:creator>
    <dc:date>2020-06-11T16:53:11Z</dc:date>
    <item>
      <title>custom colours for stacked bar chart.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657601#M20034</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code to create the attaced graph&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc template;&lt;/P&gt;&lt;P&gt;define statgraph bar100;&lt;BR /&gt;&lt;BR /&gt;begingraph ;&lt;BR /&gt;layout overlay/ xaxisopts=(display=standard label=" "&lt;BR /&gt;discreteopts=(tickdisplaylist=(&amp;amp;xticks) tickvaluefitpolicy=split tickvaluesplitchar="~") )&lt;BR /&gt;yaxisopts=(display=standard label='Percentage of Patients' linearopts=(viewmin=0 viewmax=100 tickvaluesequence=(start=0 end=100 increment=10) viewmin=0 viewmax=100 tickvalueformat =pct.));&lt;BR /&gt;BARCHARTPARM X = avisn y=percent / group=avalx name="lgnd1" ;&lt;BR /&gt;&lt;BR /&gt;discretelegend "lgnd1" /halign=right across=1 sortorder=DESCENDINGFORMATTED;&lt;BR /&gt;&lt;BR /&gt;endlayout;&lt;BR /&gt;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc sgrender data=all template=bar100;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Query is how to make the custom colours for the stacks?&lt;/P&gt;&lt;P&gt;I tried using&amp;nbsp;&lt;/P&gt;&lt;P&gt;Begingraph //datacolors=(grey pink lightblue blue orange yellow lightred red lightgreen green black)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gave me the colours i mentioned&amp;nbsp; but not as the way i wanted. This pics the colours based on the first xaxis value and so on.&amp;nbsp; I tried sorting data using my group variable avalx but that make the graph wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My output without using the datacolours is below:&lt;/P&gt;&lt;P&gt;My intention is to give&amp;nbsp;grey = 00&amp;nbsp; pink=02 lightblue=04&amp;nbsp; blue=08 orange=12 yellow=16 lightred=20 red=24 lightgreen=32 green=48 black=ND&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Manj_0-1591894275170.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42723i31AFD56F50AD2DE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Manj_0-1591894275170.png" alt="Manj_0-1591894275170.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657601#M20034</guid>
      <dc:creator>Manj</dc:creator>
      <dc:date>2020-06-11T16:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: custom colours for stacked bar chart.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657615#M20035</link>
      <description>&lt;P&gt;Have you considered using a DATTRMAP data set? The data set contains formatted values of your variable and appearance settings.&lt;/P&gt;
&lt;P&gt;With SGRENDER&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procStatement"&gt;
&lt;DIV class="xis-procStatementSyntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;DIV id="n0l1nt7lz6wzvqn16f9dqun80ynt" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD rowspan="2" class="xis-requirement"&gt;Requirements&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;Do either one of the following:
&lt;DIV class="xis-listUnordered"&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV id="p06rr50qn4zn7kn1xabb0pxfe0k9" class="xis-item"&gt;
&lt;DIV id="n1iho1ycg5wesnn159ef9mo2opq0" class="xis-paraSimpleFirst"&gt;specify the attribute map ID variable by using the DATTRVAR statement in the SGRENDER procedure.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV id="n1dwvvdkb47yydn1c8go3w34kyn7" class="xis-item"&gt;
&lt;DIV id="p1eslgbjkpdsiln16eq9em1vg1ke" class="xis-paraSimpleFirst"&gt;specify the attribute map ID variable using the DISCRETEATTRVAR variable in the StatGraph template.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
If neither of these requirements is met, the descriptions in the attribute map data set are ignored.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryText"&gt;The values in the DATTRMAP data set must be sorted by ID. If they are not, only the first value is found.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 11 Jun 2020 17:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657615#M20035</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T17:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: custom colours for stacked bar chart.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657625#M20036</link>
      <description>&lt;P&gt;But I see these are for individual bars and not the stacks within each bars. It is a stacked bar chart .May be I'm missing something?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 17:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657625#M20036</guid>
      <dc:creator>Manj</dc:creator>
      <dc:date>2020-06-11T17:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: custom colours for stacked bar chart.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657633#M20037</link>
      <description>&lt;P&gt;DATTRMAPS will work for your stacked bar chart as well, as the attribute mapping is tied to your GROUP values. See pages 9-14 in this paper for more information:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings17/SAS0675-2017.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings17/SAS0675-2017.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 17:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/657633#M20037</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2020-06-11T17:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: custom colours for stacked bar chart.</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/658023#M20041</link>
      <description>Hi&lt;BR /&gt;Thanks for this. This works if I specify the colours. I found the below from the sas blogs. It says green to red. Quite unsure of this dynamic way of doing it. Im looking for colours from dark yellow--light yellow--red and I have about 12 stacks. The below code is working fro green to red. but im not sure how to alter this code for the scheme im looking for.&lt;BR /&gt;&lt;BR /&gt;/*--Define attributes map data set--*/&lt;BR /&gt;data AttrMap;&lt;BR /&gt;length FillColor $8 LineColor $8;&lt;BR /&gt;id='Hist';&lt;BR /&gt;ghigh=192; /*--High value for Green--*/ ???? not sure of this number&lt;BR /&gt;rhigh=255; /*--High value for Red--*/ ???? not sure of this number&lt;BR /&gt;&lt;BR /&gt;mid=(&amp;amp;minbin + &amp;amp;maxbin) / 2;&lt;BR /&gt;LineColor='CX000000';&lt;BR /&gt;&lt;BR /&gt;do val=&amp;amp;minbin to &amp;amp;maxbin by &amp;amp;BinInt;&lt;BR /&gt;value=put(val, 5.0);&lt;BR /&gt;if val &amp;lt; mid then do;&lt;BR /&gt;g=ghigh; b=0; r=rhigh*(val-&amp;amp;minbin)/ (mid-&amp;amp;minbin);&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;r=rhigh; b=0; g=ghigh*(1-((val-&amp;amp;minbin) - (mid-&amp;amp;minbin))/ (mid-&amp;amp;minbin)); ???? what is this calculation?&lt;BR /&gt;end;&lt;BR /&gt;fillcolor='CX' || put(r, hex2.) || put(g, hex2.) || put(b, hex2.); ???? what is this calculation?&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 12 Jun 2020 11:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/custom-colours-for-stacked-bar-chart/m-p/658023#M20041</guid>
      <dc:creator>Manj</dc:creator>
      <dc:date>2020-06-12T11:35:42Z</dc:date>
    </item>
  </channel>
</rss>

