<?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 Decrease by 1 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693716#M37357</link>
    <description>Hi everyone...does anyone know how should i modify my coding to get result that generates after d_DELQ_BUCKET2=74, the next row must be d_DELQ_BUCKET2=73,...72,...71 and so on.&lt;BR /&gt;However the example here only one sample from 90,000 records. Appreciate if the coding can applicable to large records. Thanks a lot&lt;BR /&gt;&lt;BR /&gt;My coding:&lt;BR /&gt;Data a;&lt;BR /&gt;Set b;&lt;BR /&gt;by acct_number;&lt;BR /&gt;If first. acct_number then d_DELQ_BUCKET=DELINQUENCY_BUCKET;&lt;BR /&gt;else d_DELQ_BUCKET+(-1);&lt;BR /&gt;d_DELQ_BUCKET2=max(DELINQUENCY_BUCKET, d_DELQ_BUCKET)&lt;BR /&gt;run;</description>
    <pubDate>Fri, 23 Oct 2020 12:29:30 GMT</pubDate>
    <dc:creator>Shamz</dc:creator>
    <dc:date>2020-10-23T12:29:30Z</dc:date>
    <item>
      <title>Decrease by 1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693716#M37357</link>
      <description>Hi everyone...does anyone know how should i modify my coding to get result that generates after d_DELQ_BUCKET2=74, the next row must be d_DELQ_BUCKET2=73,...72,...71 and so on.&lt;BR /&gt;However the example here only one sample from 90,000 records. Appreciate if the coding can applicable to large records. Thanks a lot&lt;BR /&gt;&lt;BR /&gt;My coding:&lt;BR /&gt;Data a;&lt;BR /&gt;Set b;&lt;BR /&gt;by acct_number;&lt;BR /&gt;If first. acct_number then d_DELQ_BUCKET=DELINQUENCY_BUCKET;&lt;BR /&gt;else d_DELQ_BUCKET+(-1);&lt;BR /&gt;d_DELQ_BUCKET2=max(DELINQUENCY_BUCKET, d_DELQ_BUCKET)&lt;BR /&gt;run;</description>
      <pubDate>Fri, 23 Oct 2020 12:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693716#M37357</guid>
      <dc:creator>Shamz</dc:creator>
      <dc:date>2020-10-23T12:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Decrease by 1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693728#M37359</link>
      <description>&lt;P&gt;Why are you doing that MAX calculation, when you want a strictly decreasing sequence?&lt;/P&gt;
&lt;P&gt;Please post example data in usable form, as a data step with datalines, and use the "little running man" button to post the code. One can't develop and test code against pictures. And post an example for the expected output from that example data.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 14:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693728#M37359</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-23T14:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Decrease by 1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693774#M37361</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/353796"&gt;@Shamz&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sample data suggest that the values of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;DELINQUENCY_BUCKET&lt;/FONT&gt;&amp;nbsp;within an &lt;FONT face="courier new,courier"&gt;acct_number&lt;/FONT&gt; BY group (which is not shown, though) are decreasing, except for one (or more?) observation. What should happen if &lt;FONT face="courier new,courier"&gt;DELINQUENCY_BUCKET&lt;/FONT&gt; has a second (third, ...) increase, e.g., to 72 after the last record shown in your screenshot?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If &lt;FONT face="courier new,courier"&gt;d_DELQ_BUCKET2&lt;/FONT&gt; is to ignore these later increases (analogous to &lt;FONT face="courier new,courier"&gt;d_DELQ_BUCKET&lt;/FONT&gt;), I would suggest something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a(drop=_flag);
set b;
by acct_number;
if first.acct_number then do;
  d_DELQ_BUCKET  = DELINQUENCY_BUCKET;
  d_DELQ_BUCKET2 = DELINQUENCY_BUCKET;
  _flag+1;
end;
else do;
  d_DELQ_BUCKET+(-1);
  if DELINQUENCY_BUCKET&amp;gt;d_DELQ_BUCKET &amp;amp; _flag then do;
    d_DELQ_BUCKET2 = DELINQUENCY_BUCKET;
    _flag=0;
  end;
  else d_DELQ_BUCKET2+(-1);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, if&amp;nbsp;&lt;FONT face="courier new,courier"&gt;d_DELQ_BUCKET2&lt;/FONT&gt; is to be "reset" also in the event of second, third, ... increases or if no such cases can occur anyway, I'd suggest:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
set b;
by acct_number;
if first.acct_number then do;
  d_DELQ_BUCKET  = DELINQUENCY_BUCKET;
  d_DELQ_BUCKET2 = DELINQUENCY_BUCKET;
end;
else do;
  d_DELQ_BUCKET+(-1);
  if DELINQUENCY_BUCKET&amp;gt;d_DELQ_BUCKET2 then d_DELQ_BUCKET2 = DELINQUENCY_BUCKET;
  else d_DELQ_BUCKET2+(-1);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Oct 2020 15:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/693774#M37361</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-10-23T15:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Decrease by 1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/694021#M37369</link>
      <description>Hi, the answer in option 2 is the solution i need... Thanks a lot for your help and you are so geniusss and may god bless you &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;</description>
      <pubDate>Sat, 24 Oct 2020 17:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/694021#M37369</guid>
      <dc:creator>Shamz</dc:creator>
      <dc:date>2020-10-24T17:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Decrease by 1</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/694022#M37370</link>
      <description>Hi this is my first time posting here so i dont know how to post but thank you for your guidance on how i should ask the question.</description>
      <pubDate>Sat, 24 Oct 2020 17:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Decrease-by-1/m-p/694022#M37370</guid>
      <dc:creator>Shamz</dc:creator>
      <dc:date>2020-10-24T17:36:21Z</dc:date>
    </item>
  </channel>
</rss>

