<?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: Get the combinations with do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340999#M272738</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112588"&gt;@sas_newbie3&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want the result can be an arrary format, so I can retrieve the first element and second item etc.&lt;/P&gt;
&lt;P&gt;So for example, for AA, it is an array. The first item of the array is A, the second item of array is A also.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then go back to your orginal post and change the "example" data to what you actually want. Your example implied one record per two character concatenated string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And your description would result in 32 values not 16:&lt;/P&gt;
&lt;P&gt;A,A,A,B,A,C,A,D,B,A,B,B,B,C,B,D,C,A,C,B,C,C,C,D,D,A,D,B,D,C,D,D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   array x {32} $1.;
   counter=0;
   do i= 'A','B','C','D';
      do j= 'A','B','C','D';
         counter+1;
         x[counter]=i ;
         counter+1;
         x[counter]=j ;
      end;
   end;
   output;
   drop counter i j;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Mar 2017 23:32:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-14T23:32:13Z</dc:date>
    <item>
      <title>Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340955#M272733</link>
      <description>&lt;P&gt;Say we have 4 letters--"A", "B","C","D". Now I want to get the combinations, the result should be 16 ELEMENTS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AA
AB
AC
AD
BA
BB
BC
BD
CA
CB
CC
CD
DA
DB
DC
DD&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 20:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340955#M272733</guid>
      <dc:creator>sas_newbie3</dc:creator>
      <dc:date>2017-03-14T20:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340957#M272734</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do i = 'A', 'B', 'C', 'D';
do j = 'A', 'B', 'C', 'D';
var = cats(i, j);
output;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 20:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340957#M272734</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-14T20:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340978#M272735</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want the result can be an arrary format, so I can retrieve the first element and second item etc.&lt;/P&gt;&lt;P&gt;So for example, for AA, it is an array. The first item of the array is A, the second item of array is A also.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 22:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340978#M272735</guid>
      <dc:creator>sas_newbie3</dc:creator>
      <dc:date>2017-03-14T22:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340988#M272736</link>
      <description>&lt;P&gt;I'm really sorry, but I don't understand. The code I provided gives you the results you specified. The i and j give you the two separate portions, if that's what you mean.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 22:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340988#M272736</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-14T22:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340994#M272737</link>
      <description>&lt;P&gt;Not sure what you're asking for. Is it something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want (keep=first: second:);
  array first(16) $;
  array second(16) $;
  do i = 'A', 'B', 'C', 'D';
    do j = 'A', 'B', 'C', 'D';
      cell+1;
      first(cell)=i;
      second(cell)=j ;
    end;
  end;
run;  &lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 23:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340994#M272737</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-14T23:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get the combinations with do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340999#M272738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112588"&gt;@sas_newbie3&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want the result can be an arrary format, so I can retrieve the first element and second item etc.&lt;/P&gt;
&lt;P&gt;So for example, for AA, it is an array. The first item of the array is A, the second item of array is A also.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then go back to your orginal post and change the "example" data to what you actually want. Your example implied one record per two character concatenated string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And your description would result in 32 values not 16:&lt;/P&gt;
&lt;P&gt;A,A,A,B,A,C,A,D,B,A,B,B,B,C,B,D,C,A,C,B,C,C,C,D,D,A,D,B,D,C,D,D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data junk;
   array x {32} $1.;
   counter=0;
   do i= 'A','B','C','D';
      do j= 'A','B','C','D';
         counter+1;
         x[counter]=i ;
         counter+1;
         x[counter]=j ;
      end;
   end;
   output;
   drop counter i j;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 23:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-combinations-with-do-loop/m-p/340999#M272738</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-14T23:32:13Z</dc:date>
    </item>
  </channel>
</rss>

