<?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: first. last. and comparing with previous observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844421#M333830</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The next 2nd row obs has AETOXGR=3 with AEOUT = "NOT RECOVERED/NOT RESOLVED". This is incorrect, the 2nd row obs should instead have "NOT RECOVERED/NOT RESOLVED" since the AETOXGR is increasing 2 to 3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The second row does already have the "correct" value, so this sentence makes no sense at all.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 16:59:22 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-11-15T16:59:22Z</dc:date>
    <item>
      <title>first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844389#M333819</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I would like to output records of AEOUT which are being collected incorrectly for the same AEDECOD. For instance, consider the 1st row obs AETOXGR = 2 and has AEOUT="NOT RECOVERED/NOT RESOLVED.&lt;BR /&gt;The next 2nd row obs has AETOXGR=3 with AEOUT = "NOT RECOVERED/NOT RESOLVED". This is incorrect, the 2nd row obs should instead have "NOT RECOVERED/NOT RESOLVED" since the AETOXGR is increasing 2 to 3.&lt;/P&gt;
&lt;P&gt;And vice-versa, where the 2nd row obs AETOXGR = 3 and AEOUT="NOT RECOVERED/NOT RESOLVED" and the 3rd row obs with AETOXGR = 2 have AEOUT="NOT RECOVERED/NOT RESOLVED",&lt;BR /&gt;instead the 3rd row obs should have been "RECOVERING/RESOLVING" since the AETOXGR is being decreased from 3 to 2.&lt;/P&gt;
&lt;P&gt;Below is the sample data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SUBJID  GRPID   AESTDTC      AEENDTC     AEDECOD                AEOUT                   SSEQ  AETOXGR
100012 	 1      2021-03-25  2021-04-13 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.1  	2
100012 	 1      2021-04-14  2021-04-21 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.2  	3
100012 	 1      2021-04-22  2021-04-27 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.3  	2
100012 	 1      2021-04-28  2021-05-04 	Anaemia            	RECOVERING/RESOLVING 		1.4  	3
100012 	 1      2021-05-05  2021-05-10 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.5  	2
100012 	 1      2021-05-11  2021-05-17 	Anaemia            	RECOVERING/RESOLVING 		1.6  	3
100012 	 1      2021-05-17  2021-05-25 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.7  	2
100012 	 1      2021-05-26  2021-06-03 	Anaemia            	RECOVERING/RESOLVING 		1.8  	3
100012 	 1      2021-06-04  2021-06-09 	Anaemia            	RECOVERING/RESOLVING 		1.9  	2
100012 	 1      2021-06-10  2021-06-15 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.10  	1
100012 	 1      2021-06-16  2021-07-05 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.11  	2
100012 	 1      2021-07-06  2021-08-05 	Anaemia            	RECOVERING/RESOLVING 		1.12  	3
100012 	 1      2021-08-06  2021-08-15 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.13  	2
100012 	 1      2021-08-16  2021-08-22 	Anaemia            	RECOVERING/RESOLVING 		1.14  	3
100012 	 1      2021-08-23  2021-08-29 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.15  	2
100012 	 1      2021-08-30  2021-09-06 	Anaemia            	RECOVERING/RESOLVING 		1.16  	3
100012 	 1      2021-09-07  2021-09-13 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.17  	2
100012 	 1      2021-09-14  2021-10-03 	Anaemia            	RECOVERING/RESOLVING 		1.18  	3
100012 	 1      2021-10-04  2021-10-10 	Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.19  	2
100012 	 1      2021-10-11  			Anaemia            	NOT RECOVERED/NOT RESOLVED 	1.20  	3
100012 	 3      2021-02-21  2021-02-&lt;FONT color="#FF0000"&gt;21 &lt;/FONT&gt;	Thrombocytopenia   	RECOVERED/RESOLVED 			2.1  	4
100012 	 4      2021-03-&lt;FONT color="#FF0000"&gt;03&lt;/FONT&gt;  2021-03-&lt;FONT color="#FF0000"&gt;08&lt;/FONT&gt; 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.1  	3
100012 	 4      2021-03-&lt;FONT color="#FF0000"&gt;09&lt;/FONT&gt;  2021-03-15 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.2  	2
100012 	 4      2021-03-16  2021-03-23 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.3  	1
100012 	 4      2021-03-24  2021-04-07 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.4  	2
100012 	 4      2021-04-08  2021-04-21 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.5  	1
100012 	 4      2021-04-22  2021-04-27 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.6  	2
100012 	 4      2021-04-28  2021-05-04 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.7  	1
100012 	 4      2021-05-05  2021-05-10 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.8  	2
100012 	 4      2021-05-11  2021-06-09 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.9 	3
100012 	 4      2021-06-10  2021-06-15 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.10 	2
100012 	 4      2021-06-16  2021-07-05 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.11 	3
100012 	 4      2021-07-06  2021-07-27 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.12 	2
100012 	 4      2021-07-28  2021-08-29 	Thrombocytopenia 	NOT RECOVERED/NOT RESOLVED 	3.13 	3
100012 	 4      2021-08-30  2021-10-21 	Thrombocytopenia 	RECOVERING/RESOLVING 		3.14 	4
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: obs 21 have sseq as 2.1 and obs 22 has sseq 3.1 with same AEDECOD(Thrombocytopenia)). SSEQ is derived as : "All event records of same AEDECOD from the same subject are linked by the AESTDTC and AEENDTC. If an event is followed by another event with same AEDECOD with and AESTDTC the same day or 1 day after the AEENDTC of the &lt;STRONG&gt;previous record&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have tried the below code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data adae2 adae3;
	set adae1;
	retain grade;
	by subjid aedecod aestdtc aeendtc;
	if first.aedecod then grade=aetoxgr;
	
	if last.aedecod and aetoxgr lt grade then adae3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I was only able to satisfy one condition. Please suggest an appropriate method.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 15:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844389#M333819</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2022-11-15T15:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844393#M333821</link>
      <description>Bit lazy to through all your logic, but I don't understand this part of your code:&lt;BR /&gt;"then adae3;"&lt;BR /&gt;Maybe you wish to assign grade here?</description>
      <pubDate>Tue, 15 Nov 2022 15:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844393#M333821</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-11-15T15:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844406#M333824</link>
      <description>ohh, i missed OUTPUT option in between. i want to output all the records to adae3</description>
      <pubDate>Tue, 15 Nov 2022 15:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844406#M333824</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2022-11-15T15:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844410#M333826</link>
      <description>Show the complete code that you actually have executed.&lt;BR /&gt;If you wish to understand how your code works with the actual data, you can make use of the data step debugger, available in Enterprise Guide and SAS Display Manager (aka Base SAS).</description>
      <pubDate>Tue, 15 Nov 2022 16:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844410#M333826</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-11-15T16:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844415#M333827</link>
      <description>I have provided it in the above, thats all i have used for now!</description>
      <pubDate>Tue, 15 Nov 2022 16:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844415#M333827</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2022-11-15T16:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844421#M333830</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The next 2nd row obs has AETOXGR=3 with AEOUT = "NOT RECOVERED/NOT RESOLVED". This is incorrect, the 2nd row obs should instead have "NOT RECOVERED/NOT RESOLVED" since the AETOXGR is increasing 2 to 3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The second row does already have the "correct" value, so this sentence makes no sense at all.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 16:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844421#M333830</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-15T16:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844647#M333924</link>
      <description>You're right &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, I was looking at other obs and gave the wrong example. Could you please consider the other cases where it is incorrect like obs 3 and so on?</description>
      <pubDate>Wed, 16 Nov 2022 15:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844647#M333924</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2022-11-16T15:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: first. last. and comparing with previous observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844762#M333970</link>
      <description>&lt;P&gt;Post&amp;nbsp;&lt;U&gt;usable&lt;/U&gt; example data in a data step with datalines, as you have been shown&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/select-all-the-records-where-there-is-multiple-records-for-flag/m-p/839482/highlight/true#M331922" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;and as you have done yourself&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Alternate-to-sql-using-data-step/m-p/827957/highlight/true#M327061" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 08:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-last-and-comparing-with-previous-observation/m-p/844762#M333970</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-17T08:34:10Z</dc:date>
    </item>
  </channel>
</rss>

