<?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: Load Data into Target by comparing with Source Table based on Date column in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605645#M18437</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you simply need to update data in target with a matching key (same date and other key variables) then configuring the table loader to use Update &amp;amp; Insert should do the job.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need processing that also deletes data from target after a previous load with wrong data (meaning the bad load had also rows with incorrect key variables) then I can thing of the following options:&lt;/P&gt;
&lt;P&gt;A) You get a separate file for deletes from source and you use a SQL Delete for this data and then a table loader with Update &amp;amp; Insert&lt;/P&gt;
&lt;P&gt;B) You execute a delete for all target data with a date key of the load you need to redo, then use the table loader with Insert only&lt;/P&gt;
&lt;P&gt;C) If you just get the next day a single file with new records (today's date) and with correction records (today-n date) then a table loader with Update &amp;amp; Insert should do the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you see: It won't be that hard to come up with a solution but for us to tell you what's going to work, it's very important that you're very precise how your source data looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;If your target table is a SAS table and such correction are regular then you should also implement some housekeeping process which re-creates the table from time to time. Reason: A SQL Delete for SAS tables only deletes the row logically but it remains in the physical file (the SAS table). Only re-creating the file will remove logically deleted rows and though reduce the file size (less storage, improved performance).&lt;/P&gt;
&lt;P&gt;If your target table resides in a database then you don't have to recreate it BUT it both source and target table are in the database then consider using the SQL Merge transformation instead of the Table Loader. A SQL Merge should also allow to cover case B) like: SQL Merge for Update &amp;amp; Delete (all keys with an "old" date), SQL Insert of all keys with a current data.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2019 08:56:02 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-11-20T08:56:02Z</dc:date>
    <item>
      <title>Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605335#M18430</link>
      <description>&lt;P&gt;Hi Team,&lt;BR /&gt;Iam using table loader as append to existing option to load daily data with source date has today()-1.&lt;BR /&gt;So i have a scenairo where to check whether for example source_date say 18NOV2019 and this is already loaded to target table .&lt;BR /&gt;Due to some situations again the 18NOV2019 data has come from source.&lt;BR /&gt;So at this time it should delete the alreday loaded old data for 18NOV2019 in target table and then reload with new data for 18NOV2019 from source.&lt;/P&gt;&lt;P&gt;Would it be possible to make use of table loader transformation as iam already using this one in SAS job please. ?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 08:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605335#M18430</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-19T08:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605361#M18431</link>
      <description>&lt;P&gt;If your requirement is to remove all records for a date prior to loading, then you probably need to do this in two steps, first a conditional (?) SQL Delete, then Append using Table Loader. This will hold true if you are not sure if there might be different no of records (set of identifiers) between the loads.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 11:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605361#M18431</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2019-11-19T11:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605362#M18432</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;the requirement is not to remove all records for a date prior to loading .&lt;BR /&gt;why i asked like this is sometimes data will be getting loading into target from source,which is actually incorrect.&lt;BR /&gt;so in this case it is difficult to manually remove those records from target.&lt;BR /&gt;it would be good if it is handled by SAS job itself&lt;BR /&gt;Would you please suggest how can we do this please&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 11:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605362#M18432</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-19T11:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605428#M18434</link>
      <description>&lt;P&gt;To be able to respond, you need to be crystal clear when these situation occur, how you are detecting/marking it, and the specific deletion criteria.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general terms, when you identify this situation, you can load the necessary information into macro variable(s), have a conditional (use the transformations under Control) Delete transformation in which you use these macro variables.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 16:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605428#M18434</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2019-11-19T16:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605629#M18436</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;please find the details below :&lt;/P&gt;&lt;P&gt;Would you please help if i use delete trasnformation how this will compare the data in target table based on source date whether it is alreday loaded or not ? if alreday loaded then delete only those data records based on date column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This scenario will happen if we are getting wrong data for one date say "19NOV2019" and target table is alreday loaded with incorrect data for 19NOV2019.So in this case source system will run again to get the correct data for 19NOV2019.so again SAs jobs needs to be processed with correct data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you please help completly please how can i approach using SAS DI Jobs please.iam thinking on table looader option.&lt;/P&gt;&lt;P&gt;but&amp;nbsp;&amp;nbsp;iam ready to take your suggestions please&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 07:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605629#M18436</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-20T07:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605645#M18437</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you simply need to update data in target with a matching key (same date and other key variables) then configuring the table loader to use Update &amp;amp; Insert should do the job.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need processing that also deletes data from target after a previous load with wrong data (meaning the bad load had also rows with incorrect key variables) then I can thing of the following options:&lt;/P&gt;
&lt;P&gt;A) You get a separate file for deletes from source and you use a SQL Delete for this data and then a table loader with Update &amp;amp; Insert&lt;/P&gt;
&lt;P&gt;B) You execute a delete for all target data with a date key of the load you need to redo, then use the table loader with Insert only&lt;/P&gt;
&lt;P&gt;C) If you just get the next day a single file with new records (today's date) and with correction records (today-n date) then a table loader with Update &amp;amp; Insert should do the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you see: It won't be that hard to come up with a solution but for us to tell you what's going to work, it's very important that you're very precise how your source data looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;If your target table is a SAS table and such correction are regular then you should also implement some housekeeping process which re-creates the table from time to time. Reason: A SQL Delete for SAS tables only deletes the row logically but it remains in the physical file (the SAS table). Only re-creating the file will remove logically deleted rows and though reduce the file size (less storage, improved performance).&lt;/P&gt;
&lt;P&gt;If your target table resides in a database then you don't have to recreate it BUT it both source and target table are in the database then consider using the SQL Merge transformation instead of the Table Loader. A SQL Merge should also allow to cover case B) like: SQL Merge for Update &amp;amp; Delete (all keys with an "old" date), SQL Insert of all keys with a current data.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 08:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605645#M18437</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-20T08:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605670#M18438</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Actually i forgot to mention that i need to build SAS dataset which should take care of historical data also.&lt;BR /&gt;So currently i am using table loader with "Append to Existing" Option and iam sure that there will not be any duplicates.&lt;BR /&gt;So i can not use update/insert option if we are building a history dataset.&lt;BR /&gt;So may i request to suggest any other option&amp;nbsp; to take care of delete scenario along by using table loader (Append to existing option)for me please.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 11:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605670#M18438</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-20T11:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605687#M18439</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;i forgot to mention that i need to build SAS dataset which should take care of historical data also&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;And again, you need to be very precise how you want to maintain history. You also need to be very precise how you could get corrected records - like could it be possible that you get such a correction for a date current-2 while you've already loaded a new row for the same key for current-1.&lt;/P&gt;
&lt;P&gt;Don't focus which table loader you need/want to use. First fully define your data organisation (SCD2, separate current and history table, record versioning, ....) and the load process on a logical level required to maintain your tables. Only then start thinking how to implement.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 11:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605687#M18439</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-20T11:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605856#M18440</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;.&lt;BR /&gt;So sorry to trouble again.&lt;BR /&gt;Now I need to just create job where data is getting compared between source and Target based on load date column.and load into target table only if it is not available in target SAS table&lt;BR /&gt;How can I create job like this. Please help.&lt;BR /&gt;Can I make use of sql join transformation or how please. Iam currently not getting any idea&lt;BR /&gt;Please help</description>
      <pubDate>Wed, 20 Nov 2019 17:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605856#M18440</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-20T17:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605956#M18441</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/256123"&gt;@JJP1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You again don't provide sufficient information to really understand what you have and what you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My answer based on the assumption that:&lt;/P&gt;
&lt;P&gt;1. The Date column comes from source and is rather the cutoff date from source (data date) than the load date&lt;/P&gt;
&lt;P&gt;2. The Date column is part of the business key (can be used as part of the primary key)&lt;/P&gt;
&lt;P&gt;3. You only ever want to load a row into target if there isn't already a row with a matching business key&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so then setting up the table loader as below should work. In below example the business key is {data_date, key_var}&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34118iB58B49A4828C9F71/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 21:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/605956#M18441</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-11-20T21:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Load Data into Target by comparing with Source Table based on Date column</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/606036#M18442</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;.please find below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data source;
input num $1. amt sourcedate $10. loaddate $10.;
datalines;
1 32 19NOV2019 20NOV2019
2 45 19NOV2019 20NOV2019
3 89 18NOV2019 19NOV2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data target;
input num $1. amt sourcedate $10. loaddate $10.;
datalines;
1 32 19NOV2019 20NOV2019
2 45 19NOV2019 20NOV2019
3 89 18NOV2019 19NOV2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;incorrect data is there in source dataset for date 18NOV2019&lt;BR /&gt;which got alreday loaded into target table.&lt;BR /&gt;so now the souce data will become as below.;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data source;
input num $1. amt sourcedate $10. loaddate $10.;
datalines;
1 32 19NOV2019 20NOV2019
2 45 19NOV2019 20NOV2019
3 54 18NOV2019 19NOV2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So target data should show as below output when i run below code;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data target;
input num $1. amt sourcedate $10. loaddate $10.;
datalines;
1 32 19NOV2019 20NOV2019
2 45 19NOV2019 20NOV2019
3 54 18NOV2019 19NOV2019
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would want to do this proc sql option(Sql join transformation0.kindly help&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 08:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Load-Data-into-Target-by-comparing-with-Source-Table-based-on/m-p/606036#M18442</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2019-11-21T08:49:03Z</dc:date>
    </item>
  </channel>
</rss>

