<?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: [PROBLEM]Merging with Indexed Dataset . in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326679#M72805</link>
    <description>&lt;P&gt;My Intended result is 300 million rows. The rows which are present in both should be overwritten in MASTER table. This should be accomplished using index.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 11:44:42 GMT</pubDate>
    <dc:creator>ankit___gupta</dc:creator>
    <dc:date>2017-01-23T11:44:42Z</dc:date>
    <item>
      <title>[PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326639#M72785</link>
      <description>&lt;P&gt;I have two tables MASTER (30 million rows), TRANSACTION (300 rows).Before applying index, I was using the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data MASTER;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; merge MASTER TRANSACTION;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by ID;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;The code resulted in data from both the data set merged. (Thus containing in total 30 million rows).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;After Applying index to the MASTER on (ID and LOCATION) using&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; create index inde on MASTER(ID, LOCATION);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now here lies the problem on how to merge.&amp;nbsp;&lt;/P&gt;&lt;P&gt;[PROBLEM] Now Merging them using index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[I got this code.]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data &lt;SPAN&gt;MASTER &lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set TRANSACTION;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set MASTER key = inde;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if _IORC_ = 0 THEN MASTER;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ELSE MASTER;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is not resulting in the same merge as mentioned earlier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also if there is possibility for a solution on the above using simple index ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 09:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326639#M72785</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-23T09:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326644#M72788</link>
      <description>&lt;P&gt;What is your intended result? 300 million observations or 300 observations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where did you get that code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MASTER ;
set TRANSACTION;
set MASTER key = inde;
if _IORC_ = 0 THEN MASTER;
ELSE MASTER;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;from?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 09:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326644#M72788</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-01-23T09:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326649#M72790</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure of what you are trying to do, but normally it should be something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create index ID on TRANSACTION(ID); * simple index name should be the column name;
quit;

data MASTER ;
set MASTER ;
set TRANSACTION key = ID;
if _IORC_ = 0; * output when match;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Index should be created for the smaller table, which I assume here is TRANSACTION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can use _IORC_ to do whatever you want (output or not), being 0 a match 1 a mismatch.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course if you do the merge via SQL, SAS will handle the index automatically for you (if possible).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 09:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326649#M72790</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-01-23T09:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326669#M72798</link>
      <description>&lt;P&gt;You want to replicate the results of your MERGE program with a modify program, thereby savings lots of input/output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are variables in the transaction dataset not in the master dataset, they will be added to the vars in the master dataset. This cannot be replicated using modify.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But assuming there are no new vars in the transaction data set, then you could do something like this to replicate the merge:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  set transaction;
  modify master key=inde;
  set transaction (drop=recordcreation);
  if _iorc_=0 then replace;
  else output;
  call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The reason for the second&amp;nbsp;"set transaction" statement is because a successful "modify" statement would overwrite values from the first "set transaction" - the opposite of your merge program. Actually the first "set transaction" could be revised to&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set transaction (keep=id location)&lt;BR /&gt;to make clear the purpose of each set statement .&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;If there is a new record (i.e. new id/location) in dataset transaction and if a variable (say var SUPPLIER) is in master but not transaction, then supplier would inherit its value from the most recent successful modify statement, when it should have&amp;nbsp;a missing value.&amp;nbsp; That's why there is a "call missing" statement.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;I should&amp;nbsp; add that the replication is accurate if there is only one record per index value in each dataset.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The "drop=recordcreation" parameter was added to the 2nd "set transaction" to accomodate a revision to the requirement - namely to keep the value from master whenever possible, and take the value from transaction only when there is a new record.&amp;nbsp; Of course, this also breaks the property of exactly replicating the&amp;nbsp; results of the merge program.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326669#M72798</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-01-24T14:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326679#M72805</link>
      <description>&lt;P&gt;My Intended result is 300 million rows. The rows which are present in both should be overwritten in MASTER table. This should be accomplished using index.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 11:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326679#M72805</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-23T11:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326963#M72911</link>
      <description>&lt;P&gt;Hi&amp;nbsp;mkeintz&lt;SPAN class="login-bold"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;your reply was totally accurate. I have just one other question to the query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Currently it is replacing all the column in MASTER from TRANSACTION. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;But i have one particular column (column name : RecordCreation) in Master and TRANSACTION that needs to be retained in MASTER and replace the other column.Also if the data was present only in transaction then put the entire to MASTER.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Please help with the above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks in Advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 07:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/326963#M72911</guid>
      <dc:creator>ankit___gupta</dc:creator>
      <dc:date>2017-01-24T07:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: [PROBLEM]Merging with Indexed Dataset .</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/327050#M72926</link>
      <description>&lt;P&gt;Then, in the second SET TRANSACTION, modify it to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set transaction (drop=recordcreation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;See my editted program in the prior topiic message.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROBLEM-Merging-with-Indexed-Dataset/m-p/327050#M72926</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-01-24T14:04:38Z</dc:date>
    </item>
  </channel>
</rss>

