<?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: Max price change within interval i.e. 30 days or 365 days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346821#M80018</link>
    <description>Any suggestions on an approach?</description>
    <pubDate>Mon, 03 Apr 2017 19:50:48 GMT</pubDate>
    <dc:creator>brophymj</dc:creator>
    <dc:date>2017-04-03T19:50:48Z</dc:date>
    <item>
      <title>Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346735#M79988</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using teh dataset below, is there a straightforward way of calculating:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(1) the largest price increase in any consecutive 30/360/720 day period. So the algorithm would need to check the price change of from every day to every other day within 30/360/720 days and output a maximum&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(2) the largest price increase in a particular month&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(3)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the largest price increase in a particular year&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(4) the correlation of price movements between January 2015 and January 2016 i.e. are price movements in Jan 2015 correlated with price movements in Jan 2016?&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;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;attrib date length=4 format=date9.;&lt;BR /&gt;do date = '1jan2015'd to '31dec2016'd;&lt;BR /&gt;price = int(ranuni(225465114) * 30) + 95;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&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>Mon, 03 Apr 2017 16:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346735#M79988</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-03T16:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346744#M79989</link>
      <description>&lt;P&gt;I think you may need to expand on your definitions of 2 and 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) the largest price increase in a particular month: Do you mean single day to day increase within calendar month, largest end of month compared with first of month, increase from previous month end, or something else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of this may be easier if you have SAS/ETS available. Do you?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 16:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346744#M79989</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-03T16:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346750#M79991</link>
      <description>Hi ballard, for part 2) I mean largest price movement within a month .i.e. Could be between the 14th and 15th or the 1st and the 30th or any combination&lt;BR /&gt;&lt;BR /&gt;3) same as above but it's a calendar year instead of a month</description>
      <pubDate>Mon, 03 Apr 2017 16:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346750#M79991</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-03T16:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346752#M79993</link>
      <description>I don't have sas/ets</description>
      <pubDate>Mon, 03 Apr 2017 16:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346752#M79993</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-03T16:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346821#M80018</link>
      <description>Any suggestions on an approach?</description>
      <pubDate>Mon, 03 Apr 2017 19:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346821#M80018</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-03T19:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346839#M80022</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I assumed disjoint months. not sure what you want for output.

proc sql;
  create
     table cart as
  select
     l.month
    ,max(abs(l.price - r.price)) as jandif
  from
     date as l full outer join date as r
  on
     l.month ne r.month and
     l.date ne r.date
  group
     by l.month
;quit;


Up to 40 obs WORK.CART total obs=3

Obs    MONTH    JANDIF

 1       1        29
 2       2        28
 3       3        29
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346839#M80022</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-03T21:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346846#M80025</link>
      <description>&lt;P&gt;How about providing a concrete (NOT random) 45 days of data and show us what the result for the 30 day problem would look like based on that data. That should not be to large to do by hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also need to be careful about "increase". What is the result for if the data only decreases over a given time interval?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/346846#M80025</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-03T21:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347010#M80084</link>
      <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your feedback.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached an excel with two tabs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first shows the calculation in excel for calculating the max price increase (not decrease) in a calendar week (Mon-Sun) over a two month period.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second is an expansion of the first example and shows how to calculate the max price increase in any 7 day consecutive period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the above has been solved, it is straightforward expanding this to months/ bigger intervals.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will see in both examples that the agorithm needs to calculate a matrix of price change and then max over the matrix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So to calculate the max price change in a calendar week you need to perform 21 calculations and take the max the get the max price change. If we wanted to do the same for January, you would need to perform 1,860 calculations. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this make sense?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 12:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347010#M80084</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-04T12:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347072#M80116</link>
      <description>I think the solution is probably through the use of arrays but they're not my strongpoint</description>
      <pubDate>Tue, 04 Apr 2017 15:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347072#M80116</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-04T15:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347126#M80136</link>
      <description>Any advice??</description>
      <pubDate>Tue, 04 Apr 2017 17:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347126#M80136</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2017-04-04T17:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Max price change within interval i.e. 30 days or 365 days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347185#M80155</link>
      <description>&lt;P&gt;See if this does the 7 days. Since the data is random it may not match expectations.&lt;/P&gt;
&lt;PRE&gt;data have;
   attrib date length=4 format=date9.;
   do date = '1jan2015'd to '31dec2016'd;
      price = int(ranuni(225465114) * 30) + 95;
      PriceInc = dif(Price)/lag(price);
      If PriceInc&amp;lt;0 then PriceInc=.;
      Max7Day = max(priceInc,lag(priceinc),lag2(priceinc),lag3(priceinc),lag4(priceinc),lag5(priceinc),lag6(priceinc));
      output;
   end;
   label 
      PriceInc = "Percent increase from previous day"
      Max7Day  = "Maximum daily price increase percent 7 days"
   ;
   format PriceInc Max7Day percent8.1;
run;&lt;/PRE&gt;
&lt;P&gt;If that at matches then some of what you requested may be possible with other report procedures and careful use of formats&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=have;
   class date;
   format date yymon.;
   var priceinc;
   tables date,
          priceinc*max*f=percent8.1;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Max-price-change-within-interval-i-e-30-days-or-365-days/m-p/347185#M80155</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-04T21:37:14Z</dc:date>
    </item>
  </channel>
</rss>

