<?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 create a table with all possible permutations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265153#M52097</link>
    <description>&lt;P&gt;Thanks for the correction, the order does not matter therefore it is a combination. This solution worked great.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Apr 2016 16:49:19 GMT</pubDate>
    <dc:creator>Hadrien</dc:creator>
    <dc:date>2016-04-20T16:49:19Z</dc:date>
    <item>
      <title>How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265116#M52083</link>
      <description>&lt;P&gt;Hi, I am new to SAS and can't figure out how to create a table with all possible permutations from multiple vectors (I actually don't know how to create the vectors either). Could someone point me in the right direction on how to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of what I am trying to do and how it would be done in R using the expand.grid() function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#Create vectors
states &amp;lt;- c("MA", "NY")
seasons &amp;lt;- c("Fall", "Winter", "Spring", "Summer")
activities &amp;lt;- c("TV", "Board Games")

#Create data frame with all permutations
permutations &amp;lt;- expand.grid(states, seasons, activities)&lt;/PRE&gt;&lt;P&gt;The resulting "permutations" table would be:&lt;/P&gt;&lt;PRE&gt;   Var1   Var2        Var3
1    MA   Fall          TV
2    NY   Fall          TV
3    MA Winter          TV
4    NY Winter          TV
5    MA Spring          TV
6    NY Spring          TV
7    MA Summer          TV
8    NY Summer          TV
9    MA   Fall Board Games
10   NY   Fall Board Games
11   MA Winter Board Games
12   NY Winter Board Games
13   MA Spring Board Games
14   NY Spring Board Games
15   MA Summer Board Games
16   NY Summer Board Games&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265116#M52083</guid>
      <dc:creator>Hadrien</dc:creator>
      <dc:date>2016-04-20T14:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265122#M52086</link>
      <description>&lt;P&gt;One way&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   array s {2} $ 2   _temporary_ ('MA','NY');
   array t {4} $ 8   _temporary_ ('Spring','Summer','Fall','Winter');
   array a {2} $ 15  _temporary_ ('TV','Board Games');
   Do i=1 to dim(s);
      State=s[i];
      do j= 1 to dim(t);
         Season = t[j];
         do k = 1 to dim(a);
            Activity= a[k];
            output;
         end;
      end;
   end;
   keep state season activity;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The critical parts of the arrays: the number of elements in the braces should match the number of items in parentheses, the length - number after the $- should be as large as the length of the longest element entered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 15:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265122#M52086</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-20T15:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265137#M52089</link>
      <description>&lt;P&gt;Those are combinations. One easy way to get all combinations is the cartesian product operation in SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data states;
do state = "MA", "NY"; output; end; run;
data seasons;
length season $8;
do season = "Fall", "Winter", "Spring", "Summer"; output; end; run;
data activities;
length activity $12;
do activity = "TV", "Board Games"; output; end; run;

proc sql;
select * from states, seasons, activities;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Apr 2016 15:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265137#M52089</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-04-20T15:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265153#M52097</link>
      <description>&lt;P&gt;Thanks for the correction, the order does not matter therefore it is a combination. This solution worked great.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 16:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265153#M52097</guid>
      <dc:creator>Hadrien</dc:creator>
      <dc:date>2016-04-20T16:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265294#M52155</link>
      <description>&lt;P&gt;There is a similiar function in IML .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
states={"MA", "NY"};
seasons={"Fall", "Winter", "Spring", "Summer"};
activities={"TV", "Board Games"};
want=expandgrid(states,seasons,activities);

print want;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 02:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265294#M52155</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-21T02:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265405#M52192</link>
      <description>&lt;P&gt;This is a very elegant solution, thank you! Unfortunately I got the following error message, perhaps it has to do with my version of SAS:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: The SAS/IML product with which IML (2) is associated is either not licensed for your system or the product license has 
       expired. Please contact your SAS installation representative.
ERROR: Bad product ID for procedure IML.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2016 14:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265405#M52192</guid>
      <dc:creator>Hadrien</dc:creator>
      <dc:date>2016-04-21T14:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265440#M52198</link>
      <description>permutations can be done with proc plan&lt;BR /&gt;check your OnLine doc for this topic:&lt;BR /&gt;&lt;BR /&gt;permutation, generating with PLAN procedure</description>
      <pubDate>Thu, 21 Apr 2016 14:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265440#M52198</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2016-04-21T14:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a table with all possible permutations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265566#M52250</link>
      <description>Yeah. Maybe your site don't have IML product.
But you can run it under SAS University Edition. It is totally free.</description>
      <pubDate>Fri, 22 Apr 2016 01:02:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-table-with-all-possible-permutations/m-p/265566#M52250</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-22T01:02:07Z</dc:date>
    </item>
  </channel>
</rss>

