<?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 Comparing multiple observations for a single patient in order to delete unnecessary observations in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-multiple-observations-for-a-single-patient-in-order-to/m-p/339076#M17863</link>
    <description>&lt;P&gt;I read this post here which deals with a similar issue but I unfortunately don't understand how to apply it to my situation:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Comparing-a-row-in-a-dataset-with-the-next-row/td-p/184735" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Comparing-a-row-in-a-dataset-with-the-next-row/td-p/184735&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7607iB12DDE7DDF81CA1E/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="anemiaexample.png" title="anemiaexample.png" /&gt;&lt;/P&gt;&lt;P&gt;What I am trying to do is for each patient when the col1 goes from a 1 to a 0, then drop all following observations for that patient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is create a start and end date for each studyid based on the 1st time any of the anemia variables are 1 and the first 0 to follow. Then I'm going to attach the respective matching rdate to the anemia#s to create the start and end date. So for example I need 00RAJJ1P to take the dates from anemia2/rdate2 to anemia4/rdate4 and make those the start and enddate for that patient. For patient 00TS73B0 I would need a startdate and the enddate would be missing. for 00UQGCK2 start date and end date would be the two variables that are there.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 01:43:25 GMT</pubDate>
    <dc:creator>roger864</dc:creator>
    <dc:date>2017-03-08T01:43:25Z</dc:date>
    <item>
      <title>Comparing multiple observations for a single patient in order to delete unnecessary observations</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-multiple-observations-for-a-single-patient-in-order-to/m-p/339076#M17863</link>
      <description>&lt;P&gt;I read this post here which deals with a similar issue but I unfortunately don't understand how to apply it to my situation:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Comparing-a-row-in-a-dataset-with-the-next-row/td-p/184735" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Comparing-a-row-in-a-dataset-with-the-next-row/td-p/184735&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7607iB12DDE7DDF81CA1E/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="anemiaexample.png" title="anemiaexample.png" /&gt;&lt;/P&gt;&lt;P&gt;What I am trying to do is for each patient when the col1 goes from a 1 to a 0, then drop all following observations for that patient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is create a start and end date for each studyid based on the 1st time any of the anemia variables are 1 and the first 0 to follow. Then I'm going to attach the respective matching rdate to the anemia#s to create the start and end date. So for example I need 00RAJJ1P to take the dates from anemia2/rdate2 to anemia4/rdate4 and make those the start and enddate for that patient. For patient 00TS73B0 I would need a startdate and the enddate would be missing. for 00UQGCK2 start date and end date would be the two variables that are there.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 01:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Comparing-multiple-observations-for-a-single-patient-in-order-to/m-p/339076#M17863</guid>
      <dc:creator>roger864</dc:creator>
      <dc:date>2017-03-08T01:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing multiple observations for a single patient in order to delete unnecessary observations</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-multiple-observations-for-a-single-patient-in-order-to/m-p/339080#M17864</link>
      <description>&lt;P&gt;Your description wasn't clear enough to insure that anyone can provide a suggested solution. However, if you're only trying to do what your first sentence descibes, then the following may be what you're looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input patient $ type1 $ type2 $ col1;
  cards;
00RAJJ1P anemia1 anemia1 0
00RAJJ1P anemia2 anemia2 1
00RAJJ1P anemia3 anemia3 1
00RAJJ1P anemia4 anemia4 0
00RAJJ1P anemia5 anemia5 1
00RAJJ1P rdate1 rdate1 19025
00RAJJ1P rdate2 rdate2 19289
00RAJJ1P rdate3 rdate3 19424
00RAJJ1P rdate4 rdate4 19493
00RAJJ1P rdate5 rdate5 19877
00RAJJ1Q anemia1 anemia1 0
00RAJJ1Q anemia2 anemia2 1
00RAJJ1Q anemia3 anemia3 1
00RAJJ1Q anemia4 anemia4 0
00RAJJ1Q anemia5 anemia5 1
00RAJJ1Q rdate1 rdate1 19025
00RAJJ1Q rdate2 rdate2 19289
00RAJJ1Q rdate3 rdate3 19424
00RAJJ1Q rdate4 rdate4 19493
00RAJJ1Q rdate5 rdate5 19877
;

data want (drop=_:);
  set have;
  retain _drops;
  by patient;
  if first.patient then _drops=0;
  if _drops ne 2 then output;
  if col1 eq 1 and _drops ne 2 then _drops=1;
  else if _drops eq 1 and col1 eq 0 then _drops=2;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 02:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Comparing-multiple-observations-for-a-single-patient-in-order-to/m-p/339080#M17864</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-08T02:18:28Z</dc:date>
    </item>
  </channel>
</rss>

