<?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 PROC SGPLOT: control BAND colors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603036#M174683</link>
    <description>&lt;P&gt;How can I control the color of the band when I use GROUP option? For example, I have 4 groups and would like to have specific colour for each group, or at least something related to the line color for that group.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sp_in_out_stats;
	styleattrs datalinepatterns=(solid dash) datacontrastcolors=(orange black);
	band x=t lower=cum_r_excess_lclm upper=cum_r_excess_uclm/group=in_out ;
	series x=t y=cum_r_excess_mean/group=in_out curvelabel curvelabelloc=outside ;	
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that I have removed other function/option within the PROC SGPLOT for ease of following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So can you see that in the following graph, each band has a different color. One outcome I would like to achieve is to have 1 color for the top 2 groups (IN_0 IN_1) and another color for the bottom two. Each group would have different levels of transparency.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot115.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33808i0816CC85D9514E89/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot115.png" alt="SGPlot115.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 10 Nov 2019 03:44:07 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2019-11-10T03:44:07Z</dc:date>
    <item>
      <title>PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603036#M174683</link>
      <description>&lt;P&gt;How can I control the color of the band when I use GROUP option? For example, I have 4 groups and would like to have specific colour for each group, or at least something related to the line color for that group.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sp_in_out_stats;
	styleattrs datalinepatterns=(solid dash) datacontrastcolors=(orange black);
	band x=t lower=cum_r_excess_lclm upper=cum_r_excess_uclm/group=in_out ;
	series x=t y=cum_r_excess_mean/group=in_out curvelabel curvelabelloc=outside ;	
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that I have removed other function/option within the PROC SGPLOT for ease of following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So can you see that in the following graph, each band has a different color. One outcome I would like to achieve is to have 1 color for the top 2 groups (IN_0 IN_1) and another color for the bottom two. Each group would have different levels of transparency.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot115.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33808i0816CC85D9514E89/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot115.png" alt="SGPlot115.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 03:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603036#M174683</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-11-10T03:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603038#M174685</link>
      <description>&lt;P&gt;For the band colors, sorting the data will accomplish what you want. To get the line pattern you desire I think you have to use a data attribute mapping. See below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	set sashelp.citimon(obs=20 keep=date c:);
run;

proc transpose data=have out=step1(rename=(_NAME_=GROUP COL1=VALUE) 
		drop=_LABEL_);
	by date;
run;

data step2;
	set step1;
	lower=VALUE-5000;
	upper=VALUE+5000;
run;

proc sort data=step2(keep=group) 
	nodupkey out=groups;
	by group;
run;

data attrmap(rename=group=value);
	retain id "attrmapping";
	set groups;
	format linepattern $5.;
	if mod(_n_,2) = 0 then linepattern = "solid";
	else linepattern = "dash";
run;

proc sgplot data=step2 dattrmap=attrmap;
	band x=date lower=lower upper=upper/group=group;
	styleattrs   
		datacolors=(VIYG BIYG PAP VPAP);	
	series x=date y=value/group=group lineattrs=(thickness=3) attrid=attrmapping;
	styleattrs 
		datacontrastcolors=(white white yellow yellow);
run;

proc sort data=step2;
	by descending group;
run;

proc sgplot data=step2 dattrmap=attrmap;
	band x=date lower=lower upper=upper/group=group;
	styleattrs   
		datacolors=(VIYG BIYG PAP VPAP);	
	series x=date y=value/group=group lineattrs=(thickness=3) attrid=attrmapping;
	styleattrs 
		datacontrastcolors=(white white yellow yellow);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sg1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33812i8FFB23DADC1F962A/image-size/large?v=v2&amp;amp;px=999" role="button" title="sg1.png" alt="sg1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sg2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33813i686F201C1F3DB99C/image-size/large?v=v2&amp;amp;px=999" role="button" title="sg2.png" alt="sg2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This website is helpful for color-picking:&amp;nbsp;&lt;A href="https://www.devenezia.com/docs/SAS/sas-colors.html" target="_blank" rel="noopener"&gt;https://www.devenezia.com/docs/SAS/sas-colors.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;-unison&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 13:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603038#M174685</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-10T13:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603041#M174686</link>
      <description>&lt;P&gt;Have you seen the &lt;FONT face="courier new,courier"&gt;transparency&lt;/FONT&gt;= option?&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 04:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603041#M174686</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-10T04:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603043#M174688</link>
      <description>&lt;P&gt;I can do transparency. However, choosing colour with patterns is troublesome as (I think) SAS cycles colours first and then the patterns&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 05:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603043#M174688</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-11-10T05:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603044#M174689</link>
      <description>&lt;P&gt;Thanks. This solves half of my problem. Is there a way to make the 2 lines with the same color to have a solid and a dash pattern?&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datalinepatterns=(solid dash) 
datacontrastcolors=(black red) &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but SAS cycles the colour&amp;nbsp;first and then the pattern which is quite frustrating&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 05:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603044#M174689</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-11-10T05:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603057#M174692</link>
      <description>&lt;P&gt;Hey &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98381"&gt;@somebody&lt;/a&gt;, see my edited post above. I think an attribute map will accomplish what you want.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 15:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603057#M174692</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-10T15:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603116#M174717</link>
      <description>&lt;P&gt;Thanks. That does it. just one last question, can't we do it within PROC SGPLOT? Do we have to use a DATA step to create the attrmap?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 04:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603116#M174717</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-11-11T04:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603399#M174821</link>
      <description>&lt;P&gt;This is exactly why I think table and variable names should be uppercased.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=STEP2 dattrmap=ATTRMAP;
  band x=DATE lower=LOWER upper=UPPER/group=GROUP;
  styleattrs datacolors=(viyg biygpap vpap);	
  series x=DATE y=VALUE/group=GROUP lineattrs=(thickness=3) attrid=ATTRMAPPING;
  styleattrs datacontrastcolors=(white white yellow yellow);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This a lot more legible imho.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 23:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603399#M174821</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-11T23:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: control BAND colors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603734#M174937</link>
      <description>&lt;P&gt;The Dattrmap would be a dataset so can't be done in Sgplot.&lt;/P&gt;
&lt;P&gt;You may be able to get close to what you want by using the STYLEATTRS statement to provide lists of items such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  styleattrs  
     datacontrastcolors=(red green blue) 
     datalinepatterns=(dot solid);
&lt;/PRE&gt;
&lt;P&gt;would assign the colors red, green and blue as the first three datacontrast colors used and the two line types.&lt;/P&gt;
&lt;P&gt;The fun part may be getting needed repeats and orders to align with your data.&lt;/P&gt;
&lt;P&gt;If there is much complexity the Dattrmap option is more robust at least in my opinion and if you make a permanent data set is always available for making consistent combinations of colors, markers and line properties. The Styleattrs would likely need to be adjusted as if your data has groups that only appear in some of your analysis subsets.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 00:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SGPLOT-control-BAND-colors/m-p/603734#M174937</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-13T00:17:56Z</dc:date>
    </item>
  </channel>
</rss>

