<?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 else in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486403#M126553</link>
    <description>&lt;P&gt;The IF clause tests a logical condition, which is not restricted to a simple condition like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if A1=11001101 then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It can be a compound condition constructed with AND's, OR's and parentheses, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (A1=11001101 or A1=1100010) then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also can have more than a single ELSE following an initial IF:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if a1=11001101 then AI2=.
else if a1=1100010 then AI2=.;
else AI2=A1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I should have added that this is a "flow-control" capability of every computer programming language that I have seen - not just SAS.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Aug 2018 16:18:44 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-08-13T16:18:44Z</dc:date>
    <item>
      <title>if then else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486399#M126550</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if anybody could help me with a problem I encountered with if, then, else statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sasdata.new;&lt;BR /&gt;set sasdata.auditvars3;&lt;BR /&gt;if A1=11001101 then AI2=.;&lt;BR /&gt;else AI2=A1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I do it if I needed A1=1001101 and A1=1100010 to both equal "." when put into the new A2 column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 16:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486399#M126550</guid>
      <dc:creator>Dylans15</dc:creator>
      <dc:date>2018-08-13T16:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: if then else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486403#M126553</link>
      <description>&lt;P&gt;The IF clause tests a logical condition, which is not restricted to a simple condition like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if A1=11001101 then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It can be a compound condition constructed with AND's, OR's and parentheses, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (A1=11001101 or A1=1100010) then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also can have more than a single ELSE following an initial IF:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if a1=11001101 then AI2=.
else if a1=1100010 then AI2=.;
else AI2=A1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I should have added that this is a "flow-control" capability of every computer programming language that I have seen - not just SAS.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 16:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486403#M126553</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-08-13T16:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: if then else</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486418#M126559</link>
      <description>&lt;P&gt;And if you have more values the IN operator is available to avoid writing a bunch of "OR" clauses;&lt;/P&gt;
&lt;P&gt;The IN operator tests a single variable against a list of explicit values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;A1 in (&lt;SPAN class="token number"&gt;11001101&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1100010&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;) then &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;is equivalent to&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; (A1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;11001101&lt;/SPAN&gt; or A1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1100010&lt;/SPAN&gt;) then &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If you later need to add a third or fourth or … item just place them inside the ()&amp;nbsp; with the existing values. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;There are also some short cuts for dealing with sequential &lt;STRONG&gt;integer&lt;/STRONG&gt; values:&amp;nbsp; var in (3:10 27.4) would test for all the integers from 3 through 10 and the value 27.4.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Character values must be inside quotes and lists do not work but this potentially saves a great many OR's in the code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 17:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-else/m-p/486418#M126559</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-13T17:22:14Z</dc:date>
    </item>
  </channel>
</rss>

