<?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: Macro Divide by Zero in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41660#M8534</link>
    <description>And, the DIVIDE function was designed to allow divide by zero without issuing that error message:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/19/965.html" target="_blank"&gt;http://support.sas.com/kb/19/965.html&lt;/A&gt; &lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
    <pubDate>Thu, 31 Mar 2011 18:38:20 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2011-03-31T18:38:20Z</dc:date>
    <item>
      <title>Macro Divide by Zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41658#M8532</link>
      <description>Hi all:&lt;BR /&gt;
&lt;BR /&gt;
I'm not great with macros but I have a problem.  How do I correct a 'divide by zero' when the values in question are macro variables?&lt;BR /&gt;
&lt;BR /&gt;
Here is a chunk of my code:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
                                                                                                                                        &lt;BR /&gt;
  proc sql;                                                                                                                             &lt;BR /&gt;
  select unique count(*) into :d_rec_count from worka;                                                                                &lt;BR /&gt;
  select unique count(*) into :d_clo_count from worka where resolvedDT ne .;                                                            &lt;BR /&gt;
  select unique &amp;amp;d_clo_count/&amp;amp;d_rec_count into :d_clo_percent from worka;                                                               &lt;BR /&gt;
  quit;                                                                                                                                 &lt;BR /&gt;
  run;                                                                                                                                  &lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
but when the divisor in the last 'select' is 0 (zero), I get a message 'No rows were selected' and the value of &amp;amp;d_clo_percent is incorrect.&lt;BR /&gt;
&lt;BR /&gt;
I think what I need to do is check that the value of the divisor is zero and set d_clo_percent to 0 (zero) somehow.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Thu, 31 Mar 2011 15:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41658#M8532</guid>
      <dc:creator>OS2Rules</dc:creator>
      <dc:date>2011-03-31T15:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Divide by Zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41659#M8533</link>
      <description>how about:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select sum(case when resolvedDT ne . then 1 else 0 end) / count(*)&lt;BR /&gt;
from worka;&lt;BR /&gt;
quit;</description>
      <pubDate>Thu, 31 Mar 2011 16:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41659#M8533</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-03-31T16:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Divide by Zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41660#M8534</link>
      <description>And, the DIVIDE function was designed to allow divide by zero without issuing that error message:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/19/965.html" target="_blank"&gt;http://support.sas.com/kb/19/965.html&lt;/A&gt; &lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 31 Mar 2011 18:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Divide-by-Zero/m-p/41660#M8534</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-03-31T18:38:20Z</dc:date>
    </item>
  </channel>
</rss>

