<?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: HOW TO MERGE MULTIPLE DATABASES TO A COMMON DATABASE? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586887#M167540</link>
    <description>&lt;P&gt;I would really like to see the log of submitting this code if it is actually accomplishing what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA MERGE;
MERGE future (IN=A);
FUTURE_ORD_;(IN=C);
by account_number;
if A;
run;&lt;/PRE&gt;
&lt;P&gt;I suspect that you have two too many semicolons in that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2019 21:29:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-09-06T21:29:25Z</dc:date>
    <item>
      <title>HOW TO MERGE MULTIPLE DATABASES TO A COMMON DATABASE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586866#M167533</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've beeing build several databases in a macro as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FUTURE_ORD_201601&lt;/P&gt;&lt;P&gt;FUTURE_ORD_201602&lt;/P&gt;&lt;P&gt;FUTURE_ORD_201603&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;FUTURE_ORD_201903&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a table (ACCOUNT_NUMBER) that contains all the account numbers that are in common (it will be the key to be merged)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ACCOUNT_NUMBER&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;1894039183298219219&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm mergin all the datasets as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA MERGE;&lt;/P&gt;&lt;P&gt;MERGE&amp;nbsp;ACCOUNT_NUMBER(IN=A);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FUTURE_ORD_:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (IN=B);&lt;/P&gt;&lt;P&gt;BY ACCOUNT_NUMBER;&lt;/P&gt;&lt;P&gt;IF A;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if I can include someway the FUTURE databases into the macre where is created in order to merge the FUTURE database in every single step and let fix the ACCOUNT_NUMBER database as pivot for the merging.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I've beeing doing so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table future as
account_number from DATABASE;
RUN;

%MACRO FUTURE(VAR1,VAR2,VAR3);
creation of the database;
order of every single database created into the macro with the name FUTURE_ORD_&amp;amp;DATE.
%MEND;

DATA MERGE;
MERGE future (IN=A);
FUTURE_ORD_;(IN=C);
by account_number;
if A;
run;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I want to make the merge inside the macro and be sure that in every single step the merge is beeing doing in propper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in regards!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 20:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586866#M167533</guid>
      <dc:creator>Aldo_Leal</dc:creator>
      <dc:date>2019-09-06T20:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO MERGE MULTIPLE DATABASES TO A COMMON DATABASE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586887#M167540</link>
      <description>&lt;P&gt;I would really like to see the log of submitting this code if it is actually accomplishing what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA MERGE;
MERGE future (IN=A);
FUTURE_ORD_;(IN=C);
by account_number;
if A;
run;&lt;/PRE&gt;
&lt;P&gt;I suspect that you have two too many semicolons in that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 21:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586887#M167540</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-06T21:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO MERGE MULTIPLE DATABASES TO A COMMON DATABASE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586897#M167547</link>
      <description>So you have one merge that works, with no macro language.&lt;BR /&gt;&lt;BR /&gt;Why would you want to replace that with dozens of merges, while adding the complexities of macro language?</description>
      <pubDate>Fri, 06 Sep 2019 22:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586897#M167547</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-09-06T22:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO MERGE MULTIPLE DATABASES TO A COMMON DATABASE?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586924#M167563</link>
      <description>&lt;P&gt;The merge statement you've posted can't work like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;is hinting. Working code needs a semicolon removed and could look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data merge;
  merge account_number(in=a) future_ord_: ;
  by account_number;
  if a;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I believe though you don't really want to merge the data but you want to stack all the rows with a matching account number to your reference table with account numbers. If so then code as below should do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stacked;
  if _n_=1 then
    do;
      dcl hash h1(dataset:'account_number(keep=account_number)');
      h1.definekey('account_number');
      h1.definedata('account_number');
      h1.definedone();
    end;
  set future_ord_: ;
  if h1.check()=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Sep 2019 01:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-TO-MERGE-MULTIPLE-DATABASES-TO-A-COMMON-DATABASE/m-p/586924#M167563</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-07T01:06:18Z</dc:date>
    </item>
  </channel>
</rss>

