<?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 Vertical SQL combine in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580650#M13589</link>
    <description>&lt;P&gt;I'm learning about combining datasets vertically using SQL.&amp;nbsp;&amp;nbsp; I'm trying to understand why the output includes a row where X=2 but no row where X=3.&amp;nbsp;&amp;nbsp; Anyone have any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; X &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; A &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1a&lt;/P&gt;&lt;P&gt;1a&lt;/P&gt;&lt;P&gt;1b&lt;/P&gt;&lt;P&gt;2c&lt;/P&gt;&lt;P&gt;3v&lt;/P&gt;&lt;P&gt;4e&lt;/P&gt;&lt;P&gt;6g&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; X &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; B &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1x&lt;/P&gt;&lt;P&gt;2y&lt;/P&gt;&lt;P&gt;3z&lt;/P&gt;&lt;P&gt;3v&lt;/P&gt;&lt;P&gt;5w&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;except&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2019 20:06:55 GMT</pubDate>
    <dc:creator>Batman</dc:creator>
    <dc:date>2019-08-12T20:06:55Z</dc:date>
    <item>
      <title>Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580650#M13589</link>
      <description>&lt;P&gt;I'm learning about combining datasets vertically using SQL.&amp;nbsp;&amp;nbsp; I'm trying to understand why the output includes a row where X=2 but no row where X=3.&amp;nbsp;&amp;nbsp; Anyone have any idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; X &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; A &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1a&lt;/P&gt;&lt;P&gt;1a&lt;/P&gt;&lt;P&gt;1b&lt;/P&gt;&lt;P&gt;2c&lt;/P&gt;&lt;P&gt;3v&lt;/P&gt;&lt;P&gt;4e&lt;/P&gt;&lt;P&gt;6g&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; X &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; B &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1x&lt;/P&gt;&lt;P&gt;2y&lt;/P&gt;&lt;P&gt;3z&lt;/P&gt;&lt;P&gt;3v&lt;/P&gt;&lt;P&gt;5w&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;except&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 20:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580650#M13589</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2019-08-12T20:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580657#M13590</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9248"&gt;@Batman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are basically asking the SQL processor to exclude records that match two and only output the nonmatches from one&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, since you didn't use ALL i.e except all, you are telling SQL to do a double pass to exclude duplicate records in the nonmatches from one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In essence, this is what you are doing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Set Difference&lt;/STRONG&gt;&lt;BR /&gt;Difference between sets is denoted by ‘A – B’, is the set containing elements of set A but not in B. i.e all elements of A except the element of B.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://media.geeksforgeeks.org/wp-content/cdn-uploads/gq/2015/06/A-B.png" target="_blank" rel="noopener"&gt;&lt;IMG class="alignnone size-medium wp-image-17640" src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/gq/2015/06/A-B-300x186.png" border="0" alt="A-B" width="300" height="186" /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Above is the Venn Diagram of A-B.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 20:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580657#M13590</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-12T20:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580685#M13594</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;Since your only&amp;nbsp;&lt;STRONG&gt;common&lt;/STRONG&gt; variable between the data sets is X that is the only variable considered for the comparison. The variable A will not be compared to B for determining inclusion/exclusion with the Except operation.&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;Name B to A in the set Two and see what happens.&lt;/STRIKE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, it is not a good idea to start your datalines with a blank unless you really truly actually want to have a row of missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 14:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580685#M13594</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-13T14:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580707#M13598</link>
      <description>&lt;P&gt;Contrary to what is stated above (sorry &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;), SQL set operations &lt;U&gt;without the CORR keyword&lt;/U&gt; operate on columns by positions, not by name. So the comparison involves column A against column B. The names are taken from the first table involved. So 2c is kept because it is different from 2y but 3v is removed because it is present in table two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try EXCEPT CORR and see what happens.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 04:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580707#M13598</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-08-13T04:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580830#M13610</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Contrary to what is stated above (sorry &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;), SQL set operations &lt;U&gt;without the CORR keyword&lt;/U&gt; operate on columns by positions, not by name. So the comparison involves column A against column B. The names are taken from the first table involved. So 2c is kept because it is different from 2y but 3v is removed because it is present in table two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try EXCEPT CORR and see what happens.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I sit corrected. Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 14:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580830#M13610</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-13T14:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580838#M13611</link>
      <description>&lt;P&gt;Because '2c' is in one and not in two, but the only value with X=3 in one is '3v' and that value is in two so it is deleted by EXCEPT.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 15:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580838#M13611</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-13T15:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580873#M13615</link>
      <description>&lt;P&gt;Ok, that makes sense, why is the additional value of "1a" also dropped.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 16:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580873#M13615</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2019-08-13T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Vertical SQL combine</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580876#M13616</link>
      <description>&lt;P&gt;SQL is a set operation language.&amp;nbsp; In general a "SET" of values does not include duplicate values. So it makes no sense to have two exact duplicates be the result of such a set operation.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 16:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Vertical-SQL-combine/m-p/580876#M13616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-13T16:18:04Z</dc:date>
    </item>
  </channel>
</rss>

