<?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 vertical join in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600184#M16570</link>
    <description>&lt;P&gt;Can I use functions with an sql vertical join?&amp;nbsp; &amp;nbsp;Something such as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a, sum(b) as tot_b&lt;/P&gt;&lt;P&gt;&amp;nbsp; from X&lt;/P&gt;&lt;P&gt;&amp;nbsp; union&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a, sum(b) as tot_b&lt;/P&gt;&lt;P&gt;&amp;nbsp; from Y&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2019 21:24:21 GMT</pubDate>
    <dc:creator>Batman</dc:creator>
    <dc:date>2019-10-29T21:24:21Z</dc:date>
    <item>
      <title>SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600184#M16570</link>
      <description>&lt;P&gt;Can I use functions with an sql vertical join?&amp;nbsp; &amp;nbsp;Something such as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a, sum(b) as tot_b&lt;/P&gt;&lt;P&gt;&amp;nbsp; from X&lt;/P&gt;&lt;P&gt;&amp;nbsp; union&lt;/P&gt;&lt;P&gt;&amp;nbsp; select a, sum(b) as tot_b&lt;/P&gt;&lt;P&gt;&amp;nbsp; from Y&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600184#M16570</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2019-10-29T21:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600186#M16571</link>
      <description>&lt;P&gt;How do you define a Vertical Join?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600186#M16571</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-29T21:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600187#M16572</link>
      <description>&lt;P&gt;The set operator "union" allows you to append two datasets in SQL&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600187#M16572</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2019-10-29T21:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600191#M16575</link>
      <description>&lt;P&gt;Yes, you can use summary functions. Note that each subquery is processed separately. In your example, the group by clause will refer only to the second subquery. Without a group by clause, the first subquery will remerge tot_b with every row from table X.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600191#M16575</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-10-29T21:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600751#M16635</link>
      <description>&lt;P&gt;If there are some values of variable "a" that are in both input datasets X and Y, can values of variable "b" be grouped by "a" in the same query (i.e. the one where they are joined)?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 17:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600751#M16635</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2019-10-31T17:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: SQL vertical join</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600762#M16637</link>
      <description>&lt;P&gt;First, there is no such thing as a "vertical join". UNION ALL does a &lt;U&gt;concatenation&lt;/U&gt; of tables. UNION without ALL eliminates duplicates. CORR requests matching by variable names (only same named variables are concatenated).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it seems like you want to concatenate X and Y first and then GROUP BY to get the sums. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select  a, sum(b) as tot_b
from 
  (select a, b
   from X
   union all corr
   select a, b
   from Y)
 group by a;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested. Not sure about the use of parentheses here. You might have to experiment.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 18:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-vertical-join/m-p/600762#M16637</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-10-31T18:13:26Z</dc:date>
    </item>
  </channel>
</rss>

