<?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: How to differentiate color bars at the same timepoint using vbar with proc sgplot? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742204#M36107</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339070"&gt;@mounikag&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if the attributes in the DATTRMAP= dataset can depend on BY values. I've modified your code (using sample code from &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2019/06/12/converting-from-sas-graph-to-ods-graphics-color-control/" target="_blank" rel="noopener"&gt;a "Graphically Speaking" blog post&lt;/A&gt;) so that only "Pain" data are used (no BY-group processing).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input rowlbl $ timepoint &amp;amp;$12. grade $ nsubjects;
datalines;
Pain  Day 1 30 min   mild         3
Pain  Day 1 30 min   moderate     1
Pain  Day 1 PM       mild         5
Pain  Day 1 PM       moderate     1
Pain  Day 2          mild         8
Pain  Day 2          moderate     2
Pain  Day 3          mild         9
Pain  Day 3          moderate     2
Pain  Day 4          mild         4
Pain  Day 5          mild         1
;

data pain_attrmap;
length ID $8 value $20 fillcolor $8 linecolor $10;
ID='Pain'; linecolor='black';
input value fillcolor;
cards;
mild     #017DBA
moderate #97C93D
;

ods graphics / height=400px width=800px;
title 'Pain';
proc sgplot data=have dattrmap=pain_attrmap noborder;
vbarparm category=timepoint response=nsubjects / group=grade barwidth=0.5 attrid=Pain;
xaxis label='Timepoints' valueattrs=(size=8)
      values=('Day 1 30 min' 'Day 1 PM' 'Day 2' 'Day 3' 'Day 4' 'Day 5' 'Day 6' 'Day 7' 'Day 7+')
      display=(noline noticks);
yaxis values=(0 to 12) label='Number of Subjects' display=(noline noticks) grid gridattrs=(color='#D2E2F4');
keylegend / noborder title="" location=outside position=bottom across=9 sortorder=ascending;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pain.png" style="width: 800px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59562iF2D53E18A0C90C36/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pain.png" alt="Pain.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>Tue, 18 May 2021 15:15:39 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-05-18T15:15:39Z</dc:date>
    <item>
      <title>How to differentiate color bars at the same timepoint using vbar with proc sgplot?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742056#M36090</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to specfiy different colors for a barchart based on nsubjects(no.of subjects) and grades at different timepoints . For example, pain with grade1 at day 1 pm should be blue color and pain with grade2 at day 1pm should be green color. Here is the code and data I've used so to produce a chart&amp;nbsp; but the colors are not producing in the output :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data x;
input rowlbl$ timepoint$ grade$ nsubjects$;
datalines;
pain  day 1 30 min   mild         4&lt;BR /&gt;pain  day 1 Pm       mild   &lt;BR /&gt;pain  day 1 pm       moderate     4&lt;BR /&gt;pain  day 2          mild         4&lt;BR /&gt;pain  day 2          moderate     4&lt;BR /&gt;pain  day 3          mild         4 &lt;BR /&gt;pain  day 4          moderate     4 
;
run;&lt;/PRE&gt;
&lt;P&gt;Here is the code Iam using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;*For consistent colors of vbars;&lt;BR /&gt;proc sort data=final out=map nodupkey;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by rowlbl grade;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data attrmap;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set map(keep=rowlbl grade);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;length fillcolor $8. ID $8. value $20. linecolor $10;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if upcase(rowlbl)='REDNESS' then fillcolor ='#cf46b7' ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if upcase(rowlbl)='SWELLING' then fillcolor='#DF7F70';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if upcase(rowlbl)='PAIN' and upcase(grade)='MILD' then fillcolor='#a82a09';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if upcase(rowlbl)='PAIN' and upcase(grade)='MODERATE' then fillcolor='#46e75e';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;id ='rowlbl';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;value = rowlbl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; linecolor='black';&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; keep id value fillcolor linecolor;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;by id value;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sgplot data=final dattrmap=attrmap;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;by rowlbl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; vbar tptn / response=nsubjs group=rowlbl name="Param" barwidth=0.5 attrid=rowlbl; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; xaxis label='Timepoints' valueattrs=(size=8) values=(0 to 8&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; valuesdisplay=('Day 1 30 Min' 'Day 1 PM' 'Day 2' 'Day 3' 'Day 4' &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Day 5' 'Day 6' 'Day 7' 'Day 7+'); *valuesformat=atpt.;* fitpolicy=rotatethin;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;yaxis values=(0 to 14 by 2) label='Number of Subjects' ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;keylegend "Param"/ noborder title="" location=outside position=bottom across=9 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sortorder=ascending;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final Ouput i need to get as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mounikag_1-1621310490608.png" style="width: 554px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59534i74C343B1B43D4502/image-dimensions/554x191?v=v2" width="554" height="191" role="button" title="mounikag_1-1621310490608.png" alt="mounikag_1-1621310490608.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please Provide your inputs whether if i am missing something . TIA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 04:06:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742056#M36090</guid>
      <dc:creator>mounikag</dc:creator>
      <dc:date>2021-05-18T04:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to differentiate color bars at the same timepoint using vbar with proc sgplot?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742177#M36104</link>
      <description>&lt;P&gt;If you expect a worked example please provide the actual data to plot or modify your example data set to match the plot code. Your SGPLOT references a data set not provided, uses variables not in the X data set : TPTN and NSUBJS .&lt;/P&gt;
&lt;P&gt;Your Sgplot code also has a missing ) for the VALUES option in the XAXIS statement.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 14:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742177#M36104</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-18T14:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to differentiate color bars at the same timepoint using vbar with proc sgplot?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742204#M36107</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339070"&gt;@mounikag&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if the attributes in the DATTRMAP= dataset can depend on BY values. I've modified your code (using sample code from &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2019/06/12/converting-from-sas-graph-to-ods-graphics-color-control/" target="_blank" rel="noopener"&gt;a "Graphically Speaking" blog post&lt;/A&gt;) so that only "Pain" data are used (no BY-group processing).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input rowlbl $ timepoint &amp;amp;$12. grade $ nsubjects;
datalines;
Pain  Day 1 30 min   mild         3
Pain  Day 1 30 min   moderate     1
Pain  Day 1 PM       mild         5
Pain  Day 1 PM       moderate     1
Pain  Day 2          mild         8
Pain  Day 2          moderate     2
Pain  Day 3          mild         9
Pain  Day 3          moderate     2
Pain  Day 4          mild         4
Pain  Day 5          mild         1
;

data pain_attrmap;
length ID $8 value $20 fillcolor $8 linecolor $10;
ID='Pain'; linecolor='black';
input value fillcolor;
cards;
mild     #017DBA
moderate #97C93D
;

ods graphics / height=400px width=800px;
title 'Pain';
proc sgplot data=have dattrmap=pain_attrmap noborder;
vbarparm category=timepoint response=nsubjects / group=grade barwidth=0.5 attrid=Pain;
xaxis label='Timepoints' valueattrs=(size=8)
      values=('Day 1 30 min' 'Day 1 PM' 'Day 2' 'Day 3' 'Day 4' 'Day 5' 'Day 6' 'Day 7' 'Day 7+')
      display=(noline noticks);
yaxis values=(0 to 12) label='Number of Subjects' display=(noline noticks) grid gridattrs=(color='#D2E2F4');
keylegend / noborder title="" location=outside position=bottom across=9 sortorder=ascending;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pain.png" style="width: 800px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59562iF2D53E18A0C90C36/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pain.png" alt="Pain.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>Tue, 18 May 2021 15:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-differentiate-color-bars-at-the-same-timepoint-using-vbar/m-p/742204#M36107</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-05-18T15:15:39Z</dc:date>
    </item>
  </channel>
</rss>

