<?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: calculating averages between dates to include saturday and sunday in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840182#M332218</link>
    <description>&lt;P&gt;If your dates are SAS dates and not character strings, inserting Saturday and Sunday should be easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   if weekday(dtcont) = 6 then do;   /* identify Fridays */
      dtcont + 1;   /* add Saturday using Friday data */
      output;
      dtcont + 1;   /* add Sunday using Friday data */
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To handle other missing points, it would be easiest if you would actually supply a list of the missing days.&amp;nbsp; "Etc." is not specific enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea here is to create a complete data set with all the dates present.&amp;nbsp; Calculating monthly statistics would be easy at that point, but post again if that part gives you any trouble.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2022 02:35:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2022-10-24T02:35:16Z</dc:date>
    <item>
      <title>calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/838628#M332212</link>
      <description>&lt;P&gt;Hi everyone&lt;BR /&gt;could you halp me !?!?!&lt;BR /&gt;I have a question regarding calculating averages between dates in my dataset.&lt;BR /&gt;this is an example of my dataset:&lt;BR /&gt;DTCONT CTV_SALDO&lt;BR /&gt;01SEP2022 145.026,70&lt;BR /&gt;02SEP2022 146.204,88&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;05SEP2022 147.946,40&lt;BR /&gt;06SEP2022 147.999.752,70&lt;BR /&gt;07SEP2022 152.085.201,11&lt;BR /&gt;08SEP2022 154.195,98&lt;BR /&gt;09SEP2022 149.789.820,12&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;12SEP2022 141.755.850,87&lt;BR /&gt;13SEP2022 140.970.282,19&lt;BR /&gt;14SEP2022 143.708,69&lt;BR /&gt;15SEP2022 140.896.452,76&lt;BR /&gt;16SEP2022 138.298.019,82&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;30SEP2022 141.237,33&lt;/P&gt;&lt;P&gt;in my dataset there isn't saturady and sunday; i had to include !!&lt;BR /&gt;the balance of saturday (3th) and sunday (4th) is the same of friday (2th)&lt;BR /&gt;i had to calculate an average based on mounth (e.s september, 30 days).&lt;BR /&gt;so i had to sum the balances of each day of the mounth.&lt;BR /&gt;the problem is: my extraction is without saturday and sunday (but also there isn't the 25th december, 1° january, ect.).&lt;BR /&gt;so, i want to realize this table:&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CTV_SALDO&lt;BR /&gt;01SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;145.026,70&lt;BR /&gt;02SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;146.204,88&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;saturday&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;146.204,88 i had to insert date and import the same friday&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;sunday&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;146.204,88 i had to insert date and import the same friday&lt;BR /&gt;05SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;147.946,40&lt;BR /&gt;06SEP2022&amp;nbsp; &amp;nbsp; 147.999.752,70&lt;BR /&gt;07SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp;152.085.201,11&lt;BR /&gt;08SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 154.195,98&lt;BR /&gt;09SEP2022&amp;nbsp; &amp;nbsp; &amp;nbsp;149.789.820,12&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;saturday&lt;/FONT&gt; &lt;STRONG&gt;149.789.820,12 i had to insert date and import the same friday&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;sunday&lt;/FONT&gt; &lt;STRONG&gt;149.789.820,12 i had to insert date and import the same friday&lt;/STRONG&gt;&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;...&lt;BR /&gt;30SEP2022 141.237,33&lt;BR /&gt;avarage&lt;BR /&gt;to calculate --&amp;gt; ______________ sum balances in each day/30&lt;BR /&gt;is there a command to insert saturday and sunday?&lt;BR /&gt;at the same time, i had to insert the same balance of friday in saturday and sunday&lt;/P&gt;&lt;P&gt;thanks for you helping !!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 13:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/838628#M332212</guid>
      <dc:creator>PPPiraneo</dc:creator>
      <dc:date>2022-10-14T13:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840182#M332218</link>
      <description>&lt;P&gt;If your dates are SAS dates and not character strings, inserting Saturday and Sunday should be easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   if weekday(dtcont) = 6 then do;   /* identify Fridays */
      dtcont + 1;   /* add Saturday using Friday data */
      output;
      dtcont + 1;   /* add Sunday using Friday data */
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To handle other missing points, it would be easiest if you would actually supply a list of the missing days.&amp;nbsp; "Etc." is not specific enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea here is to create a complete data set with all the dates present.&amp;nbsp; Calculating monthly statistics would be easy at that point, but post again if that part gives you any trouble.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 02:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840182#M332218</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-10-24T02:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840243#M332246</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input DTCONT : date9. CTV_SALDO : commax32.;
format DTCONT  date9. CTV_SALDO  commax32.2;
cards;
01SEP2022 145.026,70
02SEP2022 146.204,88
05SEP2022 147.946,40
06SEP2022 147.999.752,70
07SEP2022 152.085.201,11
08SEP2022 154.195,98
09SEP2022 149.789.820,12
12SEP2022 141.755.850,87
13SEP2022 140.970.282,19
14SEP2022 143.708,69
15SEP2022 140.896.452,76
16SEP2022 138.298.019,82
;

data want;
 merge have have(firstobs=2 keep=DTCONT rename=(DTCONT=_DTCONT));
 output;
 do DTCONT=DTCONT+1 to ifn(missing(_DTCONT),0,_DTCONT-1);
  output;
 end;
 drop _DTCONT;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2022 11:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840243#M332246</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-24T11:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840348#M332287</link>
      <description>&lt;P&gt;Very neat &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; , but you might want to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do DTCONT = DTCONT + 1 to coalesce(_DTCONT, DTCONT) - 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead, to avoid getting note in the LOG and to refer to zero as a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 19:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840348#M332287</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-10-24T19:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840421#M332303</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If your dates are SAS dates and not character strings, inserting Saturday and Sunday should be easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   if weekday(dtcont) = 6 then do;   /* identify Fridays */
      dtcont + 1;   /* add Saturday using Friday data */
      output;
      dtcont + 1;   /* add Sunday using Friday data */
      output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To handle other missing points, it would be easiest if you would actually supply a list of the missing days.&amp;nbsp; "Etc." is not specific enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea here is to create a complete data set with all the dates present.&amp;nbsp; Calculating monthly statistics would be easy at that point, but post again if that part gives you any trouble.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This needs another OUTPUT statement.&amp;nbsp; As is, it only outputs Sats and Suns.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the club.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 23:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840421#M332303</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-10-24T23:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840428#M332307</link>
      <description>Good catch!  That can happen when I post after 10 p.m.</description>
      <pubDate>Tue, 25 Oct 2022 02:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/840428#M332307</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-10-25T02:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculating averages between dates to include saturday and sunday</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/846592#M334661</link>
      <description>&lt;P&gt;Very elegant solution, congratulations. With my colleague PPPiraneo we had to deal with some randomly missing data too, which wasn't included into his initial post, but your solution deals with 99% of the problem anyway.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 12:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-averages-between-dates-to-include-saturday-and/m-p/846592#M334661</guid>
      <dc:creator>lc_isp</dc:creator>
      <dc:date>2022-11-28T12:38:58Z</dc:date>
    </item>
  </channel>
</rss>

