<?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: missing function vs = . numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744018#M29283</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/371433"&gt;@JC411911&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&amp;nbsp;, Thanks for your time.I did try the below code and it did work perfect. It does seem to simply the code as all left over results are sent to highcol. The misschol also had the correct results, but to your point I think from here on out I will utilize missing() for this. Dumb question but can I use the missing function for character values as well or is this a numeric function only?&lt;/P&gt;
&lt;PRE&gt;if cholesterol = . then
		output work.misschol;
	else if cholesterol lt 200 then
		output work.lowchol;
	else
		output work.highchol;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, the MISSING function works on both Character or Numeric data.&amp;nbsp; It's a great function.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So several I think good points here:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Missing values are considered&amp;nbsp;&lt;EM&gt;lower&lt;/EM&gt; than even large negative numbers.&amp;nbsp; In IF statements, &lt;STRONG&gt;Check for Missing first&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;MISSING() works for both character or numeric&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;MISSING() for numeric is superior&lt;/STRONG&gt; because it will check for all valid representations of Missing, not just a period.&lt;/LI&gt;
&lt;LI&gt;The last ELSE in a series of IF THEN ELSE statements should generally &lt;EM&gt;not&lt;/EM&gt; have another condition.&amp;nbsp; In other words, &lt;STRONG&gt;the last ELSE should be a default&lt;/STRONG&gt; which will catch anything not covered in the conditions of the IF's.&lt;/LI&gt;
&lt;LI&gt;When comparing the results of two different conditionals, (e.g. IF vs IF, IF vs. WHERE), &lt;STRONG&gt;check the conditions in the same order&lt;/STRONG&gt;.&amp;nbsp; "Apples to apples" makes for a valid comparison.&amp;nbsp; "Apples to oranges" does not.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2021 19:38:02 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2021-05-26T19:38:02Z</dc:date>
    <item>
      <title>missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743736#M29259</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am practicing with these data steps and if/else scenarios. Both data steps run fine but for the missing values being output to work.misschol I get different results. I can't understand why the highlited statement below isn't working when using = . but missing(cholesterol) is working. The cholesterol variable is numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.lowchol work.highchol work.misschol;
	set sashelp.heart;

	if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
	&lt;FONT color="#FF0000"&gt;else if cholesterol = . then
		output work.misschol;&lt;/FONT&gt;
run;

data work.lowchol work.highchol work.misschol;
	set sashelp.heart;

	if missing(cholesterol) then
		output work.misschol;
	else if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
run;&lt;/PRE&gt;&lt;P&gt;Thank you for your time and help in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 02:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743736#M29259</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-26T02:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743741#M29260</link>
      <description>&lt;P&gt;In SAS, missing values for numerics are taken to be "less than" all valid values, including all valid negative values.&amp;nbsp; So missing values meet your first test condition in&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
	else if cholesterol = . then
		output work.misschol;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;As a result, the 3rd condition ("else if cholesterol=.") is never assessed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you change the order of conditions, you should get what you expect:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if cholesterol = . then
		output work.misschol;
    else if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or better yet (to include missing values from .A to .Z&amp;nbsp; and ._):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if missing(cholesterol) then
		output work.misschol;
    else if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 May 2021 03:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743741#M29260</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-26T03:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743742#M29261</link>
      <description>&lt;P&gt;Well, it could be a couple of things.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;There are more missing numeric value representations than just "."&amp;nbsp; For example, ".A" through ".Z" are also valid representations of missing values.&amp;nbsp; The MISSING() function is generally better than IF var = . because MISSING will identify all valid representations of missing whereas an IF statement will only identify the missing representation that is specified.&lt;/LI&gt;
&lt;LI&gt;Your IF statements are in a different order.&amp;nbsp; If you want the same results from two different forms of an IF statement, the conditions in the IF statements should be in the same order.&lt;/LI&gt;
&lt;LI&gt;Lastly, the IF statement could be improved by having a default ELSE.&amp;nbsp; In other words, the final ELSE statement shouldn't have an&amp;nbsp;IF under it.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Regarding #3, try this:&lt;/P&gt;
&lt;P&gt;Change this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if cholesterol lt 200 then
		output work.lowchol;
	else if cholesterol ge 200 then
		output work.highchol;
	else if cholesterol = . then
		output work.misschol;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to the below and re-run.&amp;nbsp; I'd be very interested to know your results.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	if cholesterol = . then
		output work.misschol;
	else if cholesterol lt 200 then
		output work.lowchol;
	else
		output work.highchol;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope that helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 03:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743742#M29261</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-26T03:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743986#M29278</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your help and explanation. I wasn't aware that the order of my statements would cause this to occur. Glad to have learned that moving the =. to the first if statement would work. I did test and got the correct results. That being said I will continue to use missing() for this scenario to consider other values. Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 18:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743986#M29278</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-26T18:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743987#M29279</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&amp;nbsp;, Thanks for your time.I did try the below code and it did work perfect. It does seem to simply the code as all left over results are sent to highcol. The misschol also had the correct results, but to your point I think from here on out I will utilize missing() for this. Dumb question but can I use the missing function for character values as well or is this a numeric function only?&lt;/P&gt;&lt;PRE&gt;if cholesterol = . then
		output work.misschol;
	else if cholesterol lt 200 then
		output work.lowchol;
	else
		output work.highchol;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 May 2021 18:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/743987#M29279</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-26T18:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744004#M29281</link>
      <description>&lt;P&gt;MISSING() works on character values also.&amp;nbsp; Strings with only spaces are considered missing.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 19:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744004#M29281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-26T19:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744012#M29282</link>
      <description>Thank you Tom!</description>
      <pubDate>Wed, 26 May 2021 19:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744012#M29282</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-05-26T19:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: missing function vs = . numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744018#M29283</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/371433"&gt;@JC411911&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&amp;nbsp;, Thanks for your time.I did try the below code and it did work perfect. It does seem to simply the code as all left over results are sent to highcol. The misschol also had the correct results, but to your point I think from here on out I will utilize missing() for this. Dumb question but can I use the missing function for character values as well or is this a numeric function only?&lt;/P&gt;
&lt;PRE&gt;if cholesterol = . then
		output work.misschol;
	else if cholesterol lt 200 then
		output work.lowchol;
	else
		output work.highchol;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, the MISSING function works on both Character or Numeric data.&amp;nbsp; It's a great function.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So several I think good points here:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Missing values are considered&amp;nbsp;&lt;EM&gt;lower&lt;/EM&gt; than even large negative numbers.&amp;nbsp; In IF statements, &lt;STRONG&gt;Check for Missing first&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;MISSING() works for both character or numeric&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;MISSING() for numeric is superior&lt;/STRONG&gt; because it will check for all valid representations of Missing, not just a period.&lt;/LI&gt;
&lt;LI&gt;The last ELSE in a series of IF THEN ELSE statements should generally &lt;EM&gt;not&lt;/EM&gt; have another condition.&amp;nbsp; In other words, &lt;STRONG&gt;the last ELSE should be a default&lt;/STRONG&gt; which will catch anything not covered in the conditions of the IF's.&lt;/LI&gt;
&lt;LI&gt;When comparing the results of two different conditionals, (e.g. IF vs IF, IF vs. WHERE), &lt;STRONG&gt;check the conditions in the same order&lt;/STRONG&gt;.&amp;nbsp; "Apples to apples" makes for a valid comparison.&amp;nbsp; "Apples to oranges" does not.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 19:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/missing-function-vs-numeric/m-p/744018#M29283</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-05-26T19:38:02Z</dc:date>
    </item>
  </channel>
</rss>

