<?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: How to flag rows? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371311#M88699</link>
    <description>&lt;P&gt;Thank you, it worked!&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2017 14:10:20 GMT</pubDate>
    <dc:creator>Sujithpeta</dc:creator>
    <dc:date>2017-06-28T14:10:20Z</dc:date>
    <item>
      <title>How to flag rows?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371296#M88689</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9914iCB069A8803B689A1/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;&lt;P&gt;In the data the date difference is the differene between the row's date to the previous date. &amp;nbsp;I want to flag patients where there is difference of &amp;nbsp;&amp;gt;= 120 days and mark all the dates after that &amp;gt;120 days. If there is a patients who have 2 rows of &amp;gt;120 days then I want to mark first &amp;nbsp;&amp;gt;= 120 days to the 2nd &amp;gt;120 days as "R1" and "R2" for dates greater than 2nd &amp;gt;120 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371296#M88689</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-28T13:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag rows?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371303#M88693</link>
      <description>&lt;P&gt;Since I won't type off a picture, here's an example with simplified data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input patient $ date;
cards;
X 1
X 6
X 130
X 135
X 140
X 350
X 355
;
run;

data want;
set have;
by patient;
retain recurr;
diff = date - lag(date);
if first.patient
then do;
  recurr = "  ";
  diff = 0;
end;
if diff &amp;gt; 120
then do;
  if recurr = 'R1'
  then recurr = 'R2';
  else recurr = 'R1';
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371303#M88693</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-28T13:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag rows?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371306#M88696</link>
      <description>&lt;P&gt;I think this is what you are asking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by patient_ID;&lt;/P&gt;
&lt;P&gt;if first.patient_ID then count=0;&lt;/P&gt;
&lt;P&gt;drop count;&lt;/P&gt;
&lt;P&gt;if difference_between_dates &amp;gt;= 120 then count + 1;&lt;/P&gt;
&lt;P&gt;if count &amp;gt; 0 then recurrence = 'R' || put(count, z2.);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did add a zero in there, using the Z2. format.&amp;nbsp; If you are sure that you will never require double digits to count the number of recurrences, you could change that to the 1. format instead.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 13:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371306#M88696</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-28T13:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to flag rows?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371311#M88699</link>
      <description>&lt;P&gt;Thank you, it worked!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 14:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-flag-rows/m-p/371311#M88699</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-28T14:10:20Z</dc:date>
    </item>
  </channel>
</rss>

