<?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: how to rearrange data in a specific order in SAS/IML? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629106#M5026</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x=expandgrid(0:1,0:1,0:1);
s=x[,+]||x;
call sortndx(idx,s,1:4,2:4);
want=x[idx,];
print x,want;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Mar 2020 12:43:22 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-03-03T12:43:22Z</dc:date>
    <item>
      <title>how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629090#M5023</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been given a code to generate a matrix of 0's and 1's&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;iml&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
start AllZeroOneComb&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; return &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   cmd &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"m = expandgrid("&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   do i &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
      cmd &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; cmd &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"0:1, "&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   cmd &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; cmd &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"0:1);"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token comment"&gt;*print cmd;&lt;/SPAN&gt;
   CALL &lt;SPAN class="token keyword"&gt;EXECUTE&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cmd&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   return &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
finish&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

do &lt;SPAN class="token function"&gt;n&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   m &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; AllZeroOneComb&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; m&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this program output the following:&lt;/P&gt;
&lt;P&gt;in the case of n=3,&lt;/P&gt;
&lt;P&gt;0 0 0&lt;/P&gt;
&lt;P&gt;1 0 0&lt;/P&gt;
&lt;P&gt;0 1 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 1 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 0 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 0 1&lt;/P&gt;
&lt;P&gt;0 1 1&lt;/P&gt;
&lt;P&gt;1 1 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like my data to appear in the following order instead;&lt;/P&gt;
&lt;P&gt;0 0 0&lt;/P&gt;
&lt;P&gt;1 0 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 1 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 0 1&lt;/P&gt;
&lt;P&gt;1 1 0&lt;/P&gt;
&lt;P&gt;1 0 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 1 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 1 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know how to implement that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;DJ&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 11:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629090#M5023</guid>
      <dc:creator>DJ20</dc:creator>
      <dc:date>2020-03-03T11:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629094#M5024</link>
      <description>&lt;P&gt;I'd like to take a step back ... why is all of this being done in PROC IML? Each of your examples that you have been working on in the last week or so could be much easier done without using PROC IML, which is (in a manner of speaking) an entirely different language. Everything you have done in PROC IML, you are working very hard at, and there are much simpler ways of doing these things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you are working on a factorial experiment, what difference does it make what order these things are in?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 11:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629094#M5024</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-03T11:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629095#M5025</link>
      <description>&lt;P&gt;For n=3, it looks like you want to swap the 3rd and 4th rows. Anticipating that you next question might be "how do I do it for n=4 and n=5, let me direct you to a resource for &lt;A href="https://blogs.sas.com/content/iml/2011/03/16/sorting-a-matrix-by-row-or-column-statistics.html" target="_self"&gt;reordering the rows of a matrix according to any measure that you want to use&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, create a vector of ranks, then use row subscripts to permute the rows according to the given ranks:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
m = {
0 0 0,
1 0 0,
0 1 0,
1 1 0,
0 0 1,
1 0 1,
0 1 1,
1 1 1 
};

rank = {1 2 3 5 4 6 7 8};
z = m[rank,];     /* rearrange the rows */
print z;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Create a similar vector of ranks for n=4 and n=5.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 11:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629095#M5025</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-03-03T11:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629106#M5026</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x=expandgrid(0:1,0:1,0:1);
s=x[,+]||x;
call sortndx(idx,s,1:4,2:4);
want=x[idx,];
print x,want;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Mar 2020 12:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629106#M5026</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-03T12:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629822#M5027</link>
      <description>&lt;P&gt;I have been given the task of finding the ANOVA table for a factorial design with 2 levels for each factor. I know that using PROC IML for this purpose is not convenient at all however it is not my choice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been given a number of data sets with different number of factors in each data set the least is two and maximum is 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can easily do the calculations for the data with one block only, however when the number of blocks exceeds 1 it gets quite complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now with the help I got in the community from such nice and helpful people like you I am almost done with program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My main issue now is to construct the ANOVA table!! because I have used yates's method to do the calculations I had to put my main factors and interactions between the factors in a specific order:&lt;/P&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;P&gt;A&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;AB&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;AC&lt;/P&gt;
&lt;P&gt;BC&lt;/P&gt;
&lt;P&gt;ABC&lt;/P&gt;
&lt;P&gt;and so on. For the ANOVA table I need them to be in the following order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A&lt;/P&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;AB&lt;/P&gt;
&lt;P&gt;AC&lt;/P&gt;
&lt;P&gt;BC&lt;/P&gt;
&lt;P&gt;ABC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thats why I asked whether there is a possibility to change the order using the same code.&amp;nbsp; it seems impossible to do that usiing the same code Do you have any other suggestions?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;DJ&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 14:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629822#M5027</guid>
      <dc:creator>DJ20</dc:creator>
      <dc:date>2020-03-05T14:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629828#M5028</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for you reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does work however I wanted to attach other columns to the matrix of o's and 1's and I want to sort them depending on the changes applied to the matrix of 0's and 1's!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;DJ&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 14:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629828#M5028</guid>
      <dc:creator>DJ20</dc:creator>
      <dc:date>2020-03-05T14:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to rearrange data in a specific order in SAS/IML?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629839#M5029</link>
      <description>&lt;P&gt;Great! I feel confident that you can solve the related problem by using the many tips, techniques, and resources that we've offered. Give it a go. If you still have questions after you have made several programming attempts, you can post the program that doesn't completely work and people will suggest ways to revise/improve it.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 15:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-rearrange-data-in-a-specific-order-in-SAS-IML/m-p/629839#M5029</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-03-05T15:30:11Z</dc:date>
    </item>
  </channel>
</rss>

