<?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: Select most recent rows with changed value only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363808#M86199</link>
    <description>Hi art297,&lt;BR /&gt;The advice given is great !&lt;BR /&gt;Can you advice me further to identify all records having change in TYPE with reference to the first one.&lt;BR /&gt;Regards,</description>
    <pubDate>Fri, 02 Jun 2017 13:47:50 GMT</pubDate>
    <dc:creator>DeepakSwain</dc:creator>
    <dc:date>2017-06-02T13:47:50Z</dc:date>
    <item>
      <title>Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363785#M86184</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your kind information, I am trying to identify only those records which have been submitted with some changes. For example in the table mentioned below, TYPE has been changed in the most recent report with reference to the earliest&amp;nbsp;report submitted.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
format date_1 date9. ;
input id $ sp_num $ type $  date_1 yymmdd8.;
datalines;
101 a01 p 20160102
101 a01 b 20160103
102 b02 b 20160104
102 b02 b 20160105
103 c03 p 20160106
103 c03 p 20160107
103 c03 b 20160108
;
run;


data want ;
format date_1 date9. ;
input id $ sp_num $ type $  date_1 yymmdd8.;
datalines;
101 a01 b 20160103
103 c03 b 20160108
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can anybody kindly guide me to get it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 12:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363785#M86184</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-06-02T12:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363789#M86187</link>
      <description>&lt;P&gt;did you also want the following record in your want dataset?:&lt;/P&gt;
&lt;PRE&gt;102 b02 b 20160105
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 13:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363789#M86187</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-02T13:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363795#M86191</link>
      <description>&lt;P&gt;I think I answered my own question. Are you looking to do something like?:&lt;/P&gt;
&lt;PRE&gt;data want (drop=change);
  set have;
  by id sp_num;
  retain change;
  if first.sp_num then change=0;
  if type ne lag(type) and not first.sp_num then change=1;
  if change and last.sp_num then output;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 13:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363795#M86191</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-02T13:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363803#M86197</link>
      <description>&lt;P&gt;Hi art297,&lt;/P&gt;&lt;P&gt;As the value of type has not changed, that record is not included.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 13:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363803#M86197</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-06-02T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363808#M86199</link>
      <description>Hi art297,&lt;BR /&gt;The advice given is great !&lt;BR /&gt;Can you advice me further to identify all records having change in TYPE with reference to the first one.&lt;BR /&gt;Regards,</description>
      <pubDate>Fri, 02 Jun 2017 13:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363808#M86199</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-06-02T13:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363820#M86206</link>
      <description>&lt;P&gt;In order to identify all instances where type is different than the initial value for type, I'd suggest a slightly different approach:&lt;/P&gt;
&lt;PRE&gt;data have ;
  format date_1 date9. ;
  input id $ sp_num $ type $  date_1 yymmdd8.;
  datalines;
101 a01 p 20160102
101 a01 b 20160103
102 b02 b 20160104
102 b02 b 20160105
103 c03 p 20160106
103 c03 p 20160107
103 c03 b 20160108
103 c03 b 20160109
;
run;

data want (drop=change);
  set have;
  by id sp_num;
  retain first_type;
  if first.sp_num then first_type=type;
  else if type ne first_type then output;
run;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363820#M86206</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-02T14:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent rows with changed value only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363840#M86210</link>
      <description>&lt;P&gt;Hi art297,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking the pain to answer my silly questions. It has been a good learning experience.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 14:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-rows-with-changed-value-only/m-p/363840#M86210</guid>
      <dc:creator>DeepakSwain</dc:creator>
      <dc:date>2017-06-02T14:46:13Z</dc:date>
    </item>
  </channel>
</rss>

