<?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: Where am I wrong in this conditional calculation? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511298#M2151</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Act NE 9999 and SurvA NE 9999 and STD not in (0, 9999) then Surprise_A=(Act-SurvA)/STD;
else Surprise_A=9999;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Nov 2018 06:50:31 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2018-11-08T06:50:31Z</dc:date>
    <item>
      <title>Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511295#M2148</link>
      <description>&lt;P&gt;I want to calculate Surprise_A = (Act - SurvA)/ STD. But there are missing values in each of Act, SurvA and STD. And, STD can also be 0. If there is a missing value in any of these, or STD = 0, I would not calculate Surprise_A for that observation. So I coded the following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Act NE 9999 or SurvA NE 9999 or STD NE 9999 or STD NE 0 then
			Surprise_A=(Act-SurvA)/STD;
				else Surprise_A=9999;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not getting desired results. I still get note for division by 0, and I don't see any Surprise_A having&amp;nbsp; 9999.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where am I wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I much appreciate your time as always.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 06:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511295#M2148</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-11-08T06:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511297#M2150</link>
      <description>&lt;P&gt;Why do you compare with 9999 when you want to check for missing values?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 06:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511297#M2150</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-11-08T06:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511298#M2151</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Act NE 9999 and SurvA NE 9999 and STD not in (0, 9999) then Surprise_A=(Act-SurvA)/STD;
else Surprise_A=9999;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Nov 2018 06:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511298#M2151</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-11-08T06:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511299#M2152</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;, Thank you so much. I was such a stupid!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 06:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511299#M2152</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-11-08T06:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511300#M2153</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239423"&gt;@d6k5d3&lt;/a&gt; - It's easy to get this type of logic mixed up. I'm still doing it after over 30 years of using SAS &lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://communities.sas.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 07:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511300#M2153</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-11-08T07:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511492#M2179</link>
      <description>&lt;P&gt;Just because a data source uses 9999 or similar code for missing does not mean that you have to perpetuate that in a SAS data set. Since SAS has an actual "missing" value (actually many more with special missing like .A .B etc) .&lt;/P&gt;
&lt;P&gt;So set codes that mean missing to be missing for SAS variables.&lt;/P&gt;
&lt;P&gt;Then instead of lots of NE 9999 you can use the MISSING function to test individual variables or NMISS for multiple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you had actual SAS missing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If nmiss(ACT, SurvA, STD) =0 and STD ne 0 then …&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nmiss returns the number of missing values for numeric variables. So if any of them are missing the result would be greater than 0.&lt;/P&gt;
&lt;P&gt;Imagine writing a similar condition for 15 or more variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use of SAS missing values means that you wouldn't even need the Else. If the value isn't calculated then SAS automatically sets it to missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now suppose at some later time you want to calculate a mean (or max or standard deviation or practically any statistic except min) for the Surprise_A variable (or Act or SurvA or STD). Do you really want to include the values of 9999 in the calculation???&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 19:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/511492#M2179</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-08T19:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Where am I wrong in this conditional calculation?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/514662#M2778</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, Awesome! Thank you so much for the insight.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 04:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Where-am-I-wrong-in-this-conditional-calculation/m-p/514662#M2778</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-11-20T04:26:13Z</dc:date>
    </item>
  </channel>
</rss>

