<?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: compare two tables and find the participants in common in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731966#M28465</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Maybe a PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Submit this as an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
 call streaminit(123);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data have2;
 call streaminit(456);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data want;
 merge have1(rename=(participant_group_number=participant_group_number1)) 
       have2(rename=(participant_group_number=participant_group_number2)); 
 by participant_sequence_number /* participant_group_number */;
run;

PROC FREQ data=want;
 tables participant_group_number1 * participant_group_number2;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think the LIST option may make the output easier to read for the original question:&lt;/P&gt;
&lt;PRE&gt;PROC FREQ data=want;
 tables participant_group_number1 * participant_group_number2/ list ;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Apr 2021 16:03:37 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-04-07T16:03:37Z</dc:date>
    <item>
      <title>compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731936#M28463</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two tables that both contain variables "participant sequence number" (value: 1-10000) and "participant group number" (value: 1-4). The sample of two tables are the same, so&amp;nbsp;"participant sequence number" are same in two tables, but the methods of grouping are different, so their corresponding "participant group number" may be different between two tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to know how many participants&amp;nbsp;that are included in the same group are in both tables? (for example， how many participants that are included in group 1 in the first table, and also included in group 1 in the second table) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you tell me how to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 14:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731936#M28463</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2021-04-07T14:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731963#M28464</link>
      <description>&lt;P&gt;Maybe a PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Submit this as an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
 call streaminit(123);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data have2;
 call streaminit(456);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data want;
 merge have1(rename=(participant_group_number=participant_group_number1)) 
       have2(rename=(participant_group_number=participant_group_number2)); 
 by participant_sequence_number /* participant_group_number */;
run;

PROC FREQ data=want;
 tables participant_group_number1 * participant_group_number2;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 16:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731963#M28464</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-07T16:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731966#M28465</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Maybe a PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Submit this as an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
 call streaminit(123);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data have2;
 call streaminit(456);
 do participant_sequence_number = 1 to 10000;
  participant_group_number=floor(rand('uniform')*5);
  output;
 end;
run;
data want;
 merge have1(rename=(participant_group_number=participant_group_number1)) 
       have2(rename=(participant_group_number=participant_group_number2)); 
 by participant_sequence_number /* participant_group_number */;
run;

PROC FREQ data=want;
 tables participant_group_number1 * participant_group_number2;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think the LIST option may make the output easier to read for the original question:&lt;/P&gt;
&lt;PRE&gt;PROC FREQ data=want;
 tables participant_group_number1 * participant_group_number2/ list ;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Apr 2021 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731966#M28465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-07T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731996#M28466</link>
      <description>&lt;P&gt;Or use SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
    a.participant_group_number, 
    count(*) as nbInBothTables
from
    have1 as a inner join
    have2 as b 
        on  a.participant_sequence_number = b.participant_sequence_number and 
            a.participant_group_number = b.participant_group_number
group by a.participant_group_number;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorPGStats_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;Using simulated data from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_1-1617817532932.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57059i6A548F5227C3BD0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_1-1617817532932.png" alt="PGStats_1-1617817532932.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, 07 Apr 2021 17:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/731996#M28466</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-04-07T17:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732024#M28467</link>
      <description>Thank you! this is helpful!</description>
      <pubDate>Wed, 07 Apr 2021 19:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732024#M28467</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2021-04-07T19:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732025#M28468</link>
      <description>Thank you!</description>
      <pubDate>Wed, 07 Apr 2021 19:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732025#M28468</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2021-04-07T19:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: compare two tables and find the participants in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732026#M28469</link>
      <description>&lt;P&gt;Thank you! This is helpful!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 19:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/compare-two-tables-and-find-the-participants-in-common/m-p/732026#M28469</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2021-04-07T19:12:05Z</dc:date>
    </item>
  </channel>
</rss>

