<?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 Find the next record with specific criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560051#M156500</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping to show each time a case has went through a specific status and the next status/date it moves to the other specific status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included in my HAVE and WANT data to show what the data looks like / desired outcome. The criteria is each time an ID goes to the A status until the next time they reach the B status. If I can provide anymore detail then just let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sandy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.HAVE;
	input ID :1. STATUS :$1. DATE :date9.;
	format date date9.;
	infile datalines dlm=',';
	datalines;
1,A,01MAY2019
1,B,02MAY2019
2,A,01MAY2019
2,C,02MAY2019
2,B,03MAY2019
3,A,01MAY2019
3,C,02MAY2019
3,A,03MAY2019
3,B,04MAY2019
4,A,01MAY2019
4,B,02MAY2019
4,A,03MAY2019
4,B,04MAY2019
;

data work.WANT;
	input ID :1. STATUS_1 :$1. DATE_1 :date9. STATUS_2 :$1. DATE_2 :date9.;
	format date_1 date_2 date9.;
	infile datalines dlm=',';
	datalines;
1,A,01MAY2019,B,02MAY2019
2,A,01MAY2019,B,03MAY2019
3,A,01MAY2019,B,04MAY2019
3,A,03MAY2019,B,04MAY2019
4,A,01MAY2019,B,02MAY2019
4,A,03MAY2019,B,04MAY2019
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 09:17:30 GMT</pubDate>
    <dc:creator>Sanflo</dc:creator>
    <dc:date>2019-05-20T09:17:30Z</dc:date>
    <item>
      <title>Find the next record with specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560051#M156500</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hoping to show each time a case has went through a specific status and the next status/date it moves to the other specific status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included in my HAVE and WANT data to show what the data looks like / desired outcome. The criteria is each time an ID goes to the A status until the next time they reach the B status. If I can provide anymore detail then just let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sandy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.HAVE;
	input ID :1. STATUS :$1. DATE :date9.;
	format date date9.;
	infile datalines dlm=',';
	datalines;
1,A,01MAY2019
1,B,02MAY2019
2,A,01MAY2019
2,C,02MAY2019
2,B,03MAY2019
3,A,01MAY2019
3,C,02MAY2019
3,A,03MAY2019
3,B,04MAY2019
4,A,01MAY2019
4,B,02MAY2019
4,A,03MAY2019
4,B,04MAY2019
;

data work.WANT;
	input ID :1. STATUS_1 :$1. DATE_1 :date9. STATUS_2 :$1. DATE_2 :date9.;
	format date_1 date_2 date9.;
	infile datalines dlm=',';
	datalines;
1,A,01MAY2019,B,02MAY2019
2,A,01MAY2019,B,03MAY2019
3,A,01MAY2019,B,04MAY2019
3,A,03MAY2019,B,04MAY2019
4,A,01MAY2019,B,02MAY2019
4,A,03MAY2019,B,04MAY2019
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 09:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560051#M156500</guid>
      <dc:creator>Sanflo</dc:creator>
      <dc:date>2019-05-20T09:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find the next record with specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560054#M156502</link>
      <description>&lt;P&gt;Do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do until (status='B' | (last.id));
      set have;
      by id;
      if status='A' then do;
         status1='A';
         date1=date;
      end;
   end;

   if status='B';
   
   rename date=date2 status=status2;
   format date: date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 09:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560054#M156502</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-20T09:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Find the next record with specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560117#M156538</link>
      <description>&lt;P&gt;Thanks, much appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560117#M156538</guid>
      <dc:creator>Sanflo</dc:creator>
      <dc:date>2019-05-20T13:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find the next record with specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560120#M156539</link>
      <description>&lt;P&gt;Anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-the-next-record-with-specific-criteria/m-p/560120#M156539</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-20T13:12:00Z</dc:date>
    </item>
  </channel>
</rss>

