<?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: Compare 2 datasets and output observations with variables that have changed data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357305#M274242</link>
    <description>&lt;P&gt;Thanks, Reeza.&amp;nbsp; I am using a combination of updates and merge statements to actually update the primary data set but what I am trying to do is create a dataset or report of the variables in observations that have changed each day.&amp;nbsp; That is the primary focus of this article but it just seemed a little cumbersome and I was hoping there was an easier way.&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2017 21:10:20 GMT</pubDate>
    <dc:creator>elwayfan446</dc:creator>
    <dc:date>2017-05-09T21:10:20Z</dc:date>
    <item>
      <title>Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357301#M274240</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to build a process that takes a daily file and compares it to the data already stored in a dataset.&amp;nbsp; I want to create a dataset out of the file and compare it to the main dataset to see if there were any observations that had data changed in any variable.&amp;nbsp; For example, I have a dataset 3 observations in it.&amp;nbsp; The variables are ID, Name, Date1, Date2, Amount.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 Red 5/1/2017, 5/30/2017, $400.00&lt;/P&gt;&lt;P&gt;2 Blue 6/1/2017, 6/30/2017, $500.00&lt;/P&gt;&lt;P&gt;3 Blue 6/1/2017, 7/31/2017, $350.00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a file that has 1 observation with 2 data fields that are different from my original dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 Blue 6/1/2017, &lt;STRONG&gt;7/31/2017&lt;/STRONG&gt;, &lt;STRONG&gt;$600.00&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to be able to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Update the old (primary) dataset with the new data in the updated file.&lt;/P&gt;&lt;P&gt;2. Add new records if they are in the new file but not the old (primary) dataset.&lt;/P&gt;&lt;P&gt;3. Generate a dataset or report that gives the observation, which variables were updated, and what the updates were.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have found this article and it makes pretty good sense.&amp;nbsp; However, I want to make sure there isn't something built in for this that would make it a little easier.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="Using PROC COMPARE to identify new and updated ... - PharmaSUG" href=" https://www.google.com/search?q=sas+compare+2+datasets+and+export+observations+that+have+variables+with+different+values+to+a+new+dataset&amp;amp;ie=utf-8&amp;amp;oe=utf-8" target="_blank"&gt;Using PROC COMPARE to identify new and updated ... - PharmaSUG&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a better way, please let me know.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 20:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357301#M274240</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2017-05-09T20:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357303#M274241</link>
      <description>&lt;P&gt;I would suggest looking more at the UPDATE statement either in a data step or SQL proc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357303#M274241</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-09T21:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357305#M274242</link>
      <description>&lt;P&gt;Thanks, Reeza.&amp;nbsp; I am using a combination of updates and merge statements to actually update the primary data set but what I am trying to do is create a dataset or report of the variables in observations that have changed each day.&amp;nbsp; That is the primary focus of this article but it just seemed a little cumbersome and I was hoping there was an easier way.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357305#M274242</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2017-05-09T21:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357307#M274243</link>
      <description>&lt;P&gt;If you're doing this manually I totally understand, and would also use update/merge. Lazy method:&lt;/P&gt;
&lt;P&gt;1. Back up old data&lt;/P&gt;
&lt;P&gt;2. Update data&lt;/P&gt;
&lt;P&gt;3. Compare new to old via merge&lt;/P&gt;
&lt;P&gt;Is there any possibility of&amp;nbsp;including a modified/last updated field in your master dataset that you could then generate your report off?.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know when I worked with SSIS we were able to automate this, because those fields were updated. I'm assuming SAS DI would have something similar but I really don't know. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357307#M274243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-09T21:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357309#M274244</link>
      <description>&lt;P&gt;Yes, I also did something similar with SSIS when I had it available to me.&amp;nbsp; It has been hard to learn how to do some things in SAS that I was able to do fairly easily with SSIS and SSMS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do have a "last updated" field for each observation so I can key off of that.&amp;nbsp; I am not sure what is different from your method versus the article if I am still going to compare using a merge.&amp;nbsp; Could you explain that step in a little more detail?&amp;nbsp; I already keep a copy of the prior day's dataset so I have the ability to compare the one I would update today to the data as it was yesterday.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357309#M274244</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2017-05-09T21:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357313#M274245</link>
      <description>&lt;P&gt;My point is sadly that proc compare doesn't add any value to the process IMO. It's a proc that could have a ton of value but needs to be updated significantly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357313#M274245</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-09T21:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357314#M274246</link>
      <description>&lt;P&gt;I agree with you completely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if you were doing it your way... in step three (update/merge) what would you do to compare those two datasets and either output to a new report or dataset the observations that have changes and which variables were changed?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357314#M274246</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2017-05-09T21:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357319#M274247</link>
      <description>Hi @elwayfan466&lt;BR /&gt;Have you looked into using an AUDIT table.&lt;BR /&gt;This makes most sense if your masterfile is updated like a database - by sql update or data step MODIFY - rather than by data step SET and  MERGE</description>
      <pubDate>Tue, 09 May 2017 21:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357319#M274247</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-05-09T21:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 datasets and output observations with variables that have changed data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357464#M274248</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15174"&gt;@Peter_C&lt;/a&gt;, I had not heard of an audit trail before but I will definitely look into that.&amp;nbsp; Right now I am updating my datasets each day with a combination of sql and MERGE but, if using an audit table is more efficient, then I will definitely look into it.&amp;nbsp; Thank you for the suggestion!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will report back.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 13:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-2-datasets-and-output-observations-with-variables-that/m-p/357464#M274248</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2017-05-10T13:24:55Z</dc:date>
    </item>
  </channel>
</rss>

