<?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: Multiple conditions within an IF statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754804#M29981</link>
    <description>Hi, sorry for the confusion.&lt;BR /&gt;-Basically if any of the four variables even has one value less than 200 lowcd4 should = 1.&lt;BR /&gt;-If all values are missing or all values are 200 or above (or some combination of this) than lowcd4 = 0.&lt;BR /&gt;&lt;BR /&gt;Please let me know if that makes more sense!</description>
    <pubDate>Sat, 17 Jul 2021 23:46:13 GMT</pubDate>
    <dc:creator>pramenon1</dc:creator>
    <dc:date>2021-07-17T23:46:13Z</dc:date>
    <item>
      <title>Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754767#M29975</link>
      <description>&lt;P&gt;I am trying to do something along the lines of if Varibles A, B, C, or D contain values less then 200 then Y (new variable) = 1, if none of them contain values or if all their values are above 200 then Y = 0.&amp;nbsp; What I have right now is :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data dtanl.hivcancerdta;&lt;BR /&gt;set dtanl.hivcancerdta;&lt;BR /&gt;IF cd4_cnt1 &amp;lt; . THEN lowcd4 = 0;&lt;BR /&gt;IF cd4_cnt2 &amp;lt; . THEN lowcd4 = 0;&lt;BR /&gt;IF cd4 cnt3 &amp;lt; . THEN lowcd4 = 0;&lt;BR /&gt;IF cd4_cnt4 &amp;lt; . THEN lowcd4 = 0;&lt;BR /&gt;IF cd4_cnt1 &amp;lt; 200 THEN lowcd4 = 1;&lt;BR /&gt;IF cd4_cnt2 &amp;lt; 200 THEN lowcd4 = 1;&lt;BR /&gt;IF cd4 cnt3 &amp;lt; 200 THEN lowcd4 = 1;&lt;BR /&gt;IF cd4_cnt4 &amp;lt; 200 THEN lowcd4 = 1;&lt;BR /&gt;ELSE lowcd4 = 0;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its ugly and isn't working. Is there a better way to do this. I tried looking online and some options use do statements but I dont have much experience with it. Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 16:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754767#M29975</guid>
      <dc:creator>pramenon1</dc:creator>
      <dc:date>2021-07-17T16:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754772#M29976</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dtanl.hivcancerdta1;
    set dtanl.hivcancerdta;
    if whichn(.,of cd4_cnt:)&amp;gt;0 then lowcd4=0;
    else if cd4_cnt1&amp;lt;200 or cd4_cnt2&amp;lt;200 or cd4_cnt3&amp;lt;200 or cd4_cnt4&amp;lt;200 then lowcd4=1;
    else lowcd4=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You requirements don't seem to be complete. What happens if one of the variables is missing and one of the variables is &amp;lt;200 and one of the variables is &amp;gt;=200?&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 16:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754772#M29976</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-17T16:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754777#M29977</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/387108"&gt;@pramenon1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your real condition for LOWCD4=1 is that &lt;EM&gt;any&lt;/EM&gt; of the four CD4_CNT variables has a nonmissing value &amp;lt;200 (and&amp;nbsp;LOWCD4=0 otherwise) I would use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;lowcd4=(min(of cd4_cnt1-cd4_cnt4,200)&amp;lt;200);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Jul 2021 16:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754777#M29977</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-17T16:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754780#M29978</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&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/387108"&gt;@pramenon1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your real condition for LOWCD4=1 is that &lt;EM&gt;any&lt;/EM&gt; of the four CD4_CNT variables has a nonmissing value &amp;lt;200 (and&amp;nbsp;LOWCD4=0 otherwise) I would use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;lowcd4=(min(of cd4_cnt1-cd4_cnt4,200)&amp;lt;200);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A much better solution than mine!&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 16:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754780#M29978</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-17T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754797#M29979</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF cd4_cnt1 &amp;lt; . THEN lowcd4 = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since MISSING is considered the lowest value by definition, this condition can NEVER be true.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 18:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754797#M29979</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-17T18:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754799#M29980</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF cd4_cnt1 &amp;lt; . THEN lowcd4 = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since MISSING is considered the lowest value by definition, this condition can NEVER be true.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;Almost&lt;/EM&gt; never, to be more precise, as&amp;nbsp;&lt;FONT face="courier new,courier"&gt;.&lt;/FONT&gt; is only the &lt;EM&gt;second lowest&lt;/EM&gt; numeric value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
cd4_cnt1=._;
if cd4_cnt1 &amp;lt; . then lowcd4 = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jul 2021 18:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754799#M29980</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-17T18:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754804#M29981</link>
      <description>Hi, sorry for the confusion.&lt;BR /&gt;-Basically if any of the four variables even has one value less than 200 lowcd4 should = 1.&lt;BR /&gt;-If all values are missing or all values are 200 or above (or some combination of this) than lowcd4 = 0.&lt;BR /&gt;&lt;BR /&gt;Please let me know if that makes more sense!</description>
      <pubDate>Sat, 17 Jul 2021 23:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754804#M29981</guid>
      <dc:creator>pramenon1</dc:creator>
      <dc:date>2021-07-17T23:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions within an IF statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754808#M29982</link>
      <description>&lt;P&gt;So find the minimum value.&amp;nbsp; Then test if it is less that 200.&amp;nbsp; You can test if the value is between &lt;A href="https://stackoverflow.com/questions/32414264/what-does-z-mean-in-sas/32414479#32414479" target="_self"&gt;.Z&lt;/A&gt;&amp;nbsp; and 200 to exclude missing values (which are less than any actual number).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then just assign the reulst of the test to your new variable since SAS evaluates boolean expression as 1 or 0. No need for IF/THEN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;lowcd4 = .Z &amp;lt; min(of cd4_cnt1-cd4_cnt4) &amp;lt; 200;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jul 2021 01:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-conditions-within-an-IF-statement/m-p/754808#M29982</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-18T01:19:17Z</dc:date>
    </item>
  </channel>
</rss>

