<?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 SQL Union all issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497263#M131743</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am appending 4 tables with same variable names using SQL UNION and SET statement in datastep but its not giving me all the employee_names its missing few employees.&lt;/P&gt;
&lt;P&gt;What&amp;nbsp; i need is, getting all the records (for&amp;nbsp;&lt;SPAN&gt;employee_name, sponsor, projectcode and employee_region&lt;/SPAN&gt;) from all 4 tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please help me to resolve the issue and correct me if i missed something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt; create table TEMP as &lt;BR /&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table1&lt;BR /&gt;union all&lt;BR /&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table2&lt;/P&gt;
&lt;P&gt;union all&lt;/P&gt;
&lt;P&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table3&lt;/P&gt;
&lt;P&gt;union all&lt;/P&gt;
&lt;P&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from table4t;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test (keep= employee_name sponsor projectcode employee_region);&lt;BR /&gt;set table1 table2 table3 table4;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data test (keep= employee_name sponsor projectcode employee_region);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table1 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table2 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set &lt;/SPAN&gt;&lt;SPAN&gt;table3 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table4;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Sep 2018 07:45:20 GMT</pubDate>
    <dc:creator>Rahul_SAS</dc:creator>
    <dc:date>2018-09-20T07:45:20Z</dc:date>
    <item>
      <title>SQL Union all issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497263#M131743</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am appending 4 tables with same variable names using SQL UNION and SET statement in datastep but its not giving me all the employee_names its missing few employees.&lt;/P&gt;
&lt;P&gt;What&amp;nbsp; i need is, getting all the records (for&amp;nbsp;&lt;SPAN&gt;employee_name, sponsor, projectcode and employee_region&lt;/SPAN&gt;) from all 4 tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please help me to resolve the issue and correct me if i missed something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt; create table TEMP as &lt;BR /&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table1&lt;BR /&gt;union all&lt;BR /&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table2&lt;/P&gt;
&lt;P&gt;union all&lt;/P&gt;
&lt;P&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from&amp;nbsp;table3&lt;/P&gt;
&lt;P&gt;union all&lt;/P&gt;
&lt;P&gt;select&amp;nbsp; employee_name, sponsor, projectcode, employee_region from table4t;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test (keep= employee_name sponsor projectcode employee_region);&lt;BR /&gt;set table1 table2 table3 table4;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data test (keep= employee_name sponsor projectcode employee_region);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table1 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table2 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set &lt;/SPAN&gt;&lt;SPAN&gt;table3 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set table4;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 07:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497263#M131743</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2018-09-20T07:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Union all issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497279#M131753</link>
      <description>&lt;P&gt;No test data, can't do anything.&amp;nbsp; As for your question are all three methods returning the same amount of observations which is implied with "&lt;SPAN&gt;using SQL UNION and SET statement in datastep but its not giving me all the employee_names its missing few employees.".&amp;nbsp; If so then you have what you should expect from the set, each of the datasets appended together which is what this does:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data test (keep= employee_name sponsor projectcode employee_region);
set table1
    table2
    table3
    table4;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Do note however that you should only have one set statement followed by the datasets followed by a semicolon, otherwise you will get an error.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 08:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497279#M131753</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-20T08:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Union all issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497437#M131847</link>
      <description>&lt;P&gt;I would expect this&lt;/P&gt;
&lt;PRE&gt;data test (keep= employee_name sponsor projectcode employee_region);

set table1 

set table2 

set table3 

set table4;
run;
&lt;/PRE&gt;
&lt;P&gt;to have multiple errors about data set SET not found, unless you have created a data set named SET previously. In which case it would have been included 3 times&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 15:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Union-all-issue/m-p/497437#M131847</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-20T15:37:45Z</dc:date>
    </item>
  </channel>
</rss>

