<?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 Loop a macro for each combination of two lists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193116#M36356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;I have a macro which i need run for each combination of 2 lists. For example&lt;SPAN class="apple-converted-space"&gt; &lt;/SPAN&gt;&lt;EM style="font-family: 'Arial','sans-serif';"&gt;list1 = old young&lt;/EM&gt; , &lt;EM style="font-family: 'Arial','sans-serif';"&gt;list2 = small medium large&lt;/EM&gt;. I want the macro to run for each combination of the 2 lists (i.e. a Cartesian product).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Is there a macro that someone has created which i can wrap around my inner macro, and loop it for each combination of the two lists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;I have seen macros like &lt;EM style="font-family: 'Arial','sans-serif';"&gt;%ITERLISTI&lt;/EM&gt;&lt;SPAN class="apple-converted-space"&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/SPAN&gt;which loop nicely for each value of a single list, but i need to extend it to two lists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Thanks&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Apr 2015 14:17:16 GMT</pubDate>
    <dc:creator>amsbam1</dc:creator>
    <dc:date>2015-04-10T14:17:16Z</dc:date>
    <item>
      <title>Loop a macro for each combination of two lists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193116#M36356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;I have a macro which i need run for each combination of 2 lists. For example&lt;SPAN class="apple-converted-space"&gt; &lt;/SPAN&gt;&lt;EM style="font-family: 'Arial','sans-serif';"&gt;list1 = old young&lt;/EM&gt; , &lt;EM style="font-family: 'Arial','sans-serif';"&gt;list2 = small medium large&lt;/EM&gt;. I want the macro to run for each combination of the 2 lists (i.e. a Cartesian product).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Is there a macro that someone has created which i can wrap around my inner macro, and loop it for each combination of the two lists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;I have seen macros like &lt;EM style="font-family: 'Arial','sans-serif';"&gt;%ITERLISTI&lt;/EM&gt;&lt;SPAN class="apple-converted-space"&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/SPAN&gt;which loop nicely for each value of a single list, but i need to extend it to two lists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Thanks&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 14:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193116#M36356</guid>
      <dc:creator>amsbam1</dc:creator>
      <dc:date>2015-04-10T14:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a macro for each combination of two lists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193117#M36357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would need to put more details about what you are trying to do.&amp;nbsp; You could for instance do:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i="old young","small medium large";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%your_macro (the_list='||strip(i)||');');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 14:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193117#M36357</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-10T14:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a macro for each combination of two lists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193118#M36358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The basic structure here assumes that default delimiters of the %SCAN function can be used:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro two_lists (list1=, list2=);&lt;/P&gt;&lt;P&gt; %local i j next_i next_j;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=1 %to %sysfunc(countw(&amp;amp;list1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let next_i = %scan(&amp;amp;list1, &amp;amp;i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do j=1 %to %sysfunc(countw(&amp;amp;list2));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let next_j = %scan(&amp;amp;list2, &amp;amp;j);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %*** DO something here like call a macro;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend two_lists;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 14:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193118#M36358</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-04-10T14:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loop a macro for each combination of two lists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193119#M36359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works perfectly, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 08:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-a-macro-for-each-combination-of-two-lists/m-p/193119#M36359</guid>
      <dc:creator>amsbam1</dc:creator>
      <dc:date>2015-04-13T08:55:50Z</dc:date>
    </item>
  </channel>
</rss>

