<?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: Combinatorial counting in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213764#M2222</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot. This obviously works. Particularly, Ian's code is really simple and elegant and it does exactly its job (up to the row order but that doesn't really matter - only the unique list of permutations is needed and that's what the codes gives). It helps speed up the computational burden.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jul 2015 11:33:56 GMT</pubDate>
    <dc:creator>mra</dc:creator>
    <dc:date>2015-07-13T11:33:56Z</dc:date>
    <item>
      <title>Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213752#M2210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Colleagues&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for insightful discussion on my question. I am back very late but I haven been following the discussion with interest, and alongside also trying to work on my SAS question further. I think, it goes fine now. Particularly, one can compare the rannor() function with randnormal() and I feel the later one is easier to use and manipulate, even for several non-normal cases.&lt;/P&gt;&lt;P&gt;Since, Rick had already stated about his book which I have now and I find it very helpful. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, I also have another short question here, and I hope you can help me figure it out much quicker. I usually write my programs in SAS/IML, but this time I started with R and the program works fine, although R's speed for that program is painfully slow. I am writing the same thing in SAS/IML for which I need to compute all possible distinct combinations of size, say k, out of, say n, elements. Simply, I want a SAS function that does exactly what permutations() function does in R's gtools package. I have gone through LEXPERK(), ALLPERM() etc. It seems LEXPERK() is the closest option but it needs the variable list as well which I have but I want to use the list later, First, I only need to make all permutations, say permutations(10, 4) in R's function. Any idea? The other functions do not fit very well into my query - I suppose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks and all the best&lt;/P&gt;&lt;P&gt;MRA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 10:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213752#M2210</guid>
      <dc:creator>mra</dc:creator>
      <dc:date>2015-06-25T10:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213753#M2211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick&lt;/P&gt;&lt;P&gt;you are right, I have opened a new thread here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have gone through the combinatorial functions and also your old posts on this subject. It seems, only LEXPERK can do what I need, but the 'variables' option in its arguments is a problem. As, I shall use the output matrix of these, say (n, k) = (10, 4), permutations in a loop for different n's and possibly k's, it is better if I can generate it without variables option, or somehow manipulate this option to get what I need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any case, I am trying it in different ways to figure it out&amp;nbsp; - if possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 10:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213753#M2211</guid>
      <dc:creator>mra</dc:creator>
      <dc:date>2015-06-25T10:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213754#M2212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check GRAYCODE() of data step. of course it could be used in IML too .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 12:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213754#M2212</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-25T12:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213755#M2213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cross-linking to the other thread: &lt;A _jive_internal="true" href="https://communities.sas.com/message/281211#281211"&gt;https://communities.sas.com/message/281211#281211&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 13:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213755#M2213</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-06-25T13:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213756#M2214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think Graycode() is not the solution. In fact, I feel that SAS does not offer a simple solution to this very simple problem of basic probability theory. There are many functions for combinations/permutations, but only the random ones work directly (they generate repeated combinations/permutations which I don't need; e.g. ranperm() ). It is only LEXPERK() that can solve my problem but a seemingly unnecessary argument of 'variables list' in there is an issue. The one-line R function permutations() works wonderful and the code is also running perfectly well but it is just the amount of time it takes. So, following my usual simulation policy, I have to do it in IML but then the LEXPERK() thing. I had already read Rick's older posts before I posted this message but Rick's codes don't address the all possible unique permutations question either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/RA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 16:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213756#M2214</guid>
      <dc:creator>mra</dc:creator>
      <dc:date>2015-07-02T16:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213757#M2215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mra,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if this will help or not, but I have had to tackle this sort of problem in SAS (not in SAS/IML).&amp;nbsp; This would be a piece of a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array vars {10} var1-var10;&lt;/P&gt;&lt;P&gt;do a=1 to 7;&lt;/P&gt;&lt;P&gt;do b=a+1 to 8;&lt;/P&gt;&lt;P&gt;do c=b+1 to 9;&lt;/P&gt;&lt;P&gt;do d=c+1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; *** Code that refers to array elements a, b, c, and d;&lt;/P&gt;&lt;P&gt;end; end;&amp;nbsp; end; end;&lt;/P&gt;&lt;P&gt;You would get each combination of 4 exactly once, in the innermost loop.&amp;nbsp; Perhaps this line of thought would help in SAS/IML ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 18:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213757#M2215</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-07-02T18:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213758#M2216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am a little confused . How could you generate permutation if you miss&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; the 'variables'&amp;nbsp; arguments in &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;LEXPERK () .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Can you make an example to illustrate it ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 13:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213758#M2216</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-07-03T13:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213759#M2217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not saying that I can or I did in LEXPERK() w.o. variables list. In R function permutations(), one can do it and I just need the same result as R function gives. It seems LEXPERK gives this same result but needs variable list. I tried this list as 1:n (n specified, say 10) but did not work. Following the syntax of LEXPERK(), something like lexperk(m, k, 1:n) or lexperk(m, k, x1, x2, . . ., xn) should work with if I want to generate m distinct permutations for n items taken k at a time; e.g. m = 5040 if n = 10, k = 4. In R, I only need to give n and k, but in SAS also the variables. In my case, I shall use the functions lexperk() repeatedly in a loop for many different n's, so I am trying to somehow 'manipulate' the variables option in a way that I only get the distinct permutations list, i.e. nP4, as R function gives. I hope it is relatively clear now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 14:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213759#M2217</guid>
      <dc:creator>mra</dc:creator>
      <dc:date>2015-07-03T14:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213760#M2218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not familiar with R function . Do you mean take 1 2 3 4 ...... as 'variables' argument in LEXPERK() ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #353535; font-family: Lato, sans-serif; font-size: 14px;"&gt;&lt;/P&gt;&lt;H3&gt;Code: Program&lt;/H3&gt;&lt;PRE class="sce-render" style="font-family: 'Courier New', Menlo, 'Lucida Console'; font-size: 16px;"&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;array&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;x&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;[&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;10&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;1&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;10&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;n&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;dim&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;x&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;k&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;3&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt;nperm&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;perm&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;n&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;k&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;do&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;j&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;1&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;to&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;nperm&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;1&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;rc&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;lexperk&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;j&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;k&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;of&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;x&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;[&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;*&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;put&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;j&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;5.&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;3&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;x1&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;-&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt;x3&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;3&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;rc&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;if&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;rc&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class="numeric" style="color: #008080; font-weight: bold;"&gt;0&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;then&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;leave&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;end&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #353535; font-family: Lato, sans-serif; font-size: 14px;"&gt;&lt;/P&gt;&lt;HR /&gt;&lt;H3&gt;Log: Program&lt;/H3&gt;&lt;P&gt;Notes (1)&lt;/P&gt;&lt;DIV class="sasSource" style="color: #000000;"&gt; 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;P&gt;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 53&amp;nbsp; &lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 54 data _null_;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 55 array x[10] (1:10);&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 56 n=dim(x);&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 57 k=3;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 58 nperm=perm(n,k);&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 59 do j=1 to nperm+1;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 60 rc=lexperk(j, k, of x&lt;LI&gt;);&lt;/LI&gt;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 61 put j 5. +3 x1-x3 +3 rc=;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 62 if rc&amp;lt;0 then leave;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 63 end;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt; 64 run;&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 1 1 2 3 rc=1&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 2 1 2 4 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 3 1 2 5 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 4 1 2 6 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 5 1 2 7 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 6 1 2 8 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 7 1 2 9 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 8 1 2 10 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 9 1 3 2 rc=2&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 10 1 3 4 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 11 1 3 5 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 12 1 3 6 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 13 1 3 7 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 14 1 3 8 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 15 1 3 9 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 16 1 3 10 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 17 1 4 2 rc=2&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 18 1 4 3 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 19 1 4 5 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 20 1 4 6 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 21 1 4 7 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 22 1 4 8 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 23 1 4 9 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 24 1 4 10 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 25 1 5 2 rc=2&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 26 1 5 3 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 27 1 5 4 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 28 1 5 6 rc=3&lt;/P&gt;&lt;P class="sasSource" style="color: #000000;"&gt;&amp;nbsp; 29 1 5 7 rc=3&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 15:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213760#M2218</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-07-03T15:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213761#M2219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The SAS/IML language enables you to &lt;A href="http://blogs.sas.com/content/iml/2011/10/24/video-calling-sas-procedures-from-the-sasiml-language.html"&gt;call other SAS procedures and the DATA step&lt;/A&gt;.&amp;nbsp; Since the LEXPERK function does what you need, the simplest solution is to call a DATA step from within your SAS/IML program.&amp;nbsp; For convenience, you can &lt;A href="http://blogs.sas.com/content/iml/2014/06/23/creating-ods-graphics-from-the-sasiml-language.html"&gt;hide the call by encapsulating it within a module.&lt;/A&gt; The following module has the same name as the R function that you refer to. It returns the same data, although not necessarily in the same order. The call to permutations(10,4) takes 0.03 seconds on my PC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc iml;&lt;BR /&gt;/* enumerate permutations of k elements from n items,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; including order. By default, the function returns &lt;BR /&gt;&amp;nbsp;&amp;nbsp; a matrix with PERM(n, k) rows. Each row is a way to &lt;BR /&gt;&amp;nbsp;&amp;nbsp; enumerate k integers from the set {1,2,...,n} */&amp;nbsp;&amp;nbsp; &lt;BR /&gt;start permutations(n, k, v=1:n);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; submit n k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _perk;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keep x1-x&amp;amp;k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array x[&amp;amp;n] x1-x&amp;amp;n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n = &amp;amp;n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; k = &amp;amp;k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 to n;&amp;nbsp; x&lt;J&gt; = j;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nperm=perm(n, k);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j=1 to nperm;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call lexperk(j, k, of x&lt;LI&gt;);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; endsubmit;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; use _perk;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; read all var _num_ into x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; close _perk;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call delete("_perk");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if IsSkipped(v) then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return( x );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; y = shape( v[,x], 0, 2 );&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return( y );&lt;BR /&gt;finish;&lt;/LI&gt;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Test 1: Return pairs of letters from {a,b,c,d} */&lt;BR /&gt;v = "a":"d";&lt;BR /&gt;g = permutations(4, 2, v);&lt;BR /&gt;print g;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Test 2: Time how long it takes to return 4-tuples from 1:10 */&lt;BR /&gt;t0 = time();&lt;BR /&gt;p = permutations(10, 4);&lt;BR /&gt;elapsed = time()-t0;&lt;BR /&gt;print (dimension(p))[c={"nrow" "ncol"}];&lt;BR /&gt;print elapsed;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 19:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213761#M2219</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-06T19:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213762#M2220</link>
      <description>&lt;P&gt;I think you can work entirely within IML, since it is essentially a 'multiplication' of the matrix from the ALLCOMB(n, k) function, with the matrix from the ALLPERM(k) function.&amp;nbsp; Again row order is likely to be different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start permutations(n, k);
  c = allcomb(n, k);
  p = allperm( k );
  nc = nrow( c );
  np = nrow( p );
  a = do(0, nc # k - 1, k)` @ j(np, k) + repeat(p, nc);
  return ( shape( c[a], nc # np, k) );
finish;

print (permutations( 4, 3) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Edited January 2017 - at some point part of the&amp;nbsp;return statement&amp;nbsp;became&amp;nbsp;a link and&amp;nbsp;the code was no longer&amp;nbsp;rendered correctly -&amp;nbsp;converted to&amp;nbsp;a&amp;nbsp;SAS code box to fix the problem]&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 15:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213762#M2220</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2017-01-18T15:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213763#M2221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Really awesome, Ian!&amp;nbsp; I tried tp combine ALLCOMB and ALLPERM, but after 30 minutes I still hadn't come up with the right formula.&amp;nbsp; I'm glad you got it to work. Your way is more efficient than mine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 13:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213763#M2221</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-07T13:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combinatorial counting</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213764#M2222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot. This obviously works. Particularly, Ian's code is really simple and elegant and it does exactly its job (up to the row order but that doesn't really matter - only the unique list of permutations is needed and that's what the codes gives). It helps speed up the computational burden.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 11:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Combinatorial-counting/m-p/213764#M2222</guid>
      <dc:creator>mra</dc:creator>
      <dc:date>2015-07-13T11:33:56Z</dc:date>
    </item>
  </channel>
</rss>

