<?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: Calculation with Null values in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827925#M16332</link>
    <description>&lt;P&gt;I don't have Viya, but it looks like there is a SUM function that ignores missings, like base SAS.&amp;nbsp; So maybe you could do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;R=sum(A,-B,-C);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 17:21:01 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-08-09T17:21:01Z</dc:date>
    <item>
      <title>Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827876#M16327</link>
      <description>&lt;P&gt;Hi Everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, I'm using SAS Enterprise Guide V8.3.0.103, SAS Visual Analytics V8.5.2 and SAS VIYA V03.05.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've prepared my data in Enterprise guide.&lt;BR /&gt;I've made a left join between two tables, and, logically, I've got some data with no correspondance and it's make a null value.&lt;/P&gt;&lt;P&gt;For example, in my Table 1 I've an ordered quantity (A),&amp;nbsp; a delivered quantity (B), and in my Table 2 I've got a reserved quantities (C).&lt;/P&gt;&lt;P&gt;Of course, because of I haven't a reserved quantity for each order, the reserverd quantity may be equal to NULL.&lt;/P&gt;&lt;P&gt;I want to create a calculated element (R), the formula is :&lt;/P&gt;&lt;P&gt;R = A-B-C&lt;/P&gt;&lt;P&gt;R = 4-2-NULL =&amp;gt; Result is "." and I would like to have 2&lt;/P&gt;&lt;P&gt;If C is not null (or missing) my result is correct. If C is null (or missing), I have no result !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What kind of solution may I use to have C = 0 when C is missing or NULL ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Michel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827876#M16327</guid>
      <dc:creator>Genesis007</dc:creator>
      <dc:date>2022-08-09T15:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827885#M16329</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420869"&gt;@Genesis007&lt;/a&gt;! One unique feature of Visual Analytics is the ability to embed if/else statements directly within calculations. You can add your code to convert missing values to 0's in a single line:&lt;/P&gt;
&lt;PRE&gt;A - B - ( if('C'n = .) return 0 else 'C'n )&lt;/PRE&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827885#M16329</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2022-08-09T15:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827896#M16330</link>
      <description>Thank you so much Stu. It's working perfectly,&lt;BR /&gt;I would like to know if there is a solution to automate the transformation of missing numerical values into 0, without writing an if/else statement ?&lt;BR /&gt;It works, and thanks again, but I think it's a little bit difficult and repetitive for a non "power user" guy.&lt;BR /&gt;Michel.</description>
      <pubDate>Tue, 09 Aug 2022 15:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827896#M16330</guid>
      <dc:creator>Genesis007</dc:creator>
      <dc:date>2022-08-09T15:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827918#M16331</link>
      <description>&lt;P&gt;Unfortunately there is not at this time with the exception of doing the data prep beforehand. For example, before loading your data into CAS/LASR, you can loop through an array in a DATA Step to set any missing values of specific variables to 0:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
    set bar;
    array var[*] var1 var2 var3;

    do i = 1 to dim(var);
        if(var[i] = .) then var[i] = 0;
    end;

    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would recommend posting this request in the &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas" target="_self"&gt;SASWare Ballot&lt;/A&gt; as an idea. Thank you for your feedback on this - I have noted it down.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 16:59:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827918#M16331</guid>
      <dc:creator>Stu_SAS</dc:creator>
      <dc:date>2022-08-09T16:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827925#M16332</link>
      <description>&lt;P&gt;I don't have Viya, but it looks like there is a SUM function that ignores missings, like base SAS.&amp;nbsp; So maybe you could do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;R=sum(A,-B,-C);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 17:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/827925#M16332</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-08-09T17:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation with Null values</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/828118#M16339</link>
      <description>Thanks for this tips.&lt;BR /&gt;I'll try it and I'll keep you informed if it's OK.&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Aug 2022 16:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Calculation-with-Null-values/m-p/828118#M16339</guid>
      <dc:creator>Genesis007</dc:creator>
      <dc:date>2022-08-10T16:16:15Z</dc:date>
    </item>
  </channel>
</rss>

