<?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 sgplot or sgpanel to visual group and subgroup in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948684#M25085</link>
    <description>&lt;P&gt;Something like the following should work for you. By splitting the treatment into two bar charts, it gives you the opportunity to assign two different sets of colors to the severity variable:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-10-22 at 10.05.15 PM.png" style="width: 773px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101720i78BBCE631BCFBCD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-10-22 at 10.05.15 PM.png" alt="Screenshot 2024-10-22 at 10.05.15 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
length aeterm $ 10;
input aeterm $ treatment $  aesev $ percentage;
treatment1 = ifc(treatment ="TRT01", "TRT01", "     ");
treatment2 = ifc(treatment ="TRT02", "TRT02", "     ");
aesev2 = aesev;
datalines;
ABDOMINAL TRT01  MILD 3
ABDOMINAL TRT01 MODERATE 1
ABDOMINAL TRT02  SEVERE 8
BRONCHITIS TRT01  SEVERE 22
BRONCHITIS TRT02  MILD 11
BRONCHITIS TRT01  MILD 25
COUGH TRT01 MILD 9
COUGH TRT02 MILD 23
;
run;

data attrmap;
    length Value $ 8;
    input ID $ Value $ FillColor $ LineColor $;
    cards;
    t1 MILD     cxf8d4c1 cxe97132
    t1 MODERATE cxf2aa84 cxe97132
    t1 SEVERE   cxe97132 cxe97132
    t2 MILD     cxb5c5d9 cx143f82
    t2 MODERATE cx6c8cb4 cx143f82
    t2 SEVERE   cx143f82 cx143f82
    ;
run;

proc sgpanel data=mydata dattrmap=attrmap;
    panelby aeterm / layout=columnlattice noheaderborder noborder colheaderpos=bottom novarname;
    vbarparm category=treatment1 response=percentage / group=aesev seglabel seglabelattrs=(color=white sizze=8) attrid=t1 name="t1";
    vbarparm category=treatment2 response=percentage / group=aesev2 seglabel seglabelattrs=(color=white size=8) attrid=t2 name="t2";
    colaxis display=none;
    keylegend "t1" / title="Treatment 1";
    keylegend "t2" / title="Treatment 2";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Oct 2024 02:11:57 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2024-10-23T02:11:57Z</dc:date>
    <item>
      <title>Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948650#M25082</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-10-22 104908.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101713i5B6675722FDD2004/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-10-22 104908.png" alt="Screenshot 2024-10-22 104908.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I want to generate a plot with SAS, like the upper picture. Any ideas or help are appreciated.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Panel by aeterm&amp;nbsp;to show separate panels for each adverse event.&lt;/LI&gt;&lt;LI&gt;Cluster the bars by treatment.&lt;/LI&gt;&lt;LI&gt;Use aesev&amp;nbsp;to differentiate colors within each cluster.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data mydata;&lt;BR /&gt;input aeterm $ treatment $&amp;nbsp; aesev $ percentage;&lt;BR /&gt;datalines;&lt;BR /&gt;ABDOMINAL TRT01&amp;nbsp; MILD 3&lt;BR /&gt;ABDOMINAL TRT01 MODERATE 1&lt;BR /&gt;ABDOMINAL TRT02&amp;nbsp; SEVERE 8&lt;BR /&gt;BRONCHITIS TRT01&amp;nbsp; SEVERE 22&lt;BR /&gt;BRONCHITIS TRT02&amp;nbsp; MILD 11&lt;BR /&gt;BRONCHITIS TRT01&amp;nbsp; MILD 25&lt;/P&gt;&lt;P&gt;COUGH TRT01 MILD 9&lt;/P&gt;&lt;P&gt;COUGH TRT02 MILD 23&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 19:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948650#M25082</guid>
      <dc:creator>Ran_</dc:creator>
      <dc:date>2024-10-22T19:38:40Z</dc:date>
    </item>
    <item>
      <title>Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948656#M25083</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-10-22 104908.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101716i745053B7906CF822/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-10-22 104908.png" alt="Screenshot 2024-10-22 104908.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;I want to generate a plot with SAS, like the upper picture. Any ideas or help are appreciated.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Panel by aeterm&amp;nbsp;to show separate panels for each adverse event.&lt;/LI&gt;&lt;LI&gt;Cluster the bars by treatment.&lt;/LI&gt;&lt;LI&gt;Use aesev&amp;nbsp;to differentiate colors within each cluster.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data mydata;&lt;BR /&gt;input aeterm $ treatment $&amp;nbsp; aesev $ percentage;&lt;BR /&gt;datalines;&lt;BR /&gt;ABDOMINAL TRT01&amp;nbsp; MILD 3&lt;BR /&gt;ABDOMINAL TRT01 MODERATE 1&lt;BR /&gt;ABDOMINAL TRT02&amp;nbsp; SEVERE 8&lt;BR /&gt;BRONCHITIS TRT01&amp;nbsp; SEVERE 22&lt;BR /&gt;BRONCHITIS TRT02&amp;nbsp; MILD 11&lt;BR /&gt;BRONCHITIS TRT01&amp;nbsp; MILD 25&lt;/P&gt;&lt;P&gt;COUGH TRT01 MILD 9&lt;/P&gt;&lt;P&gt;COUGH TRT02 MILD 23&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 19:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948656#M25083</guid>
      <dc:creator>Ran_</dc:creator>
      <dc:date>2024-10-22T19:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948684#M25085</link>
      <description>&lt;P&gt;Something like the following should work for you. By splitting the treatment into two bar charts, it gives you the opportunity to assign two different sets of colors to the severity variable:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-10-22 at 10.05.15 PM.png" style="width: 773px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101720i78BBCE631BCFBCD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-10-22 at 10.05.15 PM.png" alt="Screenshot 2024-10-22 at 10.05.15 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
length aeterm $ 10;
input aeterm $ treatment $  aesev $ percentage;
treatment1 = ifc(treatment ="TRT01", "TRT01", "     ");
treatment2 = ifc(treatment ="TRT02", "TRT02", "     ");
aesev2 = aesev;
datalines;
ABDOMINAL TRT01  MILD 3
ABDOMINAL TRT01 MODERATE 1
ABDOMINAL TRT02  SEVERE 8
BRONCHITIS TRT01  SEVERE 22
BRONCHITIS TRT02  MILD 11
BRONCHITIS TRT01  MILD 25
COUGH TRT01 MILD 9
COUGH TRT02 MILD 23
;
run;

data attrmap;
    length Value $ 8;
    input ID $ Value $ FillColor $ LineColor $;
    cards;
    t1 MILD     cxf8d4c1 cxe97132
    t1 MODERATE cxf2aa84 cxe97132
    t1 SEVERE   cxe97132 cxe97132
    t2 MILD     cxb5c5d9 cx143f82
    t2 MODERATE cx6c8cb4 cx143f82
    t2 SEVERE   cx143f82 cx143f82
    ;
run;

proc sgpanel data=mydata dattrmap=attrmap;
    panelby aeterm / layout=columnlattice noheaderborder noborder colheaderpos=bottom novarname;
    vbarparm category=treatment1 response=percentage / group=aesev seglabel seglabelattrs=(color=white sizze=8) attrid=t1 name="t1";
    vbarparm category=treatment2 response=percentage / group=aesev2 seglabel seglabelattrs=(color=white size=8) attrid=t2 name="t2";
    colaxis display=none;
    keylegend "t1" / title="Treatment 1";
    keylegend "t2" / title="Treatment 2";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Oct 2024 02:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948684#M25085</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2024-10-23T02:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948686#M25086</link>
      <description>&lt;P&gt;It looks like not really easy to get this kind of graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
input aeterm $ treatment $  aesev $ percentage;
datalines;
ABDOMINAL TRT01  MILD 0
ABDOMINAL TRT01 MODERATE 18
ABDOMINAL TRT01 SEVERE 60
ABDOMINAL TRT02  MILD 30
ABDOMINAL TRT02 MODERATE 60
ABDOMINAL TRT02  SEVERE 28
BRONCHITIS TRT01  MILD 41
BRONCHITIS TRT01  MODERATE 10
BRONCHITIS TRT01  SEVERE 0
BRONCHITIS TRT02  MILD 4
BRONCHITIS TRT02  MODERATE 30
BRONCHITIS TRT02  SEVERE 30
COUGH TRT01  MILD 40
COUGH TRT01  MODERATE 10
COUGH TRT01  SEVERE 30
COUGH TRT02  MILD 2
COUGH TRT02  MODERATE 4
COUGH TRT02  SEVERE 3
;
run;

proc sort data=mydata;by aeterm aesev;run;
data have;
merge mydata(where=(treatment='TRT01') rename=(percentage=pct_TRT01))
      mydata(where=(treatment='TRT02') rename=(percentage=pct_TRT02));
by aeterm aesev;
drop treatment;
run;



proc sgplot data=have noborder ;
styleattrs datacolors=(CXFEE0D2 CXFC9272 CXDE2D26 CXDEEBF7 CX9ECAE1 CX3182BD)
           datacontrastcolors=(CXFEE0D2 CXFC9272 CXDE2D26 CXDEEBF7 CX9ECAE1 CX3182BD);
vbarparm category=aeterm response=pct_TRT01/group=aesev seglabel seglabelfitpolicy=noclip barwidth=0.4 discreteoffset=-0.22 name='a' ;
vbarparm category=aeterm response=pct_TRT02/group=aesev seglabel seglabelfitpolicy=noclip barwidth=0.4 discreteoffset= 0.22 name='b' ;
xaxis tickstyle=inbetween display=(nolabel);
yaxis label='Percent';
keylegend 'a' /title='treatment1' noborder position=ne  ;
keylegend 'b' /title='treatment2' noborder position=ne ;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1729651016227.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101723i326F0DA925F5FFB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1729651016227.png" alt="Ksharp_0-1729651016227.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 02:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948686#M25086</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-23T02:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948725#M25087</link>
      <description>I really appreciate your help. I have been struggling with this for two days</description>
      <pubDate>Wed, 23 Oct 2024 12:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948725#M25087</guid>
      <dc:creator>Ran_</dc:creator>
      <dc:date>2024-10-23T12:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sgplot or sgpanel to visual group and subgroup</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948726#M25088</link>
      <description>I appreciate for your help.</description>
      <pubDate>Wed, 23 Oct 2024 12:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-sgplot-or-sgpanel-to-visual-group-and-subgroup/m-p/948726#M25088</guid>
      <dc:creator>Ran_</dc:creator>
      <dc:date>2024-10-23T12:33:09Z</dc:date>
    </item>
  </channel>
</rss>

