<?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: How to calculate averages between dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816315#M322186</link>
    <description>&lt;P&gt;Use custom formats to identify the two week time periods, and then use PROC SUMMARY to compute the means.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EXAMPLE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */

proc format;
    value twoweek '06MAY2022'd-'19MAY2022'd='06MAY2022'
        '20MAY2022'd-'02JUN2022'd='20MAY2022' /* etc. */
    ;
run;

proc summary data=have way;
    class bedrijf datum; 
    format datum twoweek.;
    var temp luchtvochtigheid co2 nh3;
    output out=stats mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: We cannot write code to test against data in screen captures. If you want tested code, then you need to provide the data as &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;), and not in any other format.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2022 11:45:31 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-03T11:45:31Z</dc:date>
    <item>
      <title>How to calculate averages between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816313#M322185</link>
      <description>&lt;P&gt;Dear sas users!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question regarding calculating averages between dates in my dataset.&lt;/P&gt;&lt;P&gt;My dataset is as followed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;whereby datum= date, tijd=time, bedrijf=company, temp=temperature, luchtvochtigheid=humidity, CO2=carbon dioxide and NH3= ammonia&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DanniekvLith_0-1654253722396.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71979iE7DEA05EBFBA53A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DanniekvLith_0-1654253722396.png" alt="DanniekvLith_0-1654253722396.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data from 12 weeks whereby every 10 minutes data from senors is logged. I have this for in total 10 companies. Now I want to calculate a 2 week average value for the 4 variables (humidity, temperature, CO2 and NH3) per company. Time is not important in this case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so for each company I want an avarage value for every 2 weeks (thus 6 average values per company) (this is because clinical analysis to the research object were done were I want to connect climate data to).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure how to do this. Does anyone maybe have an idea?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thankyou in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Danniek&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 10:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816313#M322185</guid>
      <dc:creator>DanniekvLith</dc:creator>
      <dc:date>2022-06-03T10:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate averages between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816315#M322186</link>
      <description>&lt;P&gt;Use custom formats to identify the two week time periods, and then use PROC SUMMARY to compute the means.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EXAMPLE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */

proc format;
    value twoweek '06MAY2022'd-'19MAY2022'd='06MAY2022'
        '20MAY2022'd-'02JUN2022'd='20MAY2022' /* etc. */
    ;
run;

proc summary data=have way;
    class bedrijf datum; 
    format datum twoweek.;
    var temp luchtvochtigheid co2 nh3;
    output out=stats mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: We cannot write code to test against data in screen captures. If you want tested code, then you need to provide the data as &lt;FONT color="#FF0000"&gt;working&lt;/FONT&gt; SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;), and not in any other format.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 11:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816315#M322186</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-03T11:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate averages between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816331#M322190</link>
      <description>&lt;P&gt;I have worked with data logger data similar to this. I would suggest a short investigation of your values around midnight/date change. You may have some cases where the "time" component indicates it is one of before/after midnight that doesn't quite agree with the "date" value depending on exactly how you want to consider date for the calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my case my data loggers were collecting a string of "hourly" values but had 25 hours per day: 00 to 24. The kicker was that the hour 24 values of day 1 were not the same as the hour 00 values for day 2. So some adjustments for some statistics that were really expecting 24 hourly measures had to be made.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 14:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-averages-between-dates/m-p/816331#M322190</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-03T14:32:58Z</dc:date>
    </item>
  </channel>
</rss>

