<?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 If/Then/Missing Statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848166#M335338</link>
    <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble with my If/Then/Missing statements. For this example, I'm making BMI categories, but my new variable keeps making my missing values into one of the categories. I'm trying to get if bmi_v1 &amp;gt; 25, then iBMI_v1 = 100 and so on. There are missing values for bmi_v1, but the iBMI puts the missing values as "100" instead of ".".&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data patient.guidelines;
	set  patient.health;
	if (bmi_v1) lt 25 then iBMI_v1 = 100;
	else if (bmi_v1) lt 30 then iBMI_v1 = 70;
	else if (bmi_v1) lt 35 then iBMI_v1 = 30;
	else if (bmi_v1) lt 40 then iBMI_v1 = 15;
	else if (bmi_v1) ge 40 then iBMI_v1 = 0;
	else iBMI_v1 = .;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bmi.PNG" style="width: 383px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78123i275F84ECDFBBF7E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="bmi.PNG" alt="bmi.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2022 17:26:39 GMT</pubDate>
    <dc:creator>chester2018</dc:creator>
    <dc:date>2022-12-06T17:26:39Z</dc:date>
    <item>
      <title>If/Then/Missing Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848166#M335338</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble with my If/Then/Missing statements. For this example, I'm making BMI categories, but my new variable keeps making my missing values into one of the categories. I'm trying to get if bmi_v1 &amp;gt; 25, then iBMI_v1 = 100 and so on. There are missing values for bmi_v1, but the iBMI puts the missing values as "100" instead of ".".&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data patient.guidelines;
	set  patient.health;
	if (bmi_v1) lt 25 then iBMI_v1 = 100;
	else if (bmi_v1) lt 30 then iBMI_v1 = 70;
	else if (bmi_v1) lt 35 then iBMI_v1 = 30;
	else if (bmi_v1) lt 40 then iBMI_v1 = 15;
	else if (bmi_v1) ge 40 then iBMI_v1 = 0;
	else iBMI_v1 = .;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bmi.PNG" style="width: 383px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78123i275F84ECDFBBF7E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="bmi.PNG" alt="bmi.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 17:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848166#M335338</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2022-12-06T17:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then/Missing Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848167#M335339</link>
      <description>&lt;P&gt;Because that is what you told it to do.&amp;nbsp; Comparison operators, like &amp;lt; , treat missing values as less than any actual number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(bmi_v1) then iBMI_v1 = .;
else if (bmi_v1) lt 25 then iBMI_v1 = 100;
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2022 17:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848167#M335339</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-06T17:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then/Missing Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848237#M335353</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;if 0 lt (bmi_v1) lt 25 then iBMI_v1 = 100;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 00:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848237#M335353</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-07T00:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then/Missing Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848241#M335354</link>
      <description>&lt;P&gt;One way to fix this problem is to include an additional condition to check for missing values in the &lt;CODE&gt;if&lt;/CODE&gt; statement. In SAS, missing values are represented by a dot (&lt;CODE&gt;.&lt;/CODE&gt;), so you can add a condition to check if the value of &lt;CODE&gt;bmi_v1&lt;/CODE&gt; is equal to &lt;CODE&gt;.&lt;/CODE&gt; and assign the missing value to &lt;CODE&gt;iBMI_v1&lt;/CODE&gt; in that case.&lt;/P&gt;
&lt;P&gt;Here is an example of how you can modify your code to handle missing values:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data patient.guidelines;
	set  patient.health;
	if bmi_v1 = . then iBMI_v1 = .;
	else if (bmi_v1) lt 25 then iBMI_v1 = 100;
	else if (bmi_v1) lt 30 then iBMI_v1 = 70;
	else if (bmi_v1) lt 35 then iBMI_v1 = 30;
	else if (bmi_v1) lt 40 then iBMI_v1 = 15;
	else if (bmi_v1) ge 40 then iBMI_v1 = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In the code above, the first &lt;/SPAN&gt;&lt;CODE&gt;if&lt;/CODE&gt;&lt;SPAN&gt; statement checks if the value of &lt;/SPAN&gt;&lt;CODE&gt;bmi_v1&lt;/CODE&gt;&lt;SPAN&gt; is equal to &lt;/SPAN&gt;&lt;CODE&gt;.&lt;/CODE&gt;&lt;SPAN&gt; and assigns the missing value to &lt;/SPAN&gt;&lt;CODE&gt;iBMI_v1&lt;/CODE&gt;&lt;SPAN&gt; if that is the case. This ensures that any missing values in &lt;/SPAN&gt;&lt;CODE&gt;bmi_v1&lt;/CODE&gt;&lt;SPAN&gt; will be preserved in &lt;/SPAN&gt;&lt;CODE&gt;iBMI_v1&lt;/CODE&gt;&lt;SPAN&gt; and not assigned to one of the categories.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 00:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/848241#M335354</guid>
      <dc:creator>webart999ARM</dc:creator>
      <dc:date>2022-12-07T00:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then/Missing Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/947742#M370958</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; Thank you so much!&amp;nbsp; I have my next problem running through now accounting for the missing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;:&amp;nbsp; )&amp;nbsp; Heather&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 19:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-Then-Missing-Statements/m-p/947742#M370958</guid>
      <dc:creator>heatherml20</dc:creator>
      <dc:date>2024-10-16T19:15:14Z</dc:date>
    </item>
  </channel>
</rss>

