<?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 My if do loop is not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315387#M68777</link>
    <description>&lt;P&gt;I added if condition but it seems not applied.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if state= 3 then
           do i = 1 to 4; 
              if a[2*i-1] NE 0 then
                 do; 
                     b[4*i-3] = c[i] - a[(2*i-1)]; 
                     b[4*i-2] = b[4*i-3] / a[(2*i-1)]; 
                 end;
              if a[2*i] NE 0 then 
                 do; 
                    b[4*i-1] = c[i] - a[2*i]; 
                    b[4*i] = b[4*i-1] / a[2*i];
                 end;
           end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2016 01:50:54 GMT</pubDate>
    <dc:creator>sas_newbie3</dc:creator>
    <dc:date>2016-11-30T01:50:54Z</dc:date>
    <item>
      <title>My if do loop is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315387#M68777</link>
      <description>&lt;P&gt;I added if condition but it seems not applied.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if state= 3 then
           do i = 1 to 4; 
              if a[2*i-1] NE 0 then
                 do; 
                     b[4*i-3] = c[i] - a[(2*i-1)]; 
                     b[4*i-2] = b[4*i-3] / a[(2*i-1)]; 
                 end;
              if a[2*i] NE 0 then 
                 do; 
                    b[4*i-1] = c[i] - a[2*i]; 
                    b[4*i] = b[4*i-1] / a[2*i];
                 end;
           end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Why?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 01:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315387#M68777</guid>
      <dc:creator>sas_newbie3</dc:creator>
      <dc:date>2016-11-30T01:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: My if do loop is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315389#M68778</link>
      <description>&lt;P&gt;How do you know it's "not applied"? Show the unexpected results.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 02:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315389#M68778</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-30T02:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: My if do loop is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315400#M68784</link>
      <description>&lt;P&gt;What is the ERROR/WARNING message?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 03:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315400#M68784</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-30T03:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: My if do loop is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315447#M68811</link>
      <description>&lt;P&gt;What is this code in? &amp;nbsp;It seems to me to be invalid SAS code. &amp;nbsp;The if syntax is:&lt;/P&gt;
&lt;P&gt;if &amp;lt;logic&amp;gt; then &amp;lt;result&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or for multiple statements:&lt;/P&gt;
&lt;P&gt;if &amp;lt;logic&amp;gt; then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;results&amp;gt;;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in your code it should start:&lt;/P&gt;
&lt;P&gt;if state=3 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; do i=1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a tip for your questions:&lt;/P&gt;
&lt;P&gt;- Post test data, in the form of a datastep in the post.&lt;/P&gt;
&lt;P&gt;- Show what the output should look lke&lt;/P&gt;
&lt;P&gt;- Explain any logic&lt;/P&gt;
&lt;P&gt;A question, what are all those arrays for, are you sure they are all within bounds? &amp;nbsp;I would guess that there are simpler methods to do this, but without information can't provide.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 09:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/My-if-do-loop-is-not-working/m-p/315447#M68811</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-30T09:34:37Z</dc:date>
    </item>
  </channel>
</rss>

