<?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: Conditional running of array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133948#M27228</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will use macro language to run the array conditionally, as suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VD.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 May 2013 08:13:21 GMT</pubDate>
    <dc:creator>VD</dc:creator>
    <dc:date>2013-05-15T08:13:21Z</dc:date>
    <item>
      <title>Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133943#M27223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to run an array only if a condition is satisfied. The code I am using looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if index(upcase(Combination), 'OPT') ne&amp;nbsp; 0 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array Opt[&amp;amp;mMaxCount_opt] $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to &amp;amp;mMaxCount_opt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Opt&lt;I&gt;=i;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error as the code after the if loop seems to be running even when the condition is not satisfied (in which case the value of the macro variable &amp;amp;mMaxCount_opt is . ).&lt;/P&gt;&lt;P&gt;Any solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 11:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133943#M27223</guid>
      <dc:creator>VD</dc:creator>
      <dc:date>2013-05-13T11:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133944#M27224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your whole code and sample data ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 13:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133944#M27224</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-05-13T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133945#M27225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Along with others (such as drop, keep, rename, label, retain, length, format, informat, attrib, , by, where etc.), Array() statement is non-executable. Which means it is compile-time ONLY, which further means it can NOT be applied CONDITIONALLY. (With the exception of Macro language, but that is a different story and no contradictory to this rule). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Going back to your code, the array() statement will be effective regardless of your condition applied. In this case, you need to use Macro language to branch out SAS statements conditionally. And I suspect this would be the reason whey Ksharp needs your context to come up his Macro language code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 14:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133945#M27225</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-05-13T14:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133946#M27226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should include error messages with the question to provide more information.&lt;/P&gt;&lt;P&gt;I suspect that you are getting an error from the statement:&lt;BR /&gt;array Opt[&amp;amp;mMaxCount_opt] $;&lt;/P&gt;&lt;P&gt;probably about problem array declaration.&lt;/P&gt;&lt;P&gt;IF the array OPT was already assigned before the condition and the value of &amp;amp;mMaxCount_opt resolves to a numeric then you dont' need or want the array Opt[&amp;amp;mMaxCount_opt] $; statment.&lt;/P&gt;&lt;P&gt;If you want to process all element of the array OPT you don't even need the macro variable:&lt;/P&gt;&lt;P&gt;do i = 1 to dim(Opt); would work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 14:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133946#M27226</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-05-13T14:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133947#M27227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How did you create the macro variable mMaxCount_opt ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your data step is being generated by a macro then you can use macro logic such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-family: 'courier new', courier;"&gt;%if (&amp;amp;mMaxCount_opt &amp;gt; 0) %then %do;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;&amp;nbsp; array Opt[&lt;EM&gt;&amp;amp;mMaxCount_opt&lt;/EM&gt;] $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if index(upcase(Combination), 'OPT') then do&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; i = 1 to dim(Opt);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Opt&lt;I&gt;=i;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;EM style="font-family: 'courier new', courier;"&gt;%end;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 16:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133947#M27227</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-05-13T16:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional running of array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133948#M27228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will use macro language to run the array conditionally, as suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VD.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 May 2013 08:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-running-of-array/m-p/133948#M27228</guid>
      <dc:creator>VD</dc:creator>
      <dc:date>2013-05-15T08:13:21Z</dc:date>
    </item>
  </channel>
</rss>

