<?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: RANPERM function in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46051#M277</link>
    <description>As explained in a previous thread, some Base SAS functions such as RANPERM expect a list of arguments instead of a vector of arguments. See the thread&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?threadID=7763&amp;amp;tstart=0" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?threadID=7763&amp;amp;tstart=0&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
If you know that you have three objects to permute, you can use RANPERM like this:&lt;BR /&gt;
proc iml;&lt;BR /&gt;
x1=1; x2=2; x3=3;&lt;BR /&gt;
seed=12;  /* or use 0 for random seed */&lt;BR /&gt;
call ranperm(seed,x1, x2, x3);&lt;BR /&gt;
print x1, x2, x3;&lt;BR /&gt;
&lt;BR /&gt;
However, there is an easy way to create a permutation of a vector of an arbitrary size: generate random uniform numbers and then compute the RANK of those numbers to use as an index vector. For example:&lt;BR /&gt;
&lt;BR /&gt;
x = {1,2,3};&lt;BR /&gt;
call randseed(12);&lt;BR /&gt;
u = j(nrow(x),1);              /* allocate vector */&lt;BR /&gt;
do i = 1 to 5;&lt;BR /&gt;
   call randgen(u, "uniform"); /* fill u with random uniform  */&lt;BR /&gt;
   perm = x[ rank(u) ];        /* use RANK(u) to permute data */&lt;BR /&gt;
   print i perm;&lt;BR /&gt;
end;</description>
    <pubDate>Fri, 09 Jul 2010 13:07:20 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2010-07-09T13:07:20Z</dc:date>
    <item>
      <title>RANPERM function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46050#M276</link>
      <description>I am unable to get the RANPERM function to work in IML. I have used it successfully in a DATA step using an array, but it does not seem to work in IML on a matrix, even though SAS documentation says it should. For example, the code below produces no errors or warnings in the Log, yet has no effect on the matrix.&lt;BR /&gt;
&lt;BR /&gt;
proc iml;&lt;BR /&gt;
x={1,2,3};&lt;BR /&gt;
seed=12;&lt;BR /&gt;
call ranperm(seed,x);&lt;BR /&gt;
print x;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Has anyone used this function successfully in IML?</description>
      <pubDate>Fri, 09 Jul 2010 02:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46050#M276</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-09T02:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: RANPERM function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46051#M277</link>
      <description>As explained in a previous thread, some Base SAS functions such as RANPERM expect a list of arguments instead of a vector of arguments. See the thread&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?threadID=7763&amp;amp;tstart=0" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?threadID=7763&amp;amp;tstart=0&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
If you know that you have three objects to permute, you can use RANPERM like this:&lt;BR /&gt;
proc iml;&lt;BR /&gt;
x1=1; x2=2; x3=3;&lt;BR /&gt;
seed=12;  /* or use 0 for random seed */&lt;BR /&gt;
call ranperm(seed,x1, x2, x3);&lt;BR /&gt;
print x1, x2, x3;&lt;BR /&gt;
&lt;BR /&gt;
However, there is an easy way to create a permutation of a vector of an arbitrary size: generate random uniform numbers and then compute the RANK of those numbers to use as an index vector. For example:&lt;BR /&gt;
&lt;BR /&gt;
x = {1,2,3};&lt;BR /&gt;
call randseed(12);&lt;BR /&gt;
u = j(nrow(x),1);              /* allocate vector */&lt;BR /&gt;
do i = 1 to 5;&lt;BR /&gt;
   call randgen(u, "uniform"); /* fill u with random uniform  */&lt;BR /&gt;
   perm = x[ rank(u) ];        /* use RANK(u) to permute data */&lt;BR /&gt;
   print i perm;&lt;BR /&gt;
end;</description>
      <pubDate>Fri, 09 Jul 2010 13:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46051#M277</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-07-09T13:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: RANPERM function</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46052#M278</link>
      <description>Thanks!</description>
      <pubDate>Mon, 12 Jul 2010 14:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/RANPERM-function/m-p/46052#M278</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-12T14:58:58Z</dc:date>
    </item>
  </channel>
</rss>

