<?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 sgpanel color cluster bars by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615166#M179928</link>
    <description>&lt;P&gt;1. One work-around I could think of is using the COLORRESPONSE option to color the different combinations of STAGE1 and METHOD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data plot2;
	set plot1;
	colorvar=5*stage1+2*method;
run;

ods graphics ON;
ods graphics/width=6in height=4in;

proc sgpanel data=plot2;
	panelby agegrp / novarname colheaderpos=bottom COLUMNS=4 onepanel;
	vbar stage1 / response=surv stat=sum nostatlabel group=method 
		groupdisplay=cluster barwidth=0.7
		colorresponse=colorvar colormodel=(lightcoral lightgreen darkblue);
	keylegend "Empirical" "Midpoint" / across=1 position=Top;
	format agegrp agegrp. stage1 stage.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's tricky is picking colors and a combination function (5*STAGE1+2*METHOD) that allow for distinction in the colors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. The option for spacing between clusters is called BARWIDTH. Here, BARWIDTH=0.7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sg1.png" style="width: 576px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35144i8EF16718AFB016C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="sg1.png" alt="sg1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Sun, 05 Jan 2020 06:53:40 GMT</pubDate>
    <dc:creator>unison</dc:creator>
    <dc:date>2020-01-05T06:53:40Z</dc:date>
    <item>
      <title>proc sgpanel color cluster bars by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615160#M179923</link>
      <description>&lt;P&gt;Hi folks:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a couple of questions on the same plot if you don't mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. How to assign colours to the paired bars by group variable (localized, regional and distant) but not within (blue vs red) as of now. It's confusing that two bars both belong to 'localized' takes two different colours: blue vs red. Instead, I'd like to, for example, assign green to both "localized" pair-bars but two varying in tone. Assign blue but two different blues for the 'regional' so forth so on.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. How to widen the space between the pair-bars. I'd like to have more space between clusters while pair-bars stick together with no space between as it is now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot.png" style="width: 573px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35142i521A39D86C59AA3A/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot.png" alt="plot.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time indeed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA PLOT1;
INPUT METHOD AGEGRP STAGE1 SURV; 
DATALINES;
1 1 2 99	
1 1 3 100	
1 1 4 89	
1 2 2 96	
1 2 3 96	
1 2 4 81	
1 3 2 94	
1 3 3 93	
1 3 4 78	
1 4 2 89	
1 4 3 89	
1 4 4 77	
2 1 2 95
2 1 3 92
2 1 4 65
2 2 2 87
2 2 3 85
2 2 4 60
2 3 2 80
2 3 3 79
2 3 4 54
2 4 2 63
2 4 3 67
2 4 4 41
;
PROC FORMAT; &lt;BR /&gt;VALUE STAGE &lt;BR /&gt;2='Localized'&lt;BR /&gt;3='Regional'&lt;BR /&gt;4='Distant'&lt;BR /&gt;;&lt;BR /&gt;VALUE AGEGRP&lt;BR /&gt;1='00-44yr old'&lt;BR /&gt;2='45-59yr old'&lt;BR /&gt;3='60-74yr old'&lt;BR /&gt;4='75+yr old'&lt;BR /&gt;;&lt;BR /&gt;RUN;
ods graphics ON;
ods graphics/width=6in height=4in;
proc sgpanel data=plot1;
 panelby agegrp /novarname colheaderpos=bottom COLUMNS=4 onepanel;
 styleattrs DATACONTRASTCOLORS=(BLUE green red);
 vbar stage1 / response=surv stat=sum group=method nostatlabel 
 groupdisplay=cluster;
 keylegend "Empirical" "Midpoint" / across=1 position=Top;
 format agegrp agegrp. stage1 stage.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jan 2020 02:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615160#M179923</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-01-05T02:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgpanel color cluster bars by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615166#M179928</link>
      <description>&lt;P&gt;1. One work-around I could think of is using the COLORRESPONSE option to color the different combinations of STAGE1 and METHOD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data plot2;
	set plot1;
	colorvar=5*stage1+2*method;
run;

ods graphics ON;
ods graphics/width=6in height=4in;

proc sgpanel data=plot2;
	panelby agegrp / novarname colheaderpos=bottom COLUMNS=4 onepanel;
	vbar stage1 / response=surv stat=sum nostatlabel group=method 
		groupdisplay=cluster barwidth=0.7
		colorresponse=colorvar colormodel=(lightcoral lightgreen darkblue);
	keylegend "Empirical" "Midpoint" / across=1 position=Top;
	format agegrp agegrp. stage1 stage.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's tricky is picking colors and a combination function (5*STAGE1+2*METHOD) that allow for distinction in the colors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. The option for spacing between clusters is called BARWIDTH. Here, BARWIDTH=0.7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sg1.png" style="width: 576px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35144i8EF16718AFB016C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="sg1.png" alt="sg1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2020 06:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615166#M179928</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-01-05T06:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgpanel color cluster bars by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615178#M179933</link>
      <description>&lt;P&gt;You need to change data sometime .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA PLOT1;
INPUT METHOD AGEGRP STAGE1 SURV; 
DATALINES;
1 1 2 99	
1 1 3 100	
1 1 4 89	
1 2 2 96	
1 2 3 96	
1 2 4 81	
1 3 2 94	
1 3 3 93	
1 3 4 78	
1 4 2 89	
1 4 3 89	
1 4 4 77	
2 1 2 95
2 1 3 92
2 1 4 65
2 2 2 87
2 2 3 85
2 2 4 60
2 3 2 80
2 3 3 79
2 3 4 54
2 4 2 63
2 4 3 67
2 4 4 41
;

proc summary data=plot1 nway;
class agegrp stage1 method;
var surv;
output out=have(drop=_:) sum=;
run;
proc transpose data=have out=want prefix=_;
by agegrp stage1;
id method;
var surv;
run;
PROC FORMAT; 
VALUE STAGE 
2='Localized'
3='Regional'
4='Distant';
VALUE AGEGRP
1='00-44yr old'
2='45-59yr old'
3='60-74yr old'
4='75+yr old';
RUN;
ods graphics ON;
ods graphics/width=6in height=4in;
proc sgpanel data=want;
styleattrs datacolors=(blue green red)  datacontrastcolors=(blue green red)  ;
 panelby agegrp /novarname colheaderpos=bottom COLUMNS=4 onepanel;
 vbar stage1 /group=stage1 response=_1 nostatlabel discreteoffset=-0.1 barwidth=0.2;
 vbar stage1 /group=stage1 response=_2 nostatlabel discreteoffset=0.1  barwidth=0.2;
 keylegend "Empirical" "Midpoint" / across=1 position=Top;
 format agegrp agegrp. stage1 stage.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="x.png" style="width: 576px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35147i8F72114D94F04FE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="x.png" alt="x.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2020 11:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615178#M179933</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-01-05T11:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgpanel color cluster bars by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615202#M179941</link>
      <description>&lt;P&gt;Thanks, both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used Unison's approach by modifying my data a tiny bit. Combination of &lt;CODE class=" language-sas"&gt;barwidth=1 CLUSTERWIDTH=0.7&lt;/CODE&gt; did the trick. I ran out of time to figure out the legends for the bars. Then I ended up cheating the texts on the bar using the Microsoft Paint program. Please let me know if anyone knows the proper way of doing it using SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot new.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35149i4CE25AFC4A284296/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot new.png" alt="plot new.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final code is below in case if it helps anyone in the future.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA PLOT1;
INPUT METHOD AGEGRP STAGE1 SURV; 
DATALINES;
1 1 2 95
1 1 3 92
1 1 4 65
1 2 2 87
1 2 3 85
1 2 4 60
1 3 2 80
1 3 3 79
1 3 4 54
1 4 2 63
1 4 3 67
1 4 4 41
2 1 2 99
2 1 3 100
2 1 4 89
2 2 2 96
2 2 3 96
2 2 4 81
2 3 2 94
2 3 3 93
2 3 4 78
2 4 2 89
2 4 3 89
2 4 4 77
;
PROC FORMAT; 
VALUE STAGE 
2='Localized'
3='Regional'
4='Distant';
VALUE AGEGRP
1='00-44yr old'
2='45-59yr old'
3='60-74yr old'
4='75+yr old';
RUN;

data plot2; set plot1;
	colorvar=5*stage1+2*method;
run;

ods graphics ON;
ods graphics/width=12in height=4in;

proc sgpanel data=plot2 noautolegend;
	panelby agegrp / novarname colheaderpos=bottom COLUMNS=4 onepanel;
	hbar stage1 / response=surv stat=sum nostatlabel group=method 
		groupdisplay=cluster barwidth=1 CLUSTERWIDTH=0.7 datalabel dataskin=matte
		colorresponse=colorvar colormodel=(lightcoral lightgreen blue);
rowaxis label=' '; 
colaxis label='Agreement rate within 1 month (%)' grid; 
	format agegrp agegrp. stage1 stage.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jan 2020 15:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgpanel-color-cluster-bars-by-groups/m-p/615202#M179941</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-01-05T15:53:09Z</dc:date>
    </item>
  </channel>
</rss>

