<?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: Most efficient way to find a change in data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Most-efficient-way-to-find-a-change-in-data/m-p/561792#M157320</link>
    <description>&lt;P&gt;It depends a bit, are you expecting it to never change? If so you can easily detect that by looking at the max/min values via SQL which operate on character variables as well. If you want to just identify changes you can use BY group processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this to get you started - note the NOTSORTED option because I'm assuming your data is in order of date, but not necessarily in order by partnerID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by companyID partnerID notsorted;

if first.partnerID and not first.companyID then flag=1;
else flag=0;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/167782"&gt;@dlazer1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with data and want to make sure I have it coded correctly. I have a company ID and partner ID and date. I want to see when the partner ID changes for each company ID. How would I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 May 2019 20:17:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-05-27T20:17:02Z</dc:date>
    <item>
      <title>Most efficient way to find a change in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Most-efficient-way-to-find-a-change-in-data/m-p/561791#M157319</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with data and want to make sure I have it coded correctly. I have a company ID and partner ID and date. I want to see when the partner ID changes for each company ID. How would I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 20:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Most-efficient-way-to-find-a-change-in-data/m-p/561791#M157319</guid>
      <dc:creator>dlazer1</dc:creator>
      <dc:date>2019-05-27T20:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Most efficient way to find a change in data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Most-efficient-way-to-find-a-change-in-data/m-p/561792#M157320</link>
      <description>&lt;P&gt;It depends a bit, are you expecting it to never change? If so you can easily detect that by looking at the max/min values via SQL which operate on character variables as well. If you want to just identify changes you can use BY group processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this to get you started - note the NOTSORTED option because I'm assuming your data is in order of date, but not necessarily in order by partnerID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by companyID partnerID notsorted;

if first.partnerID and not first.companyID then flag=1;
else flag=0;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/167782"&gt;@dlazer1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with data and want to make sure I have it coded correctly. I have a company ID and partner ID and date. I want to see when the partner ID changes for each company ID. How would I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 20:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Most-efficient-way-to-find-a-change-in-data/m-p/561792#M157320</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-27T20:17:02Z</dc:date>
    </item>
  </channel>
</rss>

