<?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 SAS Date/Balance Sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362979#M85816</link>
    <description>&lt;DIV style="color: rgb(0, 0, 0); font-size: 9pt; direction: ltr;"&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imcontent" style="margin-left: 12px;"&gt;
&lt;DIV&gt;Hi,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I have a problem where SAS and Excel totals differ&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Weighted_avg_term_date in EXCEL&lt;BR /&gt;Term_date * Total_Balance = X&lt;/DIV&gt;
&lt;DIV&gt;02/04/2028 * 7582557.23 = &amp;nbsp;355206924974.97&lt;BR /&gt;&lt;BR /&gt;Weighted_avg_term_date in SAS&lt;BR /&gt;Term_date * Total_Balance = Y&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imwidget" style="margin-left: 5px;"&gt;&amp;nbsp;&amp;nbsp; 02/04/2028 * 7582557.23 =&amp;nbsp;&amp;nbsp;189027600722.29&lt;/DIV&gt;
&lt;DIV style="margin-left: 5px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imcontent" style="margin-left: 12px;"&gt;
&lt;DIV&gt;Why don't they match when it's the same calculation, now im not sure what's right, SAS or Excel?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Term_Date is a Date variable.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 31 May 2017 09:45:13 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2017-05-31T09:45:13Z</dc:date>
    <item>
      <title>SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362979#M85816</link>
      <description>&lt;DIV style="color: rgb(0, 0, 0); font-size: 9pt; direction: ltr;"&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imcontent" style="margin-left: 12px;"&gt;
&lt;DIV&gt;Hi,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I have a problem where SAS and Excel totals differ&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Weighted_avg_term_date in EXCEL&lt;BR /&gt;Term_date * Total_Balance = X&lt;/DIV&gt;
&lt;DIV&gt;02/04/2028 * 7582557.23 = &amp;nbsp;355206924974.97&lt;BR /&gt;&lt;BR /&gt;Weighted_avg_term_date in SAS&lt;BR /&gt;Term_date * Total_Balance = Y&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imwidget" style="margin-left: 5px;"&gt;&amp;nbsp;&amp;nbsp; 02/04/2028 * 7582557.23 =&amp;nbsp;&amp;nbsp;189027600722.29&lt;/DIV&gt;
&lt;DIV style="margin-left: 5px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="Normalcontent" style="padding: 0px 3px; clear: both; position: relative;"&gt;
&lt;DIV id="imcontent" style="margin-left: 12px;"&gt;
&lt;DIV&gt;Why don't they match when it's the same calculation, now im not sure what's right, SAS or Excel?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Term_Date is a Date variable.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 May 2017 09:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362979#M85816</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-05-31T09:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362982#M85817</link>
      <description>&lt;P&gt;Dates are stored differently in SAS and Excel. &amp;nbsp;SAS dates are number of days since&amp;nbsp;&lt;SPAN&gt;January 1, 1960. &amp;nbsp;Excel has a 1900 (I think from memory) start date, hence why you have different results. &amp;nbsp;The real question here is why you are multiplying a Date - i.e. not a time period or number of days etc. - but a numeric. &amp;nbsp;I think you have your formula wrong there, maybe you need number of days * value or something.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;E.g. in SAS 02/04/2008 is mmddyy8., = 21949.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 09:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362982#M85817</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-31T09:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362984#M85818</link>
      <description>&lt;P&gt;This was the calculation they felt was correct. All I have been tasked with is replicating the numbers within SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 09:54:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362984#M85818</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-05-31T09:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362986#M85819</link>
      <description>&lt;P&gt;You will need to point out the incorrectness to "them" then. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming the date is 04Feb2028:&lt;/P&gt;
&lt;P&gt;SAS:&lt;/P&gt;
&lt;P&gt;21949 *&amp;nbsp;&lt;SPAN&gt;7582557.23&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel:&lt;/P&gt;
&lt;P&gt;46787 *&amp;nbsp;&lt;SPAN&gt;7582557.23&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is why you get the different results, the base interpretation of what a date is differs between the two systems, and is also the prime reason why this calculation makes no sense whatsoever. &amp;nbsp;If you move it to another system, then the number will change again. &amp;nbsp;The calculation needs to be based on some fixed data, not an adhoc representation of how a system calculates dates.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 09:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362986#M85819</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-31T09:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362989#M85822</link>
      <description>&lt;P&gt;You are multiplying a DATE with an AMOUNT? You're joking, right?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 10:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362989#M85822</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-31T10:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362992#M85824</link>
      <description>&lt;P&gt;Nope but that isn't for me to get invloved with, nothing to do with me! All I have been asked to do is replicate what they have calculated within excel whether or not I agree with it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 10:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/362992#M85824</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2017-05-31T10:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363021#M85843</link>
      <description>&lt;P&gt;First of all, this is so utterly, incredibly stupid that my head hurts just thinking about it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tested this "calculation" with Excel 2010, and - lo and behold! - I get a different result already:&lt;/P&gt;
&lt;TABLE width="431"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="80"&gt;04.02.2028&lt;/TD&gt;
&lt;TD width="80"&gt;7582557,23&lt;/TD&gt;
&lt;TD width="271"&gt;354765105120,01&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;02.04.2028&lt;/TD&gt;
&lt;TD&gt;7582557,23&lt;/TD&gt;
&lt;TD&gt;355204893439,35&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Note that I tested your date as DDMMYY or MMDDYY&lt;/P&gt;
&lt;P&gt;Are you sure that you are showing the complete Excel calculation in your initial post?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same result is achieved with LibreOffice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, if we take care of the date offset inherent in Excel:&lt;/P&gt;
&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="611"&gt;&lt;COLGROUP&gt;&lt;COL span="2" width="80" /&gt;&lt;COL width="271" /&gt;&lt;COL width="180" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xl65" style="height: 15.0pt; width: 60pt;" align="right" height="20" width="80"&gt;02.04.2028&lt;/TD&gt;
&lt;TD class="xl65" style="width: 60pt;" align="right" width="80"&gt;01.01.1900&lt;/TD&gt;
&lt;TD style="width: 203pt;" align="right" width="271"&gt;7582557,23&lt;/TD&gt;
&lt;TD class="xl66" style="width: 135pt;" align="right" width="180"&gt;355197310882,12&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;(subtracting column B from A and using the result in the multiplication)&lt;/P&gt;
&lt;P&gt;and do the same in SAS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
val1 = ('02apr2028'd - '31dec1899'd) * 7582557.23;
put val1= 20.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;we get this:&lt;/P&gt;
&lt;PRE&gt;24         data _null_;
25         val1 = ('02apr2028'd - '31dec1899'd) * 7582557.23;
26         put val1= 20.2;
27         run;

val1=355197310882.12
&lt;/PRE&gt;
&lt;P&gt;Tadaa!&lt;/P&gt;
&lt;P&gt;(Note that one has to use 31dec1899 because of a serious date calculation bug in Excel, which thinks that 1900 was a leap year)&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 11:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363021#M85843</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-31T11:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363101#M85890</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Note that one has to use 31dec1899 because of a serious date calculation bug in Excel, which thinks that 1900 was a leap year)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;AND Excel thinks 0 Jan 1900 is a valid date.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363101#M85890</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-31T14:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363112#M85896</link>
      <description>&lt;P&gt;I hope you at least bring up the issue here (that this doesn't really make sense). If you worked for me and didn't, I'd consider it a major negative in your review. Of course it may well be for someone else to say that it does make sense, but that's up to them once you point it out. &amp;nbsp;Simply hiding behind 'it's not my job' is not a sign of a good employee.&lt;BR /&gt;&lt;BR /&gt;Of course if they're evaluating the change in (whatever) since 1/1/1900, then this is fine. But that's an important detail, don't you think? &amp;nbsp;And if that's&amp;nbsp;what they're doing, then Kurt's answer is the correct one. &amp;nbsp;In fact you might ask whether they want the actual change since 1/1/1900, or the Excel-incorrect value, which will be slightly different - again as Kurt points out, Excel incorrectly considers 2/29/1900 a valid date, so it counts one more day in the period 1/1/1900-&amp;gt;today than it should. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may well be that replicating the bug is desired - that replicability is the key here and not accuracy - but I'd definitely want that documented as a specific requirement (the 2/29/1900 day being included) so that in 5 years when&amp;nbsp;my successor asks why we're subtracting 12/31/1899 the documentation explains why - and who made the decision.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 15:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363112#M85896</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2017-05-31T15:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date/Balance Sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363165#M85926</link>
      <description>&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;For a humorous but informative view of Excel dates:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;&lt;STRONG&gt;My First BillG Review&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT face="verdana,geneva"&gt;&lt;A href="https://www.joelonsoftware.com/2006/06/16/my-first-billg-review" target="_blank"&gt;https://www.joelonsoftware.com/2006/06/16/my-first-billg-review&lt;/A&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Vince DelGobbo&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;SAS R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 17:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Date-Balance-Sum/m-p/363165#M85926</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2017-05-31T17:30:27Z</dc:date>
    </item>
  </channel>
</rss>

