<?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 Create flag for policy renewal within 365 days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304838#M64926</link>
    <description>&lt;P&gt;&lt;BR /&gt;The data looks like as below&lt;BR /&gt;I need a new flag like this as Renewal&lt;BR /&gt;&lt;BR /&gt;My logic is&lt;BR /&gt;&lt;BR /&gt;Policy_no =lag(policy_no) and start_date=lag(start_date)&amp;gt;=365 then Renewal='R1'&lt;BR /&gt;&lt;BR /&gt;But my question if he renews it again in the next year it should be R2, and so on for huge data&lt;BR /&gt;&lt;BR /&gt;So I need my Renewal flag like this ...as below&lt;BR /&gt;&lt;BR /&gt;Policy_no. Start_date. Renewal&lt;BR /&gt;10100. 03Jan2014. N&lt;BR /&gt;10100. 07Mar2015. R1&lt;BR /&gt;10100. 10Sep2016. R2&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 20Oct2015. R1&lt;BR /&gt;&lt;BR /&gt;I need a renewal like this and my logic is like above. Please help me on this asap.&lt;BR /&gt;&lt;BR /&gt;If need further information please reply me.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Oct 2016 03:51:56 GMT</pubDate>
    <dc:creator>SBRVamsi</dc:creator>
    <dc:date>2016-10-15T03:51:56Z</dc:date>
    <item>
      <title>Create flag for policy renewal within 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304838#M64926</link>
      <description>&lt;P&gt;&lt;BR /&gt;The data looks like as below&lt;BR /&gt;I need a new flag like this as Renewal&lt;BR /&gt;&lt;BR /&gt;My logic is&lt;BR /&gt;&lt;BR /&gt;Policy_no =lag(policy_no) and start_date=lag(start_date)&amp;gt;=365 then Renewal='R1'&lt;BR /&gt;&lt;BR /&gt;But my question if he renews it again in the next year it should be R2, and so on for huge data&lt;BR /&gt;&lt;BR /&gt;So I need my Renewal flag like this ...as below&lt;BR /&gt;&lt;BR /&gt;Policy_no. Start_date. Renewal&lt;BR /&gt;10100. 03Jan2014. N&lt;BR /&gt;10100. 07Mar2015. R1&lt;BR /&gt;10100. 10Sep2016. R2&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 20Oct2015. R1&lt;BR /&gt;&lt;BR /&gt;I need a renewal like this and my logic is like above. Please help me on this asap.&lt;BR /&gt;&lt;BR /&gt;If need further information please reply me.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 03:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304838#M64926</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-10-15T03:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304840#M64927</link>
      <description>Sorry in he logic it should be&lt;BR /&gt;Policy_no =lag(policy_no) and&lt;BR /&gt;start_date-lag(start_date)&amp;gt;=365 then Renewal='R1'&lt;BR /&gt;&lt;BR /&gt;It's minus symbol after start_date</description>
      <pubDate>Sat, 15 Oct 2016 03:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304840#M64927</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-10-15T03:35:59Z</dc:date>
    </item>
    <item>
      <title>Base Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304841#M64930</link>
      <description>The data looks like as below&lt;BR /&gt;I need a new flag like this as Renewal&lt;BR /&gt;&lt;BR /&gt;My logic is&lt;BR /&gt;&lt;BR /&gt;Policy_no =lag(policy_no) and&lt;BR /&gt;start_date-lag(start_date)&amp;gt;=365 then Renewal='R1'&lt;BR /&gt;&lt;BR /&gt;But my question if he renews it again in the next year it should be R2, and so on for huge data&lt;BR /&gt;&lt;BR /&gt;So I need my Renewal flag like this ...as below&lt;BR /&gt;&lt;BR /&gt;Policy_no. Start_date. Renewal&lt;BR /&gt;10100. 03Jan2014. N&lt;BR /&gt;10100. 07Mar2015. R1&lt;BR /&gt;10100. 10Sep2016. R2&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 15Mar2014. N&lt;BR /&gt;21001. 20Oct2015. R1&lt;BR /&gt;&lt;BR /&gt;I need a renewal like this and my logic is like above. Please help me on this asap.&lt;BR /&gt;&lt;BR /&gt;If need further information please reply me.&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Oct 2016 03:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304841#M64930</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-10-15T03:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304842#M64929</link>
      <description>&lt;P&gt;You're on the right path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather than use lag to check for the same policy number use BY group processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LAG doesn't operate conditionally so calculate the value ahead of time and store that in a variable to use in your calculation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens if renewal is &amp;lt;365 days? That case isn't covered in your logic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Heres a sample(untested) that should get you started.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By policy_no;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Retain index;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;prev_start=lag(start_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if first.policy_no then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Prev_start=.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Index=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Renewal = 'N';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;Else if stsrt_date - prev_start &amp;gt;= 365 then do;&lt;/P&gt;
&lt;P&gt;Renewal =catt('R', index);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;else &amp;lt;logic?&amp;gt;;&lt;/P&gt;
&lt;P&gt;index+1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 03:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304842#M64929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-15T03:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304847#M64933</link>
      <description>&lt;P&gt;Use a do until() and logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.policy_no);
    set have; by policy_no;
    renewal = "N  ";
    if missing(last_date) then last_date = start_date;
    else if intck("DAY", last_date, start_date) &amp;gt;= 365 then do;
        r = sum(r, 1);
        renewal = cats("R", r);
        last_date = start_date;
        end;
    output;
    end;
drop last_date r;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Oct 2016 04:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304847#M64933</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-15T04:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag for policy renewal within 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304850#M64935</link>
      <description>&lt;PRE&gt;

data have;
infile cards dlm='. ';
input Policy_no Start_date : date9. Renewal $;
format start_date date9.;
cards;
10100. 03Jan2014. N
10100. 07Mar2015. R1
10100. 10Sep2016. R2
21001. 15Mar2014. N
21001. 15Mar2014. N
21001. 20Oct2015. R1
;
run;
data want;
 set have;
 by policy_no;
 length new $ 20;
 new='N';
 if first.policy_no then count=0;
 if dif(start_date) ge 365 and not first.policy_no then do;
  count+1;new=cats('R',count);
 end;
 drop count;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Oct 2016 06:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304850#M64935</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-15T06:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag for policy renewal within 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304872#M64943</link>
      <description>Thanks a lot ksharp...</description>
      <pubDate>Sat, 15 Oct 2016 17:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304872#M64943</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-10-15T17:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create flag for policy renewal within 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304873#M64944</link>
      <description>Thank you Guru</description>
      <pubDate>Sat, 15 Oct 2016 17:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-flag-for-policy-renewal-within-365-days/m-p/304873#M64944</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-10-15T17:04:51Z</dc:date>
    </item>
  </channel>
</rss>

