<?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: Generate all permutations list - 2 levels in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460763#M284714</link>
    <description>&lt;P&gt;Also can be done in PROC FACTEX&lt;/P&gt;</description>
    <pubDate>Tue, 08 May 2018 17:21:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-05-08T17:21:28Z</dc:date>
    <item>
      <title>Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460757#M284711</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone suggest an approach to list all permutations for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Categories&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;U&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and possible level is either (char) 1, 2, or 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where each outputted row would contain each category with its possible level such as a sample of full output would look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Possibility&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Permutations&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;R1-C1-U1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;R1-C1-U2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;R1-C2-U2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;R1-C2-U3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;R2-C2-U2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ETC.&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;…&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460757#M284711</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-05-08T17:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460759#M284712</link>
      <description>&lt;P&gt;If you have IML this becomes trivial, see the example here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2013/09/30/generate-combinations-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2013/09/30/generate-combinations-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have IML you can use CALL ALLCOMB or you do a SQL join.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $;
cards;
A
B
C
;
run;

proc sql;
create table want as
select catx("-", t1.name, t2.name, t3.name) as want
from have as t1
cross join have as t2
cross join have as t3;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 May 2018 17:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460759#M284712</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-08T17:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460761#M284713</link>
      <description>&lt;P&gt;Also trivial using Cartesian join in PROC SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data r;
    input r;
    cards;
1
2
;
run;

/* Repeat to create data sets C and U */

proc sql;
    create table want as select * from r,c,u;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 May 2018 17:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460761#M284713</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-08T17:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460763#M284714</link>
      <description>&lt;P&gt;Also can be done in PROC FACTEX&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460763#M284714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-08T17:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460771#M284715</link>
      <description>Thanks for the tip, hi, i could consider IML in Unix (aix) sas as it is running. I'll read this link to learn how to output it to a dataset &lt;A href="https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2011/04/18/writing-data-from-a-matrix-to-a-sas-data-set.html&lt;/A&gt;</description>
      <pubDate>Tue, 08 May 2018 17:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460771#M284715</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-05-08T17:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460811#M284716</link>
      <description>&lt;P&gt;thanks for ur tip to create 3 tables... In order to ultimately arrive to 1 column output table, had to add a few lines . (there is likely a more efficient way of doing it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data r;
    input r0;
    cards;
1
2
3
;
run;

/* Repeat to create data sets C and U */

data c;
    input c0;
    cards;
1
2
3
;
run;

data u;
    input u0;
    cards;
1
2
3
;
run;

proc sql;
    create table want as select * from r,c,u;
quit;

/*convert to char var */

data want2;
format r c u $1.;
set want;
r=left(put(r0,best.));
c=left(put(c0,best.));
u=left(put(u0,best.));
run;

/* use trim with char vars  to produce output as one column */

proc sql; create table wantFIN as 
select trim('R'||r||'C'||c||'U'||u) as NEWVAR
from want2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 May 2018 19:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460811#M284716</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-05-08T19:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460814#M284717</link>
      <description>&lt;P&gt;Much simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data r;
    input r $;
    cards;
R1
R2
R3
;
run;
 /* repeat for data sets C and U */
proc sql;
    select cats(r,c,u) from r,c,u;
    /* ALTERNATIVE: select catx('-',r,c,u) from r,c,u; */
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 19:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460814#M284717</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-08T19:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Generate all permutations list - 2 levels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460818#M284718</link>
      <description>&lt;P&gt;... learning everyday , thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 19:39:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-all-permutations-list-2-levels/m-p/460818#M284718</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-05-08T19:39:48Z</dc:date>
    </item>
  </channel>
</rss>

