<?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: SAS SQL Union set operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327359#M73015</link>
    <description>&lt;P&gt;Union does not remove duplicates. &amp;nbsp;It merely appends the data in the subsequent step to the data in the current step. &amp;nbsp;Exactly the same as if you use set a b; in a datastep or proc append one set to another.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2017 12:38:12 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-01-25T12:38:12Z</dc:date>
    <item>
      <title>SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327352#M73012</link>
      <description>&lt;P&gt;Could someone please explain me how does the Union set operator work. Does it remove duplicates only from each individual dataset or does it remove overall duplicates from the resultant dataset as well?&lt;/P&gt;&lt;P&gt;I have read that while joining two datasets vertically using Union operator, the duplicates are dropped.&lt;/P&gt;&lt;P&gt;But when I used it to join two datasets, I got the duplicate rows in the final dataset!&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327352#M73012</guid>
      <dc:creator>gargi01</dc:creator>
      <dc:date>2017-01-25T12:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327354#M73013</link>
      <description>&lt;P&gt;It removes duplicates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
set sashelp.class (obs=5);
run;

data test2;
set sashelp.class (firstobs=5 obs=10);
run;

proc sql;
create table want as
select * from test1
union
select * from test2
;
quit;

proc print data=want noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See the result:&lt;/P&gt;
&lt;PRE&gt;Name       Sex    Age    Height    Weight

Alfred      M      14     69.0      112.5
Alice       F      13     56.5       84.0
Barbara     F      13     65.3       98.0
Carol       F      14     62.8      102.5
Henry       M      14     63.5      102.5
James       M      12     57.3       83.0
Jane        F      12     59.8       84.5
Janet       F      15     62.5      112.5
Jeffrey     M      13     62.5       84.0
John        M      12     59.0       99.5
&lt;/PRE&gt;
&lt;P&gt;Now, if you use &lt;FONT face="courier new,courier"&gt;union all&lt;/FONT&gt; instead of just &lt;FONT face="courier new,courier"&gt;union&lt;/FONT&gt;, you get this:&lt;/P&gt;
&lt;PRE&gt;Name       Sex    Age    Height    Weight

Alfred      M      14     69.0      112.5
Alice       F      13     56.5       84.0
Barbara     F      13     65.3       98.0
Carol       F      14     62.8      102.5
Henry       M      14     63.5      102.5
Henry       M      14     63.5      102.5
James       M      12     57.3       83.0
Jane        F      12     59.8       84.5
Janet       F      15     62.5      112.5
Jeffrey     M      13     62.5       84.0
John        M      12     59.0       99.5
&lt;/PRE&gt;
&lt;P&gt;Henry now appears two times.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327354#M73013</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-25T12:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327359#M73015</link>
      <description>&lt;P&gt;Union does not remove duplicates. &amp;nbsp;It merely appends the data in the subsequent step to the data in the current step. &amp;nbsp;Exactly the same as if you use set a b; in a datastep or proc append one set to another.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327359#M73015</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-25T12:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327361#M73016</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; I beg to differ. Please run my example.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327361#M73016</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-25T12:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327367#M73018</link>
      <description>&lt;P&gt;Quite true, union removes dups, union all does not.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/49925/what-is-the-difference-between-union-and-union-all" target="_blank"&gt;http://stackoverflow.com/questions/49925/what-is-the-difference-between-union-and-union-all&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327367#M73018</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-25T12:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS SQL Union set operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327368#M73019</link>
      <description>&lt;P&gt;People usually use &lt;FONT face="courier new,courier"&gt;union all&lt;/FONT&gt; to avoid the performance penalty caused by the sort distinct (by all! variables) that scans for the duplicates.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 12:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-SQL-Union-set-operator/m-p/327368#M73019</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-25T12:59:08Z</dc:date>
    </item>
  </channel>
</rss>

