<?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: Looping argument in Index function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730744#M227581</link>
    <description>&lt;P&gt;It's not really a fair question.&amp;nbsp; After all, this comparison will never be true:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if cmpnt='LDAT' %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Never ever.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you do more of the work.&amp;nbsp; Get code that is working except for the piece that you want fixed.&amp;nbsp; Otherwise, you're really just asking someone else to do your work for you by finding all the errors and fixing them.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Apr 2021 15:33:03 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-04-01T15:33:03Z</dc:date>
    <item>
      <title>Looping argument in Index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730736#M227576</link>
      <description>&lt;P&gt;In the below macro code value of macro variable 'entity_cd' resolves to 1234,5678 and so I've got the error '&lt;/P&gt;
&lt;P&gt;ERROR: Macro function %INDEX has too many arguments.'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to pass the aruguments as loop in&amp;nbsp;index function, so that in first Iteration it will check for the value 1234 and in next Iteration it will check for 5678. Any help to resolve this error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%if cmpnt='LDAT' and                    
    %index(&amp;amp;file_name.,&amp;amp;entity_cd.) &amp;gt; 0 %then
%do;
    %let cnt=%eval(&amp;amp;cnt. + 1);
%end;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Apr 2021 15:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730736#M227576</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-04-01T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Looping argument in Index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730744#M227581</link>
      <description>&lt;P&gt;It's not really a fair question.&amp;nbsp; After all, this comparison will never be true:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if cmpnt='LDAT' %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Never ever.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you do more of the work.&amp;nbsp; Get code that is working except for the piece that you want fixed.&amp;nbsp; Otherwise, you're really just asking someone else to do your work for you by finding all the errors and fixing them.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 15:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730744#M227581</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-04-01T15:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Looping argument in Index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730791#M227606</link>
      <description>You can ignore the first %if clause in my post. I would like to understand&lt;BR /&gt;how to loop the values as argument in %index function.&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Apr 2021 17:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730791#M227606</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-04-01T17:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Looping argument in Index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730803#M227612</link>
      <description>&lt;P&gt;&amp;nbsp;Try using the SCAN() function within a loop. Here's an example that should get you headed in the right direction:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let macro_var = 123,456,789;
%let dummy_file_name = abc_123_def_456;

data _null_;
    count = countw("&amp;amp;macro_var",',');
    do i = 1 to count;
        string = scan("&amp;amp;macro_var.",i);
        if index("&amp;amp;dummy_file_name", strip(string)) &amp;gt; 0
            then put "Code to execute, since " string " is in &amp;amp;dummy_file_name.";
        else put "Otherwise...";
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Apr 2021 18:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730803#M227612</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2021-04-01T18:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Looping argument in Index function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730805#M227614</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;You can ignore the first %if clause in my post. I would like to understand&lt;BR /&gt;how to loop the values as argument in %index function.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hint: write non-macro code first that does what you want in this situation. Once you have that working, you can keep the parts that don't change, and insert macro variables for the parts that do change.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 18:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-argument-in-Index-function/m-p/730805#M227614</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-01T18:35:06Z</dc:date>
    </item>
  </channel>
</rss>

