<?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: Wrong calculated ouput in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717703#M27542</link>
    <description>&lt;P&gt;You mention PROC SQL.&amp;nbsp; It is possible you are pulling data from some foreign database that has the variable RATE defined with some restrictive data type such as DECIMAL instead of the floating point numbers that SAS uses?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so what happens if you convert from using integer constants to using floating point constants in your formula?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(Rate/100.0/360.0) as r&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Feb 2021 19:05:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-02-08T19:05:48Z</dc:date>
    <item>
      <title>Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717520#M27515</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a raw dataset including a column Rate with interest rates in format e.g. 3.11 and I include in a proc sql&amp;nbsp; the following calculation&lt;/P&gt;
&lt;P&gt;(Rate/100/360) as r.&lt;/P&gt;
&lt;P&gt;The correct result is 0.0000864 yet the code outputs 0.0000900.&lt;/P&gt;
&lt;P&gt;I have tried with formats but the result remains the same.&lt;/P&gt;
&lt;P&gt;When I create a small testing table with same rates and the same code, the result is correct. But when I'm running the code in the initial dataset, the output is wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas why?&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 09:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717520#M27515</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2021-02-08T09:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717532#M27516</link>
      <description>&lt;P&gt;It seems to me that you imported the raw data with a wrong INFORMAT.&lt;/P&gt;
&lt;P&gt;Check the dataset created by import does it show the right and whole imported value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 10:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717532#M27516</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-08T10:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717534#M27517</link>
      <description>When I'm checking the column Rate in the raw dataset the value is correctly visible as 3.11.&lt;BR /&gt;The raw dataset is stored in main server so I cannot control the INFORMAT.</description>
      <pubDate>Mon, 08 Feb 2021 10:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717534#M27517</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2021-02-08T10:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717547#M27518</link>
      <description>&lt;P&gt;What output do you get running proc print?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have(obs=20);
 var rate;
 format rate 5.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 11:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717547#M27518</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-08T11:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717552#M27519</link>
      <description>&lt;P&gt;Interesting, does not happen when using a data step:&lt;/P&gt;
&lt;PRE&gt;28         data _null_;
29            rate = 3.11;
30            r = rate / 100 / 360;
31            put _All_;
32         run;

rate=3.11 r=0.0000863889 _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;
&lt;P&gt;And happens in proc sql only if the create table statement is omitted, so this is just a display-problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 11:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717552#M27519</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-08T11:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717562#M27523</link>
      <description>I get &lt;BR /&gt;3.11&lt;BR /&gt;2.63&lt;BR /&gt;5.40&lt;BR /&gt;&lt;BR /&gt;etc</description>
      <pubDate>Mon, 08 Feb 2021 13:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717562#M27523</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2021-02-08T13:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717564#M27524</link>
      <description>&lt;DIV class="forum-topic-flex-article"&gt;
&lt;DIV class="forum-article"&gt;
&lt;DIV class="forum-post"&gt;
&lt;DIV id="bodyDisplay_186ec0d7323782" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;I get&lt;BR /&gt;3.11&lt;BR /&gt;2.63&lt;BR /&gt;5.40&lt;BR /&gt;&lt;BR /&gt;etc&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="kudosButtonV2_4" class="KudosButton lia-button-image-kudos-wrapper lia-component-kudos-widget-button-version-3 lia-component-kudos-widget-button-horizontal lia-component-kudos-widget-button lia-component-kudos-action lia-component-message-view-widget-kudos-action" data-lia-kudos-id="717562"&gt;
&lt;DIV class="lia-button-image-kudos lia-button-image-kudos-horizontal lia-button-image-kudos-disabled lia-button-image-kudos-not-kudoed lia-button"&gt;
&lt;DIV class="lia-button-image-kudos-count" aria-atomic="true" aria-live="assertive"&gt;&lt;SPAN class="lia-link-navigation kudos-count-link lia-link-disabled" title="The total number of likes this post has received."&gt;&lt;SPAN class="MessageKudosCount lia-component-kudos-widget-message-kudos-count" aria-label="Kudos Count 0"&gt;0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-button-image-kudos-label lia-component-kudos-widget-kudos-count-label"&gt;Likes&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="lia-button-image-kudos-give" title="Sorry, you can't give likes to this post."&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 Feb 2021 13:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717564#M27524</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2021-02-08T13:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717566#M27525</link>
      <description>&lt;P&gt;The error is present in proc sql either including Create table command or excluding it.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 13:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717566#M27525</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2021-02-08T13:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717604#M27528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254213"&gt;@cmemtsa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a raw dataset including a column Rate with interest rates in format e.g. 3.11 and I include in a proc sql&amp;nbsp; the following calculation&lt;/P&gt;
&lt;P&gt;(Rate/100/360) as r.&lt;/P&gt;
&lt;P&gt;The correct result is 0.0000864 yet the code outputs 0.0000900.&lt;/P&gt;
&lt;P&gt;I have tried with formats but the result remains the same.&lt;/P&gt;
&lt;P&gt;When I create a small testing table with same rates and the same code, the result is correct. But when I'm running the code in the initial dataset, the output is wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas why?&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what formats did you try? If you did not specify a format that would allow at least &lt;STRONG&gt;8&lt;/STRONG&gt; decimals then you would see a result rounded to the number of decimals allowed by the format. And what SAS procedure did you use that shows the 0.0000900 with two trailing 0's?&lt;/P&gt;
&lt;P&gt;Your "correct answer" is ROUNDED as well.&lt;/P&gt;
&lt;PRE&gt;data example;
   rate=3.11;
   r = (Rate/100/360) ;
   put 'Format best5. ' r= best5.;
   put 'Format best6. ' r= best6.;
   put 'Format best7. ' r= best7.;
   put 'Format best8. ' r= best8.;
   put 'Format f9.7 '   r= f9.7;
   put 'Format best10.' r= best10.;
   put 'Format 10.8'    r= f10.8;
   put 'Format best32.' r= best32.;
run;
&lt;/PRE&gt;
&lt;P&gt;And what are the formats of the variables in the "initial dataset"? Perhaps you are seeing a rounded value to begin with an you have something like 3.112 not exactly 3.11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 15:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717604#M27528</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-08T15:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717686#M27541</link>
      <description>&lt;P&gt;There is no problem when using an appropriate format as demonstrated in next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   rate = 3.11; output;
run;
data check;
 set have;
     r = rate /360/100;
     format rate 12.8;
run;
proc sql;
 create table chk as
 select rate,
        (rate/360/100) as r 
 from have
; quit;
proc sql;
 select rate,
        (rate/360/100) as r format 12.8
 from have
; quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 18:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717686#M27541</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-08T18:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717703#M27542</link>
      <description>&lt;P&gt;You mention PROC SQL.&amp;nbsp; It is possible you are pulling data from some foreign database that has the variable RATE defined with some restrictive data type such as DECIMAL instead of the floating point numbers that SAS uses?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so what happens if you convert from using integer constants to using floating point constants in your formula?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(Rate/100.0/360.0) as r&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 19:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717703#M27542</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-08T19:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong calculated ouput</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717789#M27548</link>
      <description>&lt;P&gt;Please show the result of proc contents using your source dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 06:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Wrong-calculated-ouput/m-p/717789#M27548</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-09T06:27:36Z</dc:date>
    </item>
  </channel>
</rss>

