<?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 statement with multiple condition s in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565760#M158894</link>
    <description>&lt;P&gt;PLEASE use the "little running man" for posting code; it is specifically implemented for this, and the code then looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if test1='F' then
  lob='Fire';
else if test1='G' then
  lob='others';
else if test1='C' then
  lob='PA';
else if test1='P' then
  lob='PA';
else if test1='Q' then
  lob='PA';
else if test1='R' then
  lob='PA';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with consistent typeface and -size, and indentation kept, and coloring like the enhanced editor does.&lt;/P&gt;
&lt;P&gt;(assuming you had some visual formatting in the first place, see Maxim 12)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Every time you have such a if/then/else if chain, think of using the data step &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p09213s9jc2t99n1vx0omk2rh9ps.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;select&lt;/A&gt; statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select (test1);
  when ('F') lob='Fire';
  when ('G') lob='others';
  when ('C','P','Q','R') lob='PA';
  otherwise;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see how simple and clean the code looks now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2019 07:11:52 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-06-13T07:11:52Z</dc:date>
    <item>
      <title>if statement with multiple condition s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565732#M158883</link>
      <description>&lt;P&gt;Hi, can I have an if statement with multiple condition ? my code is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'F'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Fire'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'G'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'others'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'P'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Q'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'R'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times" size="3"&gt;For the last four if statement the output is actually the same, can I combine them together instead of list down them one by one like above?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times" size="3"&gt;I tried to run the code like this but it does not work. Is it anything wrong?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'F'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'Fire'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'G'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'others'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'C',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'P',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'Q',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'R'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 02:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565732#M158883</guid>
      <dc:creator>Kayla_Tan222</dc:creator>
      <dc:date>2019-06-13T02:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: if statement with multiple condition s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565733#M158884</link>
      <description>&lt;P&gt;You can use IN or OR here. IN is much more useful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if test1='C' or test1 = 'P' or test1 = 'Q' or test1 = 'R'
  then lob='PA';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;IN&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if test1 in ('C', 'P', 'Q', 'R') then lob='PA';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274500"&gt;@Kayla_Tan222&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, can I have an if statement with multiple condition ? my code is below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'F'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Fire'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'G'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'others'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'C'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'P'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Q'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'R'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times" size="3"&gt;For the last four if statement the output is actually the same, can I combine them together instead of list down them one by one like above?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times" size="3"&gt;I tried to run the code like this but it does not work. Is it anything wrong?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'F'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'Fire'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'G'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'others'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'C',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'P',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'Q',&lt;FONT face="Courier New" size="3"&gt;test1=&lt;/FONT&gt;'R'&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;lob=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'PA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 03:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565733#M158884</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T03:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: if statement with multiple condition s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565760#M158894</link>
      <description>&lt;P&gt;PLEASE use the "little running man" for posting code; it is specifically implemented for this, and the code then looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if test1='F' then
  lob='Fire';
else if test1='G' then
  lob='others';
else if test1='C' then
  lob='PA';
else if test1='P' then
  lob='PA';
else if test1='Q' then
  lob='PA';
else if test1='R' then
  lob='PA';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with consistent typeface and -size, and indentation kept, and coloring like the enhanced editor does.&lt;/P&gt;
&lt;P&gt;(assuming you had some visual formatting in the first place, see Maxim 12)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Every time you have such a if/then/else if chain, think of using the data step &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p09213s9jc2t99n1vx0omk2rh9ps.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;select&lt;/A&gt; statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select (test1);
  when ('F') lob='Fire';
  when ('G') lob='others';
  when ('C','P','Q','R') lob='PA';
  otherwise;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see how simple and clean the code looks now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 07:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-statement-with-multiple-condition-s/m-p/565760#M158894</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-13T07:11:52Z</dc:date>
    </item>
  </channel>
</rss>

