<?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 else if then condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533602#M146320</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;, thank you for your time and nice code.&amp;nbsp; I would like to thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt; ,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; for your constructive comments and hints.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Feb 2019 14:54:25 GMT</pubDate>
    <dc:creator>mmhxc5</dc:creator>
    <dc:date>2019-02-07T14:54:25Z</dc:date>
    <item>
      <title>If else if then condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533497#M146274</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am using the following code to define new variables left_time and Right_time based on the condition for other variables &lt;CODE class=" language-sas"&gt;STRUCTURE_NUMBER_008&lt;/CODE&gt; and count, but the code does not give me the new variables.&lt;/P&gt;&lt;P&gt;I would be glad if anyone could help me to get this fixed.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Ad_Year.Idaho_nbisteelic04;
set Ad_Year.idaho_nbisteelic03;
by STRUCTURE_NUMBER_008;
if  first.STRUCTURE_NUMBER_008  then left_Time=0 &amp;amp; Right_time=count;
if  last.STRUCTURE_NUMBER_008 then left_Time=count &amp;amp; Right_time=0;
else Left_time= count &amp;amp; Right_time=count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 04:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533497#M146274</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2019-02-07T04:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: If else if then condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533501#M146277</link>
      <description>&lt;P&gt;I think it should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Ad_Year.Idaho_nbisteelic04;
set Ad_Year.idaho_nbisteelic03;
by STRUCTURE_NUMBER_008;
if first.STRUCTURE_NUMBER_008 and last.STRUCTURE_NUMBER_008 then do;
    left_Time=0; /* ? */
    Right_time=0; /* ? */
    end;
else if first.STRUCTURE_NUMBER_008 then do;
    left_Time=0;
    Right_time=count;
    end;
else if last.STRUCTURE_NUMBER_008 then do;
    left_Time=count;
    Right_time=0;
    end;
else do;
    Left_time= count;
    Right_time=count;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 04:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533501#M146277</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-02-07T04:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: If else if then condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533516#M146285</link>
      <description>&lt;P&gt;&amp;amp; is a shortcut for "and", which is to be used only in a boolean expression, not for concatenating statements (as you may be used to from UNIX shell programming). Grouping statements into blocks is done with do/end in SAS (equivalent to the curly brackets in C, or begin/end in PASCAL).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 06:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533516#M146285</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-07T06:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: If else if then condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533536#M146291</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; stated, the &amp;amp; is used for logical AND not for concatenating statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;left_Time=0 &amp;amp; Right_time=count&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;gets interpreted as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;left_time=(0 and (right_time=Count))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which just assigns 0 (logically false) to left_time, and nothing to right_time.&lt;/P&gt;
&lt;P&gt;So, as logical true becomes 1 when used as a numeric you can get what you want with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Ad_Year.Idaho_nbisteelic04;
  set Ad_Year.idaho_nbisteelic03;
  by STRUCTURE_NUMBER_008;
  left_time=(not first.STRUCTURE_NUMBER_008)*Count;
  right_time=(not last.STRUCTURE_NUMBER_008)*Count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 08:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533536#M146291</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-02-07T08:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: If else if then condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533602#M146320</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;, thank you for your time and nice code.&amp;nbsp; I would like to thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt; ,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; for your constructive comments and hints.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 14:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-else-if-then-condition/m-p/533602#M146320</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2019-02-07T14:54:25Z</dc:date>
    </item>
  </channel>
</rss>

