<?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 exclude group if it involves different members in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476748#M122697</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could try sorting the data and then use by-group processing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = have;
   by group member;
run;

data want(drop = member_count);
   member_count = 0;

   do until(last.group);
      set have;
      by group member;

      member_count = member_count + first.member;
   end;

   do until(last.group);
      set have;
      by group member;

      if member_count = 1 then
         output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first do loop checks how many different members there are for the group being processed and then the second loop outputs the data if there was only one member for the same group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jul 2018 11:35:07 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2018-07-10T11:35:07Z</dc:date>
    <item>
      <title>how to exclude group if it involves different members</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476737#M122693</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;I am a beginner of SAS and processing a large data set. Let me show my problem by an example, there are three groups A, B and C. and each group have different number (or names) such as&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;Group Member;
A 1
A 1
A 2
B 1
B 1
B 1
C 2
C 1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to exclude Group A and C from my sample, as there are two different members (i.e., 1 and 2) in same group. And include Group B in my sample, as all member in Group B are same.&lt;/P&gt;&lt;P&gt;I really want to show some codes, but I have no idea about it. Could you please give me some suggestions about it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;France&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 11:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476737#M122693</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-07-10T11:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude group if it involves different members</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476748#M122697</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could try sorting the data and then use by-group processing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data = have;
   by group member;
run;

data want(drop = member_count);
   member_count = 0;

   do until(last.group);
      set have;
      by group member;

      member_count = member_count + first.member;
   end;

   do until(last.group);
      set have;
      by group member;

      if member_count = 1 then
         output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first do loop checks how many different members there are for the group being processed and then the second loop outputs the data if there was only one member for the same group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 11:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476748#M122697</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-07-10T11:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude group if it involves different members</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476760#M122706</link>
      <description>&lt;P&gt;With proc sql :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Group $ Member;
cards;
A 1
A 1
A 2
B 1
B 1
B 1
C 2
C 1
;
run;

proc sql;
    CREATE TABLE want AS
	SELECT *
	FROM HAVE
	GROUP BY Group
	HAVING count(DISTINCT Member)=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2018 12:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-exclude-group-if-it-involves-different-members/m-p/476760#M122706</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-07-10T12:25:54Z</dc:date>
    </item>
  </channel>
</rss>

