<?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: proc sql: how to do full join, keep all columns and rows from these two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277711#M55794</link>
    <description>&lt;P&gt;This reply is very confusing:&lt;/P&gt;
&lt;P&gt;- &amp;nbsp;the coalesce function is not used for the join&lt;/P&gt;
&lt;P&gt;- you already use&amp;nbsp;&amp;nbsp; on a.id = b.id&lt;/P&gt;
&lt;P&gt;Please provide an example with&amp;nbsp;5-record input&amp;nbsp;tables and the expected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:08:03 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2016-06-15T23:08:03Z</dc:date>
    <item>
      <title>proc sql: how to do full join, keep all columns and rows from these two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277389#M55687</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 create table want as
 select date, dea (dec.id=tap.id) as indic,
 (dec.id ~=".") as decid,
 (tap.id ~=".") as tapid,
 coalesce (dec.id, tap.id) as id
 from dec full join tap on dec.id=tap.id;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have two datasets that I want to merge. dataset dec has 240000 obs, dataset tap has 14000 obs. They do have 13000 in common.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to merge these two. My above code can generate a table, but cannot keep all these columns that I need.&lt;/P&gt;&lt;P&gt;I can keep all columns and all obs, that is 24000.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 40 varibles, that I prefer to keep 15 variables of these 40 from dataset tap , and want to keep 5 varibles from dec. So it is not wise to type. Among them, some IDs are common.&lt;/P&gt;&lt;P&gt;Can anybody give advice?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 21:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277389#M55687</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-06-14T21:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: how to do full join, keep all columns and rows from these two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277413#M55695</link>
      <description>&lt;P&gt;If you use SQL, you have no option but to&amp;nbsp;type each variable name, unless you just use&amp;nbsp;*.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An option around this&amp;nbsp;constraint&amp;nbsp;is to use the keep= data set option to reduce the number of variables.&lt;/P&gt;
&lt;P&gt;keep= allows you to use the&amp;nbsp;colon, dash and double-dash list shortcuts such as&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR:&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp; VAR1-VAR10&amp;nbsp;&amp;nbsp; &amp;nbsp;or&amp;nbsp;&amp;nbsp; VARA--ID .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use a data step merge instead of SQL, you have more flexibility in terms of&amp;nbsp;implicitly naming variables, and you can monitor and count which observations for which table are kept or dropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 00:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277413#M55695</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-06-15T00:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: how to do full join, keep all columns and rows from these two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277561#M55754</link>
      <description>&lt;P&gt;Thanks. But the problem is, I want to keep COALESCE function, and I want to keep all these 240000 obs&lt;/P&gt;&lt;P&gt;if I just use a regular full join, I do not know how to add coalesce funtion,&lt;/P&gt;&lt;P&gt;when i use&lt;/P&gt;&lt;P&gt;on a.ID=b.ID, I am afriad that I lose obs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 14:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277561#M55754</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-06-15T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: how to do full join, keep all columns and rows from these two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277711#M55794</link>
      <description>&lt;P&gt;This reply is very confusing:&lt;/P&gt;
&lt;P&gt;- &amp;nbsp;the coalesce function is not used for the join&lt;/P&gt;
&lt;P&gt;- you already use&amp;nbsp;&amp;nbsp; on a.id = b.id&lt;/P&gt;
&lt;P&gt;Please provide an example with&amp;nbsp;5-record input&amp;nbsp;tables and the expected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-how-to-do-full-join-keep-all-columns-and-rows-from/m-p/277711#M55794</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-06-15T23:08:03Z</dc:date>
    </item>
  </channel>
</rss>

