<?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 Why SAS can't output (-3)**(-3) in do loop? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67182#M19207</link>
    <description>First program:&lt;BR /&gt;
data c;&lt;BR /&gt;
x=-3;&lt;BR /&gt;
y=x**x;&lt;BR /&gt;
run;&lt;BR /&gt;
/* we can get y=-0.037037037 by first program. */&lt;BR /&gt;
&lt;BR /&gt;
Second program:&lt;BR /&gt;
data a;&lt;BR /&gt;
do x=-5 to 5 by 0.01;&lt;BR /&gt;
 y=x**x;&lt;BR /&gt;
 output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
/* From x=-4.99 to 0, the y value is empty. Even x=-3, the y is empty too. */&lt;BR /&gt;
&lt;BR /&gt;
How could this happen?&lt;BR /&gt;
Could anyone help to interpret this?</description>
    <pubDate>Thu, 25 Dec 2008 08:15:59 GMT</pubDate>
    <dc:creator>Black</dc:creator>
    <dc:date>2008-12-25T08:15:59Z</dc:date>
    <item>
      <title>Why SAS can't output (-3)**(-3) in do loop?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67182#M19207</link>
      <description>First program:&lt;BR /&gt;
data c;&lt;BR /&gt;
x=-3;&lt;BR /&gt;
y=x**x;&lt;BR /&gt;
run;&lt;BR /&gt;
/* we can get y=-0.037037037 by first program. */&lt;BR /&gt;
&lt;BR /&gt;
Second program:&lt;BR /&gt;
data a;&lt;BR /&gt;
do x=-5 to 5 by 0.01;&lt;BR /&gt;
 y=x**x;&lt;BR /&gt;
 output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
/* From x=-4.99 to 0, the y value is empty. Even x=-3, the y is empty too. */&lt;BR /&gt;
&lt;BR /&gt;
How could this happen?&lt;BR /&gt;
Could anyone help to interpret this?</description>
      <pubDate>Thu, 25 Dec 2008 08:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67182#M19207</guid>
      <dc:creator>Black</dc:creator>
      <dc:date>2008-12-25T08:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS can't output (-3)**(-3) in do loop?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67183#M19208</link>
      <description>That looks like a bug to me. &lt;BR /&gt;
Report it to SAS TechSupport.&lt;BR /&gt;
&lt;BR /&gt;
data c;&lt;BR /&gt;
  y=-3.1**-3.1;&lt;BR /&gt;
  put 'Case 1: ' y=;&lt;BR /&gt;
&lt;BR /&gt;
  x=3.1;&lt;BR /&gt;
  y=x**-3.1;&lt;BR /&gt;
  put 'Case 2: ' y=;&lt;BR /&gt;
&lt;BR /&gt;
  x=-3.1;&lt;BR /&gt;
  y=-3.1**x;&lt;BR /&gt;
  put 'Case 3: ' y=;&lt;BR /&gt;
&lt;BR /&gt;
  x=-3.1;&lt;BR /&gt;
  y=x**-3.1;&lt;BR /&gt;
  put 'Case 4: ' y=;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 26 Dec 2008 00:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67183#M19208</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-12-26T00:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS can't output (-3)**(-3) in do loop?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67184#M19209</link>
      <description>Actually, it's not a bug.  y**x, where y is a negative number, is called a discontinuous function -- it is not defined for every value on the real line.  For instance, (-4)**2 is well defined (16), but (-4)**(1/2) (e.g. the square root of -4) is unknown.&lt;BR /&gt;
&lt;BR /&gt;
In Black's case, my guess is that when (-3)**(-3) is rendered, SAS gets the exact value 3, but there is some rounding in the repeated additions in the do-loop, and then the discontinuous nature of using a negative base comes into play.  SAS gives an invalid argument error message for the results it could not compute.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Fri, 26 Dec 2008 19:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67184#M19209</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2008-12-26T19:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS can't output (-3)**(-3) in do loop?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67185#M19210</link>
      <description>O.K. - But why then works case1 and case4 doesn't?&lt;BR /&gt;
&lt;BR /&gt;
The only thing I can think of right now would be 'precision'.</description>
      <pubDate>Sat, 27 Dec 2008 00:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-SAS-can-t-output-3-3-in-do-loop/m-p/67185#M19210</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-12-27T00:56:37Z</dc:date>
    </item>
  </channel>
</rss>

