<?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 Missing values in addition or substraction generate error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150190#M39595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table (mylib) that contains 3 variables and some have missing values that. They are automatically replaced by a dot in my SAS table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to make a simple arithmetic equation, but the result is always 0. Can you please help me with the following proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.test as select&lt;/P&gt;&lt;P&gt;(mytable.var1 + mytable.var2 - mytable.var3) as my_calculation&lt;/P&gt;&lt;P&gt;from mylib.mytable as mytable&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and time!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Feb 2015 22:44:23 GMT</pubDate>
    <dc:creator>nicnad</dc:creator>
    <dc:date>2015-02-02T22:44:23Z</dc:date>
    <item>
      <title>Missing values in addition or substraction generate error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150190#M39595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table (mylib) that contains 3 variables and some have missing values that. They are automatically replaced by a dot in my SAS table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to make a simple arithmetic equation, but the result is always 0. Can you please help me with the following proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table work.test as select&lt;/P&gt;&lt;P&gt;(mytable.var1 + mytable.var2 - mytable.var3) as my_calculation&lt;/P&gt;&lt;P&gt;from mylib.mytable as mytable&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and time!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2015 22:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150190#M39595</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2015-02-02T22:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values in addition or substraction generate error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150191#M39596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With a single table you're being a bit redundant mentioning the dataset name everywhere but no syntax issue.&lt;/P&gt;&lt;P&gt;Some values for your input might help.&lt;/P&gt;&lt;P&gt;HOWEVER you need to know that missing + value = missing. So if any of the values are missing the way you have written you are, in effect getting a Boolean of False. If it was summing 3 variable then the SUM function would be sufficient as that is what it is designed for.&lt;/P&gt;&lt;P&gt;Because you are incorporating a subtraction there isn't an elegant solution but you might use a case statement similar to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when missing(var3) then sum(var1,var2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else (sum(var1,var2) - var3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end as my_calculation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we need additional information about what kind of result you expect with var1 and var2 are missing and var3 is not missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some example input data and expected output may be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2015 23:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150191#M39596</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-02-02T23:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values in addition or substraction generate error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150192#M39597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the sum function if you can assume that missing values can be ignored.&lt;/P&gt;&lt;P&gt;Otherwise you'll need to deal with them some other way, depends on the data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;mytable.var1, mytable.var2, -1*mytable.var3) as my_calculation&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Feb 2015 23:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Missing-values-in-addition-or-substraction-generate-error/m-p/150192#M39597</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-02T23:30:49Z</dc:date>
    </item>
  </channel>
</rss>

