<?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: Data Step Update Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266868#M52694</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10429"&gt;@Doug____&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;What I'm seeking are two things 1) were any records appended (new records) and 2) were any variable values changed&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data health2;
   update health  (in=a)
          fitness(in=b);
   by id name team;
   Updated = b;
   If a and b then Updated=1;

   If not(a) and b then New=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Though the example data I posted below didn't have any new records as that wasn't what your intial post implied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2016 21:18:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-04-27T21:18:33Z</dc:date>
    <item>
      <title>Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266809#M52659</link>
      <description>&lt;P&gt;Is there a system variable that will tell me which rows were updated when utilizing the UPDATE statement?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 18:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266809#M52659</guid>
      <dc:creator>Doug____</dc:creator>
      <dc:date>2016-04-27T18:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266816#M52662</link>
      <description>&lt;P&gt;It depends on what you mean by a row being updated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;update master trans (in=in_trans);&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;updated = in_trans;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable UPDATED tells you whether a record was found in the transaction file for that ID. &amp;nbsp;However, it doesn't tell you whether the data values actually changed the contents of the MASTER data set. &amp;nbsp;It would still be possible that all data values in TRANS had missing values and were ignored, or that the values in TRANS matched what was already in MASTER.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 18:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266816#M52662</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-27T18:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266819#M52665</link>
      <description>&lt;P&gt;What I'm seeking are two things 1) were any records appended (new records) and 2) were any variable values changed&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 19:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266819#M52665</guid>
      <dc:creator>Doug____</dc:creator>
      <dc:date>2016-04-27T19:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266822#M52667</link>
      <description>&lt;P&gt;No automatic variable that I am aware of but here is code that shows one way of adding your own as part of an update.&lt;/P&gt;
&lt;P&gt;Note that the first bits are just to provide example data the last datastep has one technique.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data  HEALTH  ;
   input ID     NAME  $   TEAM  $  WEIGHT      ;
datalines;
1114    sally    blue      125       
1441    sue      green     145       
1750    joey     red       189       
1994    mark     yellow    165
2304    joe      red       170
;
run;

Data  FITNESS ;
   input  ID     NAME $    TEAM $   WEIGHT;
datalines;
1114    sally    blue      119
1994    mark     yellow    174
2304    joe      red       170
;
run;

proc sort data=health;
   by id name team;
run;
proc sort data=fitness;
   by id name team;
run;

   /* Update Master with Transaction */
data health2;
   update health
          fitness(in=b);
   by id name team;
   Updated = b;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 19:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266822#M52667</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-27T19:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266825#M52669</link>
      <description>&lt;P&gt;In that case, there is no system tool. &amp;nbsp;You would have to run a PROC COMPARE after the fact (with a BY statement), to find differences between the original and the new data set.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 19:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266825#M52669</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-27T19:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266868#M52694</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10429"&gt;@Doug____&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;What I'm seeking are two things 1) were any records appended (new records) and 2) were any variable values changed&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data health2;
   update health  (in=a)
          fitness(in=b);
   by id name team;
   Updated = b;
   If a and b then Updated=1;

   If not(a) and b then New=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Though the example data I posted below didn't have any new records as that wasn't what your intial post implied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 21:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266868#M52694</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-27T21:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step Update Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266891#M52701</link>
      <description>You need create Integrate Constraint  on your table , and proc print it.

1)
proc datasets .........
 modify have;
 ic create sex=(sex is not missing.......)
......

audit have;
initiate;
quit;

data have;
 update have temp;
by id;
run;

proc print data=have(type=audit);run;</description>
      <pubDate>Thu, 28 Apr 2016 01:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-Update-Statement/m-p/266891#M52701</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-28T01:55:01Z</dc:date>
    </item>
  </channel>
</rss>

