<?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: IF THEN CONDITION in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710616#M218784</link>
    <description>&lt;P&gt;Avoid unnecessary parentheses, and bring visual structure to your code, so you can see the functional blocks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if
  VAR2 = '1' and
  DAD_Has_Project_340_Information  = '1' and (
    substr(DAD_MRDx_Code,1,3) in ('I63','I64','H34') or
    DAD_Administration_of_Acute_Thro  = 'Yes'
  ) and
  DAD_Administration_of_Acute_Thro ne 'Yes, Prior' and
  DAD_Administration_of_Acute_Thro = 'Yes'
then NUME = 1;
else NUME = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(note how easy it now is to count the number of opening and closing brackets)&lt;/P&gt;
&lt;P&gt;And this can be simplified to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUME = (
  VAR2 = '1' and
  DAD_Has_Project_340_Information  = '1' and (
    substr(DAD_MRDx_Code,1,3) in ('I63','I64','H34') or
    DAD_Administration_of_Acute_Thro  = 'Yes'
  ) and
  DAD_Administration_of_Acute_Thro ne 'Yes, Prior' and
  DAD_Administration_of_Acute_Thro = 'Yes'
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since the result of a condition is either 1 (true) or 0 (false).&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2021 16:38:27 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-01-11T16:38:27Z</dc:date>
    <item>
      <title>IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710598#M218774</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;8  data All_dad_nacrs_test;
1189  set dad_nacrs ;
1190
1191  if VAR2 = ('1') and (DAD_Has_Project_340_Information  = '1' ) and
1192  ((substr(DAD_MRDx_Code,1,3) IN: ('I63' 'I64' 'H34')) or
1192! DAD_Administration_of_Acute_Thro  in ('Yes'))
1193  and (DAD_Administration_of_Acute_Thro not in ('Yes, Prior') )
1194  then deno =1 ;
1195  else deno = 0;
1196
1197  if VAR2 = ('1')and (DAD_Has_Project_340_Information  = '1' )
1198  and  ((substr(DAD_MRDx_Code,1,3) IN: ('I63' 'I64' 'H34') or
1198! DAD_Administration_of_Acute_Thro  in ('Yes'))
1199  and  (DAD_Administration_of_Acute_Thro not in ('Yes, Prior') and
1199! (DAD_Administration_of_Acute_Thro  in ('Yes') ))
1200  then NUME =1 ;
      ----         -
      22           79
      202
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, -, /,
              &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL,
              NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.

ERROR 79-322: Expecting a ).

ERROR 202-322: The option or parameter is not recognized and will be ignored.

1201
1202  else nume = 0;
      ----
      160
ERROR 160-185: No matching IF-THEN clause.

1203
1204  run;

NOTE: The SAS System stopped processing this step because of errors.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would appreciate advice on correcting the error above&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also if I am to write multiple if steps instead of 1 big if condition will i still be able to assign a value of deno=1 for all conditions that are satisfied&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710598#M218774</guid>
      <dc:creator>Ranjeeta</dc:creator>
      <dc:date>2021-01-11T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710601#M218776</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Line 1198, the first parenthesis isn't closed.</description>
      <pubDate>Mon, 11 Jan 2021 16:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710601#M218776</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2021-01-11T16:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710609#M218778</link>
      <description>&lt;P&gt;In this bit of code you have ( before Dad_Administration_of_Acute_Thro&lt;/P&gt;
&lt;P&gt;that are not needed.&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;
1199  and  (DAD_Administration_of_Acute_Thro not in ('Yes, Prior') and
1199! (DAD_Administration_of_Acute_Thro  in ('Yes') ))
1200  then NUME =1 ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp; Look at the parallel coding you used in lines 1191 - 1195&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure I clearly understand this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Also if I am to write multiple if steps instead of 1 big if condition will i still be able to assign a value of deno=1 for all conditions that are satisfied&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;However if you need to assign multiple variables based on a long condition then you should look at :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;If &amp;lt;some very long conditional code&amp;gt; then do;
   var1=value;
   var2=value2;
   var3=value3;
end;
else do;
   var1=othervalue;
   var2=othervalue2;
   var3=othervalue3;
end;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710609#M218778</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-11T16:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710616#M218784</link>
      <description>&lt;P&gt;Avoid unnecessary parentheses, and bring visual structure to your code, so you can see the functional blocks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if
  VAR2 = '1' and
  DAD_Has_Project_340_Information  = '1' and (
    substr(DAD_MRDx_Code,1,3) in ('I63','I64','H34') or
    DAD_Administration_of_Acute_Thro  = 'Yes'
  ) and
  DAD_Administration_of_Acute_Thro ne 'Yes, Prior' and
  DAD_Administration_of_Acute_Thro = 'Yes'
then NUME = 1;
else NUME = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(note how easy it now is to count the number of opening and closing brackets)&lt;/P&gt;
&lt;P&gt;And this can be simplified to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUME = (
  VAR2 = '1' and
  DAD_Has_Project_340_Information  = '1' and (
    substr(DAD_MRDx_Code,1,3) in ('I63','I64','H34') or
    DAD_Administration_of_Acute_Thro  = 'Yes'
  ) and
  DAD_Administration_of_Acute_Thro ne 'Yes, Prior' and
  DAD_Administration_of_Acute_Thro = 'Yes'
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since the result of a condition is either 1 (true) or 0 (false).&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710616#M218784</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-11T16:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710621#M218787</link>
      <description>&lt;P&gt;I just discovered this site that you might find helpful :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.balancebraces.com/" target="_blank"&gt;http://www.balancebraces.com/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-01-11 17_38_01-Results Page_ Balance Braces, Parentheses, Brackets, and Tags in Your Code.png" style="width: 465px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53387i777C010FF08229F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-01-11 17_38_01-Results Page_ Balance Braces, Parentheses, Brackets, and Tags in Your Code.png" alt="2021-01-11 17_38_01-Results Page_ Balance Braces, Parentheses, Brackets, and Tags in Your Code.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710621#M218787</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2021-01-11T16:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710623#M218788</link>
      <description>&lt;P&gt;Clearly, any form of simplification will help in understanding this code.&amp;nbsp; Here's one place.&amp;nbsp; This code is overly complex:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(DAD_MRDx_Code,1,3) IN: ('I63' 'I64' 'H34')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It should become:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DAD_MRDx_Code IN: ('I63' 'I64' 'H34')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's the whole purpose of using the IN: operator instead of IN.&amp;nbsp; It automatically makes the comparison based on the smaller number of characters.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 16:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710623#M218788</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-01-11T16:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710650#M218811</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;P&gt;(...)&lt;/P&gt;
&lt;P&gt;And this can be simplified to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUME = (
  VAR2 = '1' and
  DAD_Has_Project_340_Information  = '1' and (
    substr(DAD_MRDx_Code,1,3) in ('I63','I64','H34') or
    DAD_Administration_of_Acute_Thro  = 'Yes'
  ) and
  DAD_Administration_of_Acute_Thro ne 'Yes, Prior' and
  DAD_Administration_of_Acute_Thro = 'Yes'
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;... which could be further simplified to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NUME = VAR2 = DAD_Has_Project_340_Information = '1' and
       DAD_Administration_of_Acute_Thro = 'Yes';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2021 18:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710650#M218811</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-01-11T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710695#M218830</link>
      <description>&lt;P&gt;Oh yes.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 22:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710695#M218830</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-11T22:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN CONDITION</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710784#M218864</link>
      <description>Cool. Hope sas could accept this function .</description>
      <pubDate>Tue, 12 Jan 2021 11:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-CONDITION/m-p/710784#M218864</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-12T11:52:33Z</dc:date>
    </item>
  </channel>
</rss>

