<?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: overlay histograms only for some group members in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/666565#M20160</link>
    <description>&lt;P&gt;Please try below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input score ts$ tc$ matching;
cards;
180 A B 0
200 B B 1
360 A B 0
420 A A 1
500 B A 0
234 B B 1
461 B A 0
;

data want;
set have;
if ts='A' and tc='B' then group='1';
if ts='B' and tc='B' then group='2';
if ts='B' and tc='A' then group='3';
if ts='A' and tc='A' then group='4'; 
run;

proc sgplot data=want;  
vbar group/response=score; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 631px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46847iBB12A62BD86BD95D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jul 2020 08:43:48 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-07-02T08:43:48Z</dc:date>
    <item>
      <title>overlay histograms only for some group members</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/666558#M20159</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a data set as below: I want to compare the histograms of the scores of two different groups with all possible combinations. For example,&lt;/P&gt;
&lt;P&gt;comparison of&amp;nbsp; scores for groups ts=A and tc=B;&lt;/P&gt;
&lt;P&gt;comparison of&amp;nbsp; scores&amp;nbsp;for groups ts=B and tc=B;&lt;/P&gt;
&lt;P&gt;comparison of&amp;nbsp; scores for&amp;nbsp; groups ts=B and tc=A;&lt;/P&gt;
&lt;P&gt;comparison of&amp;nbsp; scores for groups ts=A and tc=A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, there will be 4 different overlaying histograms. Could you help to draw overlaying histograms of these groups' scores?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;score ts tc matching&lt;BR /&gt;180 A B 0&lt;BR /&gt;200 B B 1&lt;BR /&gt;360 A B 0&lt;BR /&gt;420 A A 1&lt;BR /&gt;500 B A 0&lt;BR /&gt;234 B B 1&lt;BR /&gt;461 B A 0&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 07:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/666558#M20159</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-07-02T07:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: overlay histograms only for some group members</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/666565#M20160</link>
      <description>&lt;P&gt;Please try below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input score ts$ tc$ matching;
cards;
180 A B 0
200 B B 1
360 A B 0
420 A A 1
500 B A 0
234 B B 1
461 B A 0
;

data want;
set have;
if ts='A' and tc='B' then group='1';
if ts='B' and tc='B' then group='2';
if ts='B' and tc='A' then group='3';
if ts='A' and tc='A' then group='4'; 
run;

proc sgplot data=want;  
vbar group/response=score; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 631px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46847iBB12A62BD86BD95D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 08:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/666565#M20160</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-07-02T08:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: overlay histograms only for some group members</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/667437#M20173</link>
      <description>&lt;P&gt;I don't think the problem is formulated correctly. To get two overlayed histograms, you need some observations that belong to one group and other (disjoint) observations in another group. But in your example,&amp;nbsp; ts='A' includes observations for both tc='A' and tc='B'. So you can't overlay the histograms. There are not four histograms to overlay.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things that you can do:&lt;/P&gt;
&lt;P&gt;1. create two overlapping histograms. The first compares tc='A' and tc='B' given that ts='A'. The second&amp;nbsp;compares tc='A' and tc='B' given that ts='B'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. create a panel of histograms of the four groups, which are the joint levels of (ts, tc).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both of these options are shown below on some simulated data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
do ts = 'A', 'B';
   do tc = 'A', 'B';
      do k=1 to 50;
         score = 3*(ts='A') + -1*(tc='A') + rand("Normal");
         output;
      end;
   end;
end;
run;

/* 1. Given a value for ts, overlay the distributions for levels of tc */
proc sgplot data=Have;
by ts;
histogram score / group=tc transparency=0.5;
run;

/* 2. Panel the four distributions */
data Want;
set Have;
group = cats("ts=", ts, "; tc=", tc); 
run;

proc sgpanel data=Want;
panelby group / onepanel columns=1 novarname;
histogram score;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2020 13:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/overlay-histograms-only-for-some-group-members/m-p/667437#M20173</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-07-07T13:30:24Z</dc:date>
    </item>
  </channel>
</rss>

