<?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: Merge Multiple tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384310#M91750</link>
    <description>&lt;P&gt;So, my actural table contains more columns and I have twenty-one tables.&amp;nbsp;&amp;nbsp; Is there a way I could avoid looking through all of columns in each table and list all their column names in merging steps?&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 15:12:02 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2017-07-31T15:12:02Z</dc:date>
    <item>
      <title>Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384279#M91744</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 21 tables and I would like to merge them all into one table. Table 1 includes Date, ID, and Sale record. Table 2 includes Date, ID, and Sale price. Table 3 includes ID, Sale regions.&amp;nbsp;&amp;nbsp; I intend to create a final table only containing the unique column (sample list below). Please advise how to do it. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1 : Date, ID, Sale record, etc. (5 columns)&lt;/P&gt;
&lt;P&gt;Table 2: Date, Sale price, etc. (11 columns)&lt;/P&gt;
&lt;P&gt;Table 3: ID, Sale regions, etc. ( 16 columns)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final merged table: Date, ID, Sale record, Sale price, Sale Regions, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384279#M91744</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-31T14:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384284#M91745</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select
  a.date,
  a.id,
  a.sale_record,
  b.sale_price,
  c.sale_regions
from
  table1 a,
  table2 b,
  table3 c
where
  a.date = b.date and
  a.id = c.id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that does not work as intended, post your three example tables &lt;STRONG&gt;in a data step form&lt;/STRONG&gt; and an example for the expected result.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384284#M91745</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-31T14:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384286#M91746</link>
      <description>&lt;P&gt;You can merge datasets either using sql or data steps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table temp as 
    select a.*, b.price
    from table1 as a
    left join table2 as b
    on a.date = b.date;

    create table want as
     select a.* , b.region
     from temp as a
     left join table3 as b
    on a.ID = b.ID;
quit; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if you use data step to merge, you need two steps equivalent to above with sorting tables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by ID and/or DATE;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384286#M91746</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-31T15:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384291#M91747</link>
      <description>&lt;P&gt;I apologize that I didn't state clearly.&amp;nbsp;&amp;nbsp; My tables are more columns than I list below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1 : Date, ID, Sale record, etc. (5 columns)&lt;/P&gt;
&lt;P&gt;Table 2: Date, Sale price, etc. (11 columns)&lt;/P&gt;
&lt;P&gt;Table 3: ID, Sale regions, etc. ( 16 columns)&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384291#M91747</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-31T14:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384298#M91748</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I apologize that I didn't state clearly.&amp;nbsp;&amp;nbsp; My tables are more columns than I list below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table 1 : Date, ID, Sale record, etc. (5 columns)&lt;/P&gt;
&lt;P&gt;Table 2: Date, Sale price, etc. (11 columns)&lt;/P&gt;
&lt;P&gt;Table 3: ID, Sale regions, etc. ( 16 columns)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then add the additional columns to the SQL code as needed.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384298#M91748</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-31T15:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384310#M91750</link>
      <description>&lt;P&gt;So, my actural table contains more columns and I have twenty-one tables.&amp;nbsp;&amp;nbsp; Is there a way I could avoid looking through all of columns in each table and list all their column names in merging steps?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384310#M91750</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-31T15:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384312#M91751</link>
      <description>&lt;P&gt;You can change &lt;STRONG&gt;b.price&lt;/STRONG&gt; and &lt;STRONG&gt;b.region&lt;/STRONG&gt; to &lt;STRONG&gt;b.*&lt;/STRONG&gt; in order to include all variables.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384312#M91751</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-31T15:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384314#M91753</link>
      <description>&lt;P&gt;As you first post - not all tables have same and all ID (key) variables.&lt;/P&gt;
&lt;P&gt;You can expand the sql to continue join more tables with similar logic to first 3 tables.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 15:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384314#M91753</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-31T15:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384516#M91833</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So, my actural table contains more columns and I have twenty-one tables.&amp;nbsp;&amp;nbsp; Is there a way I could avoid looking through all of columns in each table and list all their column names in merging steps?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;TANSTAAFL - There Ain't No Such Thing As A Free Lunch.&lt;/P&gt;
&lt;P&gt;Will soon be Maxim 45.&lt;/P&gt;
&lt;P&gt;Sometimes working as a SAS programmer (and creating clean, maintainable code) involves work. Tedious work, even. What a surprise.&lt;/P&gt;
&lt;P&gt;Using the asterisk must be done with caution in order to deal with variables that are present in more than one input dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 06:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384516#M91833</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-01T06:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Multiple tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384518#M91834</link>
      <description>A) You could build a macro that extracts column names from SQL dictionary.columns or sashelp.vcolumn. This will be some overhead in work and probably not worth it if it's a one time operation. &lt;BR /&gt;&lt;BR /&gt;B) Use a GUI tool that lets you drag and drop columns, like the query builder in Enterprise Guide.</description>
      <pubDate>Tue, 01 Aug 2017 06:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-Multiple-tables/m-p/384518#M91834</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-08-01T06:14:22Z</dc:date>
    </item>
  </channel>
</rss>

