<?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: Two Datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190695#M304495</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you want SQL and Except clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A name="a001362284"&gt;&lt;/A&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create NewTable as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from sql.a&lt;/P&gt;&lt;P&gt;&amp;nbsp; except&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from sql.b;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;is a general form of syntax to get a new table that is the first, sql.a for example, minus records in the second set, sql.b here.&lt;/P&gt;&lt;P&gt;This comparison looks at ALL values of ALL variables to exclude matches in the second set. If you have some some variables with different values for an otherwise similar record it won't get removed. In which case the approach is to identify the variables that uniquely identify each record, use them in the above step for the new table and then use a left join with the NewTable and the first data set. The left join can use the above syntax as a subquery as below where Idvar1 and 2 are sufficient to uniquely identify each record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create NewTable as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select b.*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp; select idvar1, idvar2 from sql.a&lt;/P&gt;&lt;P&gt;&amp;nbsp; except&lt;/P&gt;&lt;P&gt;&amp;nbsp; select idvar1, idvar2&amp;nbsp; from sql.b) as keep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join sql.a as b on keep.idvar1=b.idvar1 and keep.idvar2=b.idvar2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jul 2014 23:04:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-07-22T23:04:22Z</dc:date>
    <item>
      <title>Re: Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190694#M304494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.....I have two datasets of which one dataset is a sub dataset of the second dataset and both datasets have the same number of variables and the variables have exactly the same variable names. I would like to remove or exclude those records that are listed in the smaller subset from those records listed in the larger second dataset. I was wondering if a Proc Sql&amp;nbsp; with a left join or a Data Step with a Merge of the two datasets be the easier and most efficient way to achieve the end results. Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 21:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190694#M304494</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2014-07-22T21:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190695#M304495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you want SQL and Except clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A name="a001362284"&gt;&lt;/A&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create NewTable as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from sql.a&lt;/P&gt;&lt;P&gt;&amp;nbsp; except&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from sql.b;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;is a general form of syntax to get a new table that is the first, sql.a for example, minus records in the second set, sql.b here.&lt;/P&gt;&lt;P&gt;This comparison looks at ALL values of ALL variables to exclude matches in the second set. If you have some some variables with different values for an otherwise similar record it won't get removed. In which case the approach is to identify the variables that uniquely identify each record, use them in the above step for the new table and then use a left join with the NewTable and the first data set. The left join can use the above syntax as a subquery as below where Idvar1 and 2 are sufficient to uniquely identify each record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create NewTable as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select b.*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from (&lt;/P&gt;&lt;P&gt;&amp;nbsp; select idvar1, idvar2 from sql.a&lt;/P&gt;&lt;P&gt;&amp;nbsp; except&lt;/P&gt;&lt;P&gt;&amp;nbsp; select idvar1, idvar2&amp;nbsp; from sql.b) as keep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join sql.a as b on keep.idvar1=b.idvar1 and keep.idvar2=b.idvar2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 23:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190695#M304495</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-07-22T23:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190696#M304496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for you quick response and that worked perfectly and what I was hoping the end result would be.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 23:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-Two-Datasets/m-p/190696#M304496</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2014-07-22T23:44:12Z</dc:date>
    </item>
  </channel>
</rss>

