<?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: select matched data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665195#M198854</link>
    <description>&lt;P&gt;What have you tried already?&lt;/P&gt;
&lt;P&gt;Either use a SQL inner join or a data step merge with the IN keyword.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;merge A (in=ina) B;&lt;/P&gt;
&lt;P&gt;by variable;&lt;/P&gt;
&lt;P&gt;if ina;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jun 2020 23:43:11 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-06-25T23:43:11Z</dc:date>
    <item>
      <title>select matched data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665193#M198853</link>
      <description>&lt;P&gt;I want to select all the information from data one based on the data two id.&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input id n;&lt;BR /&gt;datalines;&lt;BR /&gt;101 a&lt;BR /&gt;101 b&lt;BR /&gt;101 c&lt;BR /&gt;101 d&lt;BR /&gt;102 a&lt;BR /&gt;102 c&lt;BR /&gt;103 f&lt;BR /&gt;104 f&lt;BR /&gt;105 f&lt;BR /&gt;105 u&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data two;&lt;BR /&gt;input id;&lt;BR /&gt;datalines;&lt;BR /&gt;101&lt;BR /&gt;104&lt;BR /&gt;105&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;want:&lt;/P&gt;&lt;P&gt;101 a&lt;/P&gt;&lt;P&gt;101 b&lt;/P&gt;&lt;P&gt;101 c&lt;/P&gt;&lt;P&gt;104 f&lt;/P&gt;&lt;P&gt;105 f&lt;/P&gt;&lt;P&gt;105 u&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 23:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665193#M198853</guid>
      <dc:creator>lulu3</dc:creator>
      <dc:date>2020-06-25T23:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: select matched data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665195#M198854</link>
      <description>&lt;P&gt;What have you tried already?&lt;/P&gt;
&lt;P&gt;Either use a SQL inner join or a data step merge with the IN keyword.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;merge A (in=ina) B;&lt;/P&gt;
&lt;P&gt;by variable;&lt;/P&gt;
&lt;P&gt;if ina;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 23:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665195#M198854</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-25T23:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: select matched data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665197#M198856</link>
      <description>&lt;P&gt;And is the&lt;/P&gt;
&lt;P&gt;101 d&lt;/P&gt;
&lt;P&gt;missing from your Want data set a typo? If not a type then you will need to describe a rule for identifying that the record should be excluded.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 23:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665197#M198856</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-25T23:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: select matched data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665200#M198858</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id n $;
datalines;
101 a
101 b
101 c
101 d
102 a
102 c
103 f
104 f
105 f
105 u
;
run;

data two;
input id;
datalines;
101
104
105
;
run;

proc sql;
create table want as
select *
from one
where id in (select id from two);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jun 2020 00:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665200#M198858</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-26T00:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: select matched data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665253#M198883</link>
      <description>&lt;P&gt;You have two good solutions suggested: the datastep by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, and the SQL by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;. What you should chose depends:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;If your data TWO table only contains unique values of ID, the datastep is the fastest. This solution also assumes that both tables are sorted.&lt;/LI&gt;
&lt;LI&gt;If there are multiple rows with the same ID in TWO, the SQL solution immediately gives the right solution, and may be simpler to implement. And the data does not need to be sorted. If data ONE is very large and not sorted, the SQL solution may actually be faster than the datastep (which also needs time for sorting the large table).&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 26 Jun 2020 06:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-matched-data/m-p/665253#M198883</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-06-26T06:58:32Z</dc:date>
    </item>
  </channel>
</rss>

