<?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: Retain flag for ever delinquency by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770561#M244485</link>
    <description>Thank you for your assistance. It works.</description>
    <pubDate>Mon, 27 Sep 2021 04:08:04 GMT</pubDate>
    <dc:creator>kevinmo3</dc:creator>
    <dc:date>2021-09-27T04:08:04Z</dc:date>
    <item>
      <title>Retain flag for ever delinquency by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770532#M244469</link>
      <description>&lt;P&gt;I have amended the following SAS codes for many times but turned out failed, I want to flag those cases with ever delinquency &amp;gt; 30 days by group, could anyone help to produce the desired results. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Patients;&lt;BR /&gt;input PatientID MOB DPD @@;&lt;BR /&gt;datalines;&lt;BR /&gt;1021 1 10 1042 2 32&lt;BR /&gt;1053 1 36 1063 3 13&lt;BR /&gt;1053 2 17 1021 3 15&lt;BR /&gt;1063 1 11 1042 3 18&lt;BR /&gt;1021 2 32 1063 4 43&lt;BR /&gt;1042 1 60 1021 4 35&lt;BR /&gt;1063 2 12 1053 4 45&lt;BR /&gt;1053 3 19 1063 5 73&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=Patients;&lt;BR /&gt;by PatientID MOB DPD;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data Result;&lt;BR /&gt;set Patients;&lt;BR /&gt;by PatientID MOB DPD;&lt;BR /&gt;retain ever_flag;&lt;BR /&gt;if first.PatientID and DPD &amp;gt; 30 then ever_flag = "Y";&lt;BR /&gt;else ever_flag = "N";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original Results (failed)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kevinmo3_0-1632679907727.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64080iBDC7BC3445EA1697/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kevinmo3_0-1632679907727.png" alt="kevinmo3_0-1632679907727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Results&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kevinmo3_0-1632680442691.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64082iD5EE08B4850621B9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kevinmo3_0-1632680442691.png" alt="kevinmo3_0-1632680442691.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 18:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770532#M244469</guid>
      <dc:creator>kevinmo3</dc:creator>
      <dc:date>2021-09-26T18:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Retain flag for ever delinquency by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770536#M244471</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Patients;
input PatientID MOB DPD @@;
datalines;
1021 1 10 1042 2 32
1053 1 36 1063 3 13
1053 2 17 1021 3 15
1063 1 11 1042 3 18
1021 2 32 1063 4 43
1042 1 60 1021 4 35
1063 2 12 1053 4 45
1053 3 19 1063 5 73
;
run;

proc sort data=Patients;
by PatientID MOB DPD;
run;

data Result;
set Patients;
by PatientID MOB DPD;
retain ever_flag;
if first.PatientID then ever_flag='N';
if DPD &amp;gt; 30 then ever_flag = 'Y';
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 19:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770536#M244471</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-26T19:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retain flag for ever delinquency by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770537#M244472</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.PatientID and DPD &amp;gt; 30 then ever_flag = "Y";
else ever_flag = "N";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Whenever first.patientid is false, the whole condition becomes false (because of the AND) and the variable is set to "N".&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 20:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770537#M244472</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-26T20:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Retain flag for ever delinquency by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770561#M244485</link>
      <description>Thank you for your assistance. It works.</description>
      <pubDate>Mon, 27 Sep 2021 04:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770561#M244485</guid>
      <dc:creator>kevinmo3</dc:creator>
      <dc:date>2021-09-27T04:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Retain flag for ever delinquency by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770562#M244486</link>
      <description>Thank you</description>
      <pubDate>Mon, 27 Sep 2021 04:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-flag-for-ever-delinquency-by-group/m-p/770562#M244486</guid>
      <dc:creator>kevinmo3</dc:creator>
      <dc:date>2021-09-27T04:08:48Z</dc:date>
    </item>
  </channel>
</rss>

