<?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: update master table with transaction table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752765#M237152</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the reply. But update statement in sas programming&amp;nbsp; is a time consuming technique. So this wont work in my scenario as millions of records exist in master dataset.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming your data are sorted by ID, update is probably the least time-consuming way of creating a new updated master file from the old master file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And really, millions of records is not that much these days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How many transactions do you have?&amp;nbsp; If only a few, then you might further improve performance by &lt;EM&gt;&lt;STRONG&gt;modifying the master data set in place&lt;/STRONG&gt;&lt;/EM&gt;, using the MODIFY statement in a data step.&amp;nbsp; See the documentation on&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0g9jfr4x5hgsfn17gtma5547lt1.htm#!" target="_self"&gt;MODIFY STATEMENT&lt;/A&gt;.&amp;nbsp; &amp;nbsp;Example 3 will give you some guidance if your data are sorted by ID.&amp;nbsp; &amp;nbsp;I imagine (untested) that you could do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  modify master transact (in=int);
  by id;
  if int then replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, like my other response, this assumes both datasets are sorted by ID.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jul 2021 03:39:45 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2021-07-08T03:39:45Z</dc:date>
    <item>
      <title>update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752664#M237128</link>
      <description>&lt;P&gt;I had master, transaction and required output tables as mentioned below.&lt;/P&gt;
&lt;P&gt;1ST CONDITION: For any ID, If any data is present in the master and if blank value is present in the transaction data for the same id then&amp;nbsp; the value in the master data should not be updated with the&amp;nbsp; blank value from Transaction data.(eg:ID- 1 GENDER:female)&lt;/P&gt;
&lt;P&gt;2ND CONDITION: For any ID, If any value&amp;nbsp; &amp;nbsp;is present in the master and if any&amp;nbsp; value&amp;nbsp; is present in the transaction data also for the same id then&amp;nbsp; the value in the master data should&amp;nbsp; be updated with the&amp;nbsp; value&amp;nbsp; from Transaction data.(eg:ID- 2 GENDER:male)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me to implement the following requirement using&amp;nbsp; HASH programming only for updating the data bcoz as the master dataset has&amp;nbsp; millions of records and&amp;nbsp; using of UPDATE&amp;nbsp; statement in SAS programming is&amp;nbsp; time consuming .So please help me ..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="439"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;MASTER&lt;/TD&gt;
&lt;TD width="90"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="82"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;ID#&lt;/TD&gt;
&lt;TD width="90"&gt;Date&lt;/TD&gt;
&lt;TD width="82"&gt;Gender&lt;/TD&gt;
&lt;TD width="64"&gt;Code&lt;/TD&gt;
&lt;TD width="64"&gt;Class&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;1&lt;/TD&gt;
&lt;TD width="90"&gt;.&lt;/TD&gt;
&lt;TD width="82"&gt;female&lt;/TD&gt;
&lt;TD width="64"&gt;AB&lt;/TD&gt;
&lt;TD width="64"&gt;LOW&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;2&lt;/TD&gt;
&lt;TD width="90"&gt;.&lt;/TD&gt;
&lt;TD width="82"&gt;female&lt;/TD&gt;
&lt;TD width="64"&gt;CD&lt;/TD&gt;
&lt;TD width="64"&gt;LOW&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;3&lt;/TD&gt;
&lt;TD width="90"&gt;1/1/2021&lt;/TD&gt;
&lt;TD width="82"&gt;M&lt;/TD&gt;
&lt;TD width="64"&gt;CD&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="439"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;TRANSACTION&lt;/TD&gt;
&lt;TD width="90"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="82"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;ID#&lt;/TD&gt;
&lt;TD width="90"&gt;Date&lt;/TD&gt;
&lt;TD width="82"&gt;Gender&lt;/TD&gt;
&lt;TD width="64"&gt;Code&lt;/TD&gt;
&lt;TD width="64"&gt;Class&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;1&lt;/TD&gt;
&lt;TD width="90"&gt;7/1/2020&lt;/TD&gt;
&lt;TD width="82"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;EF&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;2&lt;/TD&gt;
&lt;TD width="90"&gt;7/2/2020&lt;/TD&gt;
&lt;TD width="82"&gt;male&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;3&lt;/TD&gt;
&lt;TD width="90"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="82"&gt;male&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="439"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;output&lt;/TD&gt;
&lt;TD width="90"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="82"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;ID#&lt;/TD&gt;
&lt;TD width="90"&gt;Date&lt;/TD&gt;
&lt;TD width="82"&gt;Gender&lt;/TD&gt;
&lt;TD width="64"&gt;Code&lt;/TD&gt;
&lt;TD width="64"&gt;Class&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;1&lt;/TD&gt;
&lt;TD width="90"&gt;7/1/2020&lt;/TD&gt;
&lt;TD width="82"&gt;female&lt;/TD&gt;
&lt;TD width="64"&gt;EF&lt;/TD&gt;
&lt;TD width="64"&gt;LOW&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;2&lt;/TD&gt;
&lt;TD width="90"&gt;7/2/2020&lt;/TD&gt;
&lt;TD width="82"&gt;male&lt;/TD&gt;
&lt;TD width="64"&gt;CD&lt;/TD&gt;
&lt;TD width="64"&gt;LOW&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="139"&gt;3&lt;/TD&gt;
&lt;TD width="90"&gt;1/1/2021&lt;/TD&gt;
&lt;TD width="82"&gt;male&lt;/TD&gt;
&lt;TD width="64"&gt;CD&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 08 Jul 2021 02:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752664#M237128</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2021-07-08T02:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752757#M237150</link>
      <description>&lt;P&gt;This is tailor-made for the UPDATE statement, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  update master transact;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Unlike the the MERGE statement, UPDATE will not overwrite non-missing values in MASTER with missing values in the matching record/variable in TRANSACT.&amp;nbsp; Also UPDATE will collapse all transact records into a single MASTER record.&amp;nbsp; And UPDATE will expect exactly one record per BY value in MASTER.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 00:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752757#M237150</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-07-08T00:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752758#M237151</link>
      <description>&lt;P&gt;Thanks for the reply. But update statement in sas programming&amp;nbsp; is a time consuming technique. So this wont work in my scenario as millions of records exist in master dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 02:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752758#M237151</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2021-07-08T02:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752765#M237152</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the reply. But update statement in sas programming&amp;nbsp; is a time consuming technique. So this wont work in my scenario as millions of records exist in master dataset.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming your data are sorted by ID, update is probably the least time-consuming way of creating a new updated master file from the old master file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And really, millions of records is not that much these days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How many transactions do you have?&amp;nbsp; If only a few, then you might further improve performance by &lt;EM&gt;&lt;STRONG&gt;modifying the master data set in place&lt;/STRONG&gt;&lt;/EM&gt;, using the MODIFY statement in a data step.&amp;nbsp; See the documentation on&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0g9jfr4x5hgsfn17gtma5547lt1.htm#!" target="_self"&gt;MODIFY STATEMENT&lt;/A&gt;.&amp;nbsp; &amp;nbsp;Example 3 will give you some guidance if your data are sorted by ID.&amp;nbsp; &amp;nbsp;I imagine (untested) that you could do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  modify master transact (in=int);
  by id;
  if int then replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, like my other response, this assumes both datasets are sorted by ID.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 03:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752765#M237152</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-07-08T03:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752777#M237153</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;1ST CONDITION: For any ID, If any data is present in the master and if blank value is present in the transaction data for the same id then&amp;nbsp; the value in the master data should not be updated with the&amp;nbsp; blank value from Transaction data.(eg:ID- 1 GENDER:female)&lt;/P&gt;
&lt;P&gt;2ND CONDITION: For any ID, If any value&amp;nbsp; &amp;nbsp;is present in the master and if any&amp;nbsp; value&amp;nbsp; is present in the transaction data also for the same id then&amp;nbsp; the value in the master data should&amp;nbsp; be updated with the&amp;nbsp; value&amp;nbsp; from Transaction data.(eg:ID- 2 GENDER:male)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can be written as:&amp;nbsp;For any ID present in the master, overwrite the master data with any non-missing transaction data. Right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The UPDATE statement should run in seconds for a few million records.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data MASTER TRAN;
  do ID=1 to 1e6;
    A=ifn(ranuni(1)&amp;gt;.8, ., ID);
    B=ifn(ranuni(1)&amp;gt;.8, ., ID);
    output MASTER;
    A=ifn(ranuni(1)&amp;gt;.8, ., ID);
    B=ifn(ranuni(1)&amp;gt;.8, ., ID);
    output TRAN;
  end;
run;
data MASTER;
 update MASTER TRAN;
 by ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: There were 1000000 observations read from the data set WORK.MASTER.&lt;BR /&gt;NOTE: There were 1000000 observations read from the data set WORK.TRAN.&lt;BR /&gt;NOTE: The data set WORK.MASTERhas 1000000 observations and 3 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 1.08 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 06:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752777#M237153</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-08T06:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: update master table with transaction table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752779#M237154</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;The UPDATE statement should run in seconds for a few million records.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Unless your data is not in SAS of course, but then surely you'd have told us that.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 06:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-master-table-with-transaction-table/m-p/752779#M237154</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-08T06:47:19Z</dc:date>
    </item>
  </channel>
</rss>

