<?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: How to fix Divide by 0 error in code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247451#M46412</link>
    <description>&lt;P&gt;You should set ratio=. (missing value) if the denominator is invalid.&amp;nbsp; Using zero is not correct.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Feb 2016 13:36:40 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-02-02T13:36:40Z</dc:date>
    <item>
      <title>How to fix Divide by 0 error in code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247265#M46327</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New to SAS coding so if you need more details please let me know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the following error when to running a code is EG 4.3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: CLI open cursor error: ERROR: &amp;nbsp;Divide by 0&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample of&amp;nbsp;data set&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;ID &amp;nbsp; Card_Sales &amp;nbsp; Card_Used&lt;/P&gt;&lt;P&gt;001 &amp;nbsp;25 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;002 &amp;nbsp;10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;&lt;P&gt;003 &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;004 &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Code I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Card_Used / Card_Sale as Ratio&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be greatly appreicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247265#M46327</guid>
      <dc:creator>cdw04</dc:creator>
      <dc:date>2016-02-01T18:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Divide by 0 error in code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247266#M46328</link>
      <description>&lt;P&gt;If you were working in a DATA step, the best way would be to use an IF/THEN statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if Card_Sale then Ratio = Card_Used / Card_Sale;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would skip the processing when Card_Sale is either zero or missing.&amp;nbsp; Since it looks like you are working with SQL instead, you would need to add a CASE statement to assign Ratio a missing value when Card_Sale is zero or missing.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247266#M46328</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-02-01T18:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Divide by 0 error in code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247268#M46330</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if card_sales in (0,.) then ratio = 0;
else ratio = card_used/card_sales;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Feb 2016 18:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247268#M46330</guid>
      <dc:creator>DanZ</dc:creator>
      <dc:date>2016-02-01T18:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Divide by 0 error in code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247354#M46371</link>
      <description>&lt;P&gt;Use function &amp;nbsp;DIVIDE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ratio =divide( card_used,card_sales) ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2016 01:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247354#M46371</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-02T01:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Divide by 0 error in code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247451#M46412</link>
      <description>&lt;P&gt;You should set ratio=. (missing value) if the denominator is invalid.&amp;nbsp; Using zero is not correct.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 13:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Divide-by-0-error-in-code/m-p/247451#M46412</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-02-02T13:36:40Z</dc:date>
    </item>
  </channel>
</rss>

