<?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: increase values until a limit in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446792#M112164</link>
    <description>&lt;P&gt;Based on the final observation in your data set, it looks like YEAR should never exceed 2017.&amp;nbsp; For that result:&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;year = date_of_last_repricing;&lt;/P&gt;
&lt;P&gt;do k=1 to 100 while (year + repricing_frequency&amp;nbsp;&amp;lt;= 2017);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; year = year + repricing_frequency;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop k;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The purpose of the 1 to 100 loop is to prevent an infinite loop for bad data, such as one of the key variables having a missing value.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 14:27:58 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-03-19T14:27:58Z</dc:date>
    <item>
      <title>increase values until a limit in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446759#M112144</link>
      <description>&lt;P&gt;I have a variable in SAS which represents the last repricing of an asset, a subset looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Subset;&lt;BR /&gt;input ID Date_of_Last_Repricing Repricing_Frequency;&lt;BR /&gt;datalines;

1 2011 2
2 2013 2
3 2016 3
4 2017 1
5 2015 1
6 2015 1
7 2017 2
8 2017 2
9 2011 1
10 2010 1
11 2010 1
12 2011 2
13 2012 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm looking to create a loop that increases the variable date_of_last_repricing by the repricing frequency until it gets as close to 2017 as possible. For example the data set would look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data want;
input ID Date_of_Last_Repricing Repricing_Frequency Year;
datalines;

1 2011 2 2017
2 2013 2 2017
3 2016 3 2016
4 2017 1 2017
5 2015 1 2017
6 2015 1 2017
7 2017 2 2017
8 2017 2 2017
9 2011 1 2017
10 2010 1 2017
11 2010 3 2016
12 2011 2 2017
13 2012 3 2015
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;So far the code I've tried to use is 


data testing;
set test;

if dateoflastrepricing+repricing_schedule&amp;lt;2017
then do until sum(dateoflastrepricing+repricing_schedule)&amp;gt;2017;

sum(dateoflastrepricing+repricingschedule);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446759#M112144</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-19T13:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: increase values until a limit in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446789#M112162</link>
      <description>&lt;P&gt;No loop or accumulator needed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;year = Date_of_Last_Repricing + ( floor((2017-Date_of_Last_Repricing)/Repricing_Frequency) * Repricing_Frequency );&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446789#M112162</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-19T14:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: increase values until a limit in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446790#M112163</link>
      <description>&lt;P&gt;nice ,ty.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446790#M112163</guid>
      <dc:creator>89974114</dc:creator>
      <dc:date>2018-03-19T14:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: increase values until a limit in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446792#M112164</link>
      <description>&lt;P&gt;Based on the final observation in your data set, it looks like YEAR should never exceed 2017.&amp;nbsp; For that result:&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;year = date_of_last_repricing;&lt;/P&gt;
&lt;P&gt;do k=1 to 100 while (year + repricing_frequency&amp;nbsp;&amp;lt;= 2017);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; year = year + repricing_frequency;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop k;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The purpose of the 1 to 100 loop is to prevent an infinite loop for bad data, such as one of the key variables having a missing value.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increase-values-until-a-limit-in-SAS/m-p/446792#M112164</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-19T14:27:58Z</dc:date>
    </item>
  </channel>
</rss>

