<?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: Issue with multiple rows of same participants in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641468#M30667</link>
    <description>&lt;P&gt;Thank you very much for the solution!!!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Apr 2020 20:28:39 GMT</pubDate>
    <dc:creator>sandrube</dc:creator>
    <dc:date>2020-04-20T20:28:39Z</dc:date>
    <item>
      <title>Issue with multiple rows of same participants</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641455#M30665</link>
      <description>&lt;P&gt;I'm looking how I can keep only those with var1=1 and var2=1. If one participants has var1=1 and var2=1, I was to keep all rows of the participants.&lt;/P&gt;&lt;P&gt;This is the initial dataset&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
infile cards missover;
input id var1 var2;
cards;
11 1 0
11 1 0
12 1 1
12 1 1
12 0 1
13 1 1
14 0 1
15 1 1
16 1 1
17 0 1
17 0 1
17 1 1
17 0 0
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The final dataset should be like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new1;
infile cards missover;
input id var1 var2;
cards;
12 1 1
12 1 1
12 0 1
13 1 1
15 1 1
16 1 1
17 0 1
17 0 1
17 1 1
17 0 0
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 20:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641455#M30665</guid>
      <dc:creator>sandrube</dc:creator>
      <dc:date>2020-04-20T20:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with multiple rows of same participants</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641461#M30666</link>
      <description>&lt;P&gt;This is a good example of applying a self-merge of a subset of a dataset with the entire dataset, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
infile cards missover;
input id var1 var2;
cards;
11 1 0
11 1 0
12 1 1
12 1 1
12 0 1
13 1 1
14 0 1
15 1 1
16 1 1
17 0 1
17 0 1
17 1 1
17 0 0
run;

data new1;
  merge new (where=(var1=1 and var2=1)  in=inkeep)
        new;
  by id;
  if inkeep;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does this work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The MERGE with a BY statement tells SAS to match records (based on ID) satisfying the first argument of merge with the second argument.&lt;/LI&gt;
&lt;LI&gt;The "IN=" parameter sets the dummy variable INKEEP to 1 if the match-merge has any observation satisfying "var1=1 and var2=1".&lt;/LI&gt;
&lt;LI&gt;Now you might be worried about a "collision" of data values.&amp;nbsp; For example the first obs matching var1=1 and var2=1 might not be the first obs overall for a given ID.&amp;nbsp; But MERGE works such that data values in the 2nd argument superseded the data values in the first argument for variable having the same name.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 20:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641461#M30666</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-04-20T20:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with multiple rows of same participants</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641468#M30667</link>
      <description>&lt;P&gt;Thank you very much for the solution!!!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 20:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Issue-with-multiple-rows-of-same-participants/m-p/641468#M30667</guid>
      <dc:creator>sandrube</dc:creator>
      <dc:date>2020-04-20T20:28:39Z</dc:date>
    </item>
  </channel>
</rss>

