<?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: Trying to create list of all possible combination of variables of length of 5 characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881010#M348129</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279134"&gt;@J_Yetman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks - I should've clarified, for this business case, they treat 'AAAAB' and 'BAAAA' as a different combination.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Repeat correction: "different permuation". By definition it is the same combination in mathematical and generally programming terminology.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I spent one semester dealing with pretty&amp;nbsp; much ways to count combinations and permutations of values and had that difference driven in pretty hard.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 20:25:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-06-15T20:25:16Z</dc:date>
    <item>
      <title>Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880936#M348093</link>
      <description>&lt;P&gt;There's a business need to create a list of all possible 5-character length combinations of 24 capital letters and 8 numbers (leaving out I, O, 1 and 0).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some basic code to create the list, using an array.&amp;nbsp; However, when outputting to the table, I'm only seeing the output of the first character of the string:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X&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; count&lt;/P&gt;&lt;P&gt;AAAAA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;AAAAB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;AAAAC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;99997&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;33554430&lt;/P&gt;&lt;P&gt;99998&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;33554431&lt;/P&gt;&lt;P&gt;99999&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;33554432&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I'm getting is&amp;nbsp;&lt;/P&gt;&lt;P&gt;X&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; count&lt;/P&gt;&lt;P&gt;A&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;1&lt;/P&gt;&lt;P&gt;A&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;2&lt;/P&gt;&lt;P&gt;A&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;3&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;9&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; 33554430&lt;/P&gt;&lt;P&gt;9&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; 33554431&lt;/P&gt;&lt;P&gt;9&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; 33554432&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;length x $5.;&lt;BR /&gt;ct=0;&lt;BR /&gt;Array a{32} $32 ('A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z',&lt;BR /&gt;'2','3','4','5','6','7','8','9');&lt;BR /&gt;do c1=1 to 32;&lt;BR /&gt;do c2=1 to 32;&lt;BR /&gt;do c3=1 to 32;&lt;BR /&gt;do c4=1 to 32;&lt;BR /&gt;do c5=1 to 32;&lt;BR /&gt;x=cat(a[c1],a[c2],a[c3],a[c4],a[c5]);&lt;BR /&gt;ct=ct+1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;drop a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 c1 c2 c3 c4 c5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880936#M348093</guid>
      <dc:creator>J_Yetman</dc:creator>
      <dc:date>2023-06-15T15:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880950#M348100</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279134"&gt;@J_Yetman&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Inserting the "s" in&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;x=cat&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;/FONT&gt;(a[c1], ...)&lt;/FONT&gt; will solve the issue. (The code could also be simplified, but the time to do that might easily exceed the run time of only a few seconds.)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880950#M348100</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-06-15T15:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880968#M348114</link>
      <description>&lt;P&gt;Your code does PERMUTATIONS, where order matters not combinations. In Combinations AAAAB and BAAAA are the same combination of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also fix your code by using this array definition:&lt;/P&gt;
&lt;PRE&gt;Array a{32}&lt;FONT size="5"&gt;&lt;STRONG&gt; $1&lt;/STRONG&gt;&lt;/FONT&gt; ('A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z',
'2','3','4','5','6','7','8','9');&lt;/PRE&gt;
&lt;P&gt;Your definition created 32 variables each of length 32. Which meant that the CAT function was using lots of trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880968#M348114</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-15T15:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880988#M348120</link>
      <description>Thanks - I should've clarified, for this business case, they treat 'AAAAB' and 'BAAAA' as a different combination.&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Jun 2023 18:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/880988#M348120</guid>
      <dc:creator>J_Yetman</dc:creator>
      <dc:date>2023-06-15T18:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881010#M348129</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279134"&gt;@J_Yetman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks - I should've clarified, for this business case, they treat 'AAAAB' and 'BAAAA' as a different combination.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Repeat correction: "different permuation". By definition it is the same combination in mathematical and generally programming terminology.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I spent one semester dealing with pretty&amp;nbsp; much ways to count combinations and permutations of values and had that difference driven in pretty hard.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 20:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881010#M348129</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-15T20:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881036#M348141</link>
      <description>&lt;P&gt;Looks like you got the right number.&amp;nbsp; But you did a lot of extra work to find it.&lt;/P&gt;
&lt;PRE&gt;621  data _null_;
622    np = 32**5 ;
623    put np= comma32.;
624  run;

np=33,554,432
&lt;/PRE&gt;
&lt;P&gt;Are you making license plates?&lt;/P&gt;
&lt;PRE&gt;734  data plates;
735    letters='ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
736    length plate $5 ;
737    do ct=0 to length(letters)**5-1 ;
738      temp=ct;
739      do pos=5 to 1 by -1 ;
740        substr(plate,pos,1) = char(letters,1+mod(temp,32));
741        temp=int(temp/32);
742      end;
743      output;
744    end;
745    drop temp letters pos;
746  run;

NOTE: The data set WORK.PLATES has 33554432 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           4.80 seconds
      cpu time            4.64 seconds


747
748  data _null_;
749    set plates nobs=nobs ;
750    if _n_ in (1:5) or _n_ &amp;gt; nobs-5 ;
751    put plate ct :comma32.;
752  run;

AAAAA 0
AAAAB 1
AAAAC 2
AAAAD 3
AAAAE 4
99995 33,554,427
99996 33,554,428
99997 33,554,429
99998 33,554,430
99999 33,554,431
NOTE: There were 33554432 observations read from the data set WORK.PLATES.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 02:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881036#M348141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-16T02:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to create list of all possible combination of variables of length of 5 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881097#M348160</link>
      <description>&lt;P&gt;Thanks - that's way more elegant!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 14:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-create-list-of-all-possible-combination-of-variables/m-p/881097#M348160</guid>
      <dc:creator>J_Yetman</dc:creator>
      <dc:date>2023-06-16T14:21:52Z</dc:date>
    </item>
  </channel>
</rss>

