<?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: Iterating sas do to loop for specific variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/350004#M81310</link>
    <description>&lt;P&gt;It would be less messy if you could change the format of the incoming list. &amp;nbsp;Are you able to get the equivalent of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let list = 1 2 5 # 2 4 6;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The choice of delimiter isn't important, but removing the brackets and commas is helpful.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2017 10:45:15 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-04-14T10:45:15Z</dc:date>
    <item>
      <title>Iterating sas do to loop for specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/349968#M81305</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so below is the structure of my program (pesudo code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;list =&amp;nbsp;&lt;/P&gt;&lt;P&gt;[1,2,5],&lt;/P&gt;&lt;P&gt;[2,4,6];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro someMacro (list)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do list=1 to list=&amp;lt;lastIndex&amp;gt;&lt;/P&gt;&lt;P&gt;when list = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;access 1,2,5 in loop&lt;/P&gt;&lt;P&gt;when list = 2&lt;/P&gt;&lt;P&gt;access 2,4,6 in loop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend someMacro()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;someMacro(list)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;how do I impliment a sas macro with passing a list or array as a parameter to the macro?&lt;BR /&gt;&lt;BR /&gt;My problem is similar to this topic.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/26/155.html" target="_blank"&gt;http://support.sas.com/kb/26/155.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Only difference is that I need to pass more than 1 variable in one iteration.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 07:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/349968#M81305</guid>
      <dc:creator>captainprice0</dc:creator>
      <dc:date>2017-04-14T07:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating sas do to loop for specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/350004#M81310</link>
      <description>&lt;P&gt;It would be less messy if you could change the format of the incoming list. &amp;nbsp;Are you able to get the equivalent of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let list = 1 2 5 # 2 4 6;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The choice of delimiter isn't important, but removing the brackets and commas is helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 10:45:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/350004#M81310</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-14T10:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating sas do to loop for specific variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/350025#M81319</link>
      <description>&lt;P&gt;Don't use comma as the delimiter. In that sense the advice from SAS in that posting should be first to use spaces or some other character besides comma as your delmiter. This will eliminate the need for a lot of macro quoting that makes the code hard to read and also end up confusing the SAS parser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To generate your type of multi-dimensional list just need to use more than one type of delimiter. Typically I would use space first and add | as the next delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro someMacro (list);
%local i sentence j word;
%do i = 1 %to %sysfunc(countw(&amp;amp;list,|));
  %let sentence = %scan(&amp;amp;list,&amp;amp;i,|);
  %do j = 1 %to %sysfunc(countw(&amp;amp;sentence));
    %let word = %scan(&amp;amp;sentence,&amp;amp;j);
    %put (&amp;amp;i,&amp;amp;j) = &amp;amp;word;
  %end;
%end;
%mend someMacro;

%someMacro(1 2 3|4 5 6);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Apr 2017 12:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterating-sas-do-to-loop-for-specific-variables/m-p/350025#M81319</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-14T12:46:59Z</dc:date>
    </item>
  </channel>
</rss>

