<?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: Choose 6 numbers from 10-all combinations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969411#M376845</link>
    <description>&lt;P&gt;To finish the Rick's IML code with creating a WANT table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numbers=2,4,16,21,22,24,27,31,32,34;
proc iml;
x = {&amp;amp;numbers};
idx = allcomb(nrow(x), 6);
comb = shape(x[idx,], nrow(idx));
/* then print or save to data set */
create want from comb[c=('x1':'x6')];
append from comb;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Jun 2025 00:51:06 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-06-20T00:51:06Z</dc:date>
    <item>
      <title>Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969289#M376812</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Lets say I have 10 numbers and I want to choose 6 of them .&lt;/P&gt;
&lt;P&gt;There are 210 possible combinations&amp;nbsp; of choose 6 numbers from 10.(select a subset of 6 elements from a set of 10).&lt;/P&gt;
&lt;P&gt;I want to get the all 210 combinations&lt;/P&gt;
&lt;P&gt;So in want&amp;nbsp; data set will have columns:&amp;nbsp;&lt;CODE class=" language-sas"&gt;serial X1 X2 X3 X4 X5 X6&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;what is the way to do it please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numbers=2,4,16,21,22,24,27,31,32,34;

Data want;
input serial X1 X2 X3 X4 X5 X6;
cards;
1 4 16 21 22 24
2 16 21 22 24 27
and so on

;
Run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 10:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969289#M376812</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-18T10:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969293#M376813</link>
      <description>&lt;P&gt;You can use the COMB and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0rag3bzl2l7dsn16xc6bwufqg5a.htm" target="_self"&gt;ALLCOMB&lt;/A&gt; functions to do this. I have modified your code below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   array x[10] (2,4,16,21,22,24,27,31,32,34);
   n=dim(x);
   k=6;
   ncomb=comb(n, k);
   do j=1 to ncomb+1;
      rc=allcomb(j, k, of x[*]);
      put j 5. +3 x1-x6 +3 rc=;
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Jun 2025 11:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969293#M376813</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-06-18T11:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969299#M376819</link>
      <description>&lt;P&gt;Maxim 9: There Is a Function For It. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 12:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969299#M376819</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-06-18T12:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969345#M376834</link>
      <description>&lt;P&gt;Yes. The most convenient way is using ALLCOMB() function.&lt;/P&gt;
&lt;P&gt;But if you would like to perform it on your own. Here you go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numbers=2,4,16,21,22,24,27,31,32,34;

Data want;
array x{10} _temporary_ (&amp;amp;numbers);
do a1=1 to 10;
do a2=a1+1 to 10;
do a3=a2+1 to 10;
do a4=a3+1 to 10;
do a5=a4+1 to 10;
do a6=a5+1 to 10;
 serial+1;
 x1=x{a1};
 x2=x{a2};
 x3=x{a3};
 x4=x{a4};
 x5=x{a5};
 x6=x{a6};
 output;
end;
end;
end;
end;
end;
end;
drop a:;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jun 2025 01:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969345#M376834</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-06-19T01:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969346#M376835</link>
      <description>&lt;P&gt;And Here is a SQL solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data x;
infile cards dlm=',';
input x @@;
cards;
2,4,16,21,22,24,27,31,32,34
;
run;
ods select none;
ods output sql_results=want;
proc sql number;
select 
x1.x as x1,
x2.x as x2,
x3.x as x3,
x4.x as x4,
x5.x as x5,
x6.x as x6
 from 
x as x1, 
x as x2, 
x as x3, 
x as x4, 
x as x5, 
x as x6
 where
x1.x&amp;lt;x2.x and
x2.x&amp;lt;x3.x and
x3.x&amp;lt;x4.x and
x4.x&amp;lt;x5.x and
x5.x&amp;lt;x6.x 
;
quit;
ods select all;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jun 2025 02:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969346#M376835</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-06-19T02:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969398#M376842</link>
      <description>&lt;P&gt;Since others have given you a DATA step and PROC SQL solution, here is the PROC IML solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numbers=2,4,16,21,22,24,27,31,32,34;
proc iml;
x = {&amp;amp;numbers};
idx = allcomb(nrow(x), 6);
comb = shape(x[idx,], nrow(idx));
/* then print or save to data set */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jun 2025 15:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969398#M376842</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-06-19T15:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Choose 6 numbers from 10-all combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969411#M376845</link>
      <description>&lt;P&gt;To finish the Rick's IML code with creating a WANT table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let numbers=2,4,16,21,22,24,27,31,32,34;
proc iml;
x = {&amp;amp;numbers};
idx = allcomb(nrow(x), 6);
comb = shape(x[idx,], nrow(idx));
/* then print or save to data set */
create want from comb[c=('x1':'x6')];
append from comb;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jun 2025 00:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-6-numbers-from-10-all-combinations/m-p/969411#M376845</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-06-20T00:51:06Z</dc:date>
    </item>
  </channel>
</rss>

