<?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 Calculate 7 day average by date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858737#M37922</link>
    <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which starts on 4th Jan 2021. What I want to do is show the rolling 7 day average for each of these dates so for example 12/02/2023 i want to know what the average has been over the last 7 days, and on 11/02/2023 the average over the last 7 days of that date etc etc. I have attached my sample file, if anyone could help that would be great.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2023 14:44:23 GMT</pubDate>
    <dc:creator>Abz_17</dc:creator>
    <dc:date>2023-02-14T14:44:23Z</dc:date>
    <item>
      <title>Calculate 7 day average by date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858737#M37922</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which starts on 4th Jan 2021. What I want to do is show the rolling 7 day average for each of these dates so for example 12/02/2023 i want to know what the average has been over the last 7 days, and on 11/02/2023 the average over the last 7 days of that date etc etc. I have attached my sample file, if anyone could help that would be great.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 14:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858737#M37922</guid>
      <dc:creator>Abz_17</dc:creator>
      <dc:date>2023-02-14T14:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate 7 day average by date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858747#M37924</link>
      <description>&lt;P&gt;If you have SAS/ETS licensed, you can use PROC EXPAND. See the examples here:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/etsug/etsug_expand_details19.htm#etsug_expand001988" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/etsug/etsug_expand_details19.htm#etsug_expand001988&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858747#M37924</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-14T15:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate 7 day average by date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858758#M37925</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/246113"&gt;@Abz_17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset which starts on 4th Jan 2021. What I want to do is show the rolling 7 day average for each of these dates so for example 12/02/2023 i want to know what the average has been over the last 7 days, and on 11/02/2023 the average over the last 7 days of that date etc etc. I have attached my sample file, if anyone could help that would be great.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Average of what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is of the column in that text file called Rejection_rate, which shows a percent sign in the value, then you need to be very aware that averages of percent values are seldom the actual percent average unless the denominator is identical for every record:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;n&amp;nbsp;&amp;nbsp; reject&amp;nbsp;&amp;nbsp; rejection rate&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50%&lt;/P&gt;
&lt;P&gt;1000&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.1%&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you "average" those two you get a result of 50.1 / 2 = 25.05%. But the combined rate is (1 +1)/(2+1000) which is 0.2% (rounded somewhat from 0.199601&lt;/P&gt;
&lt;P&gt;If your denominator is similar every single observation then just have smaller less obvious errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to do a running rejection rate you have to accumulate the numerators and denominators for each observation before calculating a "running rate".&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858758#M37925</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-14T15:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate 7 day average by date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858836#M37926</link>
      <description>&lt;P&gt;To keep a rolling window, use an array:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array val {0:6} _temporary_;
x = mean(of val{*});
val{mod(_n_,7)} = rate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Feb 2023 21:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-7-day-average-by-date/m-p/858836#M37926</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-14T21:16:29Z</dc:date>
    </item>
  </channel>
</rss>

