<?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 creating combinatorial output in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67718#M19379</link>
    <description>I'm new to this forum. Sorry if I'm missusing it.&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset with five columns.&lt;BR /&gt;
The first column identifies objects A, the second identifies objects B related to each of the objects in the first column, the third gives the number (n) of a certain characteristic (X) each object in the second column has, the fourth the number (m) of objects related to each object in the first column, while the fifth column contains the characterstic X. &lt;BR /&gt;
&lt;BR /&gt;
235456    10456     3    2   PO&lt;BR /&gt;
235456    10456     3    2   UI&lt;BR /&gt;
235456    10456     3    2   UR&lt;BR /&gt;
235456    14283     3    2   PO&lt;BR /&gt;
235456    14283     3    2   AL&lt;BR /&gt;
235456    14283     3    2   KO&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
I would like to produce a table with all combinations of the characteristic X contained in the material. For each object A there are n to the power of m possible combinations if I'm not misstaken. From the example above&lt;BR /&gt;
PO-PO&lt;BR /&gt;
PO-AL&lt;BR /&gt;
PO-KO&lt;BR /&gt;
UI-PO&lt;BR /&gt;
UI-AL&lt;BR /&gt;
UI-KO&lt;BR /&gt;
UR-PO&lt;BR /&gt;
UR-AL&lt;BR /&gt;
UR-KO&lt;BR /&gt;
&lt;BR /&gt;
I would appreciate any suggestion how to solv this.&lt;BR /&gt;
&lt;BR /&gt;
Johan</description>
    <pubDate>Fri, 27 Aug 2010 14:50:38 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-08-27T14:50:38Z</dc:date>
    <item>
      <title>creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67718#M19379</link>
      <description>I'm new to this forum. Sorry if I'm missusing it.&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset with five columns.&lt;BR /&gt;
The first column identifies objects A, the second identifies objects B related to each of the objects in the first column, the third gives the number (n) of a certain characteristic (X) each object in the second column has, the fourth the number (m) of objects related to each object in the first column, while the fifth column contains the characterstic X. &lt;BR /&gt;
&lt;BR /&gt;
235456    10456     3    2   PO&lt;BR /&gt;
235456    10456     3    2   UI&lt;BR /&gt;
235456    10456     3    2   UR&lt;BR /&gt;
235456    14283     3    2   PO&lt;BR /&gt;
235456    14283     3    2   AL&lt;BR /&gt;
235456    14283     3    2   KO&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
I would like to produce a table with all combinations of the characteristic X contained in the material. For each object A there are n to the power of m possible combinations if I'm not misstaken. From the example above&lt;BR /&gt;
PO-PO&lt;BR /&gt;
PO-AL&lt;BR /&gt;
PO-KO&lt;BR /&gt;
UI-PO&lt;BR /&gt;
UI-AL&lt;BR /&gt;
UI-KO&lt;BR /&gt;
UR-PO&lt;BR /&gt;
UR-AL&lt;BR /&gt;
UR-KO&lt;BR /&gt;
&lt;BR /&gt;
I would appreciate any suggestion how to solv this.&lt;BR /&gt;
&lt;BR /&gt;
Johan</description>
      <pubDate>Fri, 27 Aug 2010 14:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67718#M19379</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-08-27T14:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67719#M19380</link>
      <description>I believe that you are not getting an answer because we do not understand the question - I don't in any case.  I don't believe that I understand all the constraints.  Are there necessarily only two groups (more than two values in the second column)?  Do you always match first to second?  The fourth column is always 2, but UI and UR are not related to PO in the first group. Can you expand your example to show what the fourth column means?</description>
      <pubDate>Sun, 29 Aug 2010 23:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67719#M19380</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-08-29T23:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67720#M19381</link>
      <description>Hi:&lt;BR /&gt;
  I agree with Art. I don't understand how your posted results correspond to what you said about wanting "to produce a table with &lt;B&gt;&lt;U&gt;all combinations&lt;/U&gt;&lt;/B&gt;&lt;U&gt;&lt;/U&gt; of the characteristic X contained in the material".&lt;BR /&gt;
&lt;BR /&gt;
  I'm confused about a few things:&lt;BR /&gt;
1) Right now, in the data, you only show the same value for object A (first col) -- does your data have more than one object A?? I would normally expect that your data was more than 6 rows or observations. What is the logical connection between your object A and your object B and characteristic X. For example, all the values of object A are the same, but you have 2 unique values for object B. Considering ONLY object A, you have 6 values for characteristic X -- but only 5 unique values.&lt;BR /&gt;
    &lt;BR /&gt;
2) You say you have to produce this table with all combinations of X (last column) for every unique value of A -- will you ever have to produce this set of combinations across the whole table or will it always be across unique values of A?? Where do the other columns come into play???&lt;BR /&gt;
 &lt;BR /&gt;
You have 6 values for the last column (characteristic X) for unique values of object A=235456 :&lt;BR /&gt;
[pre]&lt;BR /&gt;
PO&lt;BR /&gt;
UI&lt;BR /&gt;
UR&lt;BR /&gt;
PO&lt;BR /&gt;
AL&lt;BR /&gt;
KO&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
(of course PO is repeated twice...you'll have to decide how to deal with that) &lt;BR /&gt;
ALL the possible combinations would be something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
PO combined with all:&lt;BR /&gt;
  PO         PO&lt;BR /&gt;
  UI         PO&lt;BR /&gt;
  UR         PO&lt;BR /&gt;
  PO         PO&lt;BR /&gt;
  AL         PO&lt;BR /&gt;
  KO         PO&lt;BR /&gt;
      &lt;BR /&gt;
UI combined with all:&lt;BR /&gt;
  PO         UI&lt;BR /&gt;
  UI         UI&lt;BR /&gt;
  UR         UI&lt;BR /&gt;
  PO         UI&lt;BR /&gt;
  AL         UI&lt;BR /&gt;
  KO         UI&lt;BR /&gt;
                               &lt;BR /&gt;
UR Combined with all:&lt;BR /&gt;
  PO         UR&lt;BR /&gt;
  UI         UR&lt;BR /&gt;
  UR         UR&lt;BR /&gt;
  PO         UR&lt;BR /&gt;
  AL         UR&lt;BR /&gt;
  KO         UR&lt;BR /&gt;
                       &lt;BR /&gt;
The second value of PO combined with all:&lt;BR /&gt;
  PO         PO&lt;BR /&gt;
  UI         PO&lt;BR /&gt;
  UR         PO&lt;BR /&gt;
  PO         PO&lt;BR /&gt;
  AL         PO&lt;BR /&gt;
  KO         PO&lt;BR /&gt;
                                      &lt;BR /&gt;
AL combined with all:&lt;BR /&gt;
  PO         AL&lt;BR /&gt;
  UI         AL&lt;BR /&gt;
  UR         AL&lt;BR /&gt;
  PO         AL&lt;BR /&gt;
  AL         AL&lt;BR /&gt;
  KO         AL&lt;BR /&gt;
                      &lt;BR /&gt;
KO combined with all:&lt;BR /&gt;
  PO         KO&lt;BR /&gt;
  UI         KO&lt;BR /&gt;
  UR         KO&lt;BR /&gt;
  PO         KO&lt;BR /&gt;
  AL         KO&lt;BR /&gt;
  KO         KO&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                    &lt;BR /&gt;
Is there some other criteria for the combinations you envision?? Is KO-AL the same as AL-KO as a combination, for example??? What about the fact that PO occurs twice for object A -- should it only get considered 1 time???&lt;BR /&gt;
 &lt;BR /&gt;
If you only considered the unique combinations, then you might get combinations like this (PO only counted one time):&lt;BR /&gt;
[pre]&lt;BR /&gt;
PO combined with all:&lt;BR /&gt;
  PO         PO&lt;BR /&gt;
  UI         PO&lt;BR /&gt;
  UR         PO&lt;BR /&gt;
  AL         PO&lt;BR /&gt;
  KO         PO&lt;BR /&gt;
              &lt;BR /&gt;
UI combined with everything but PO:&lt;BR /&gt;
  UI         UI&lt;BR /&gt;
  UR         UI&lt;BR /&gt;
  AL         UI&lt;BR /&gt;
  KO         UI&lt;BR /&gt;
                &lt;BR /&gt;
UR combined with everything but PO and UI:&lt;BR /&gt;
  UR         UR&lt;BR /&gt;
  AL         UR&lt;BR /&gt;
  KO         UR&lt;BR /&gt;
                &lt;BR /&gt;
AL combined with everything but PO, UI and UR:&lt;BR /&gt;
  AL         AL&lt;BR /&gt;
  KO         AL&lt;BR /&gt;
                          &lt;BR /&gt;
KO combined with itself:&lt;BR /&gt;
     KO         KO&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Or is there some other combination that you envision??? The first combination example sounds like a Cartesian product to me. &lt;A href="http://support.sas.com/kb/25/270.html" target="_blank"&gt;http://support.sas.com/kb/25/270.html&lt;/A&gt; &lt;BR /&gt;
And, this paper has some other examples of SQL joins: &lt;A href="http://support.sas.com/resources/papers/proceedings09/062-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/062-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
The second combination sounds like a specialized join or a Cartesian product with some post-processing to remove duplicates. Right now, I don't understand where your second column (object B) or your third column (X) or your 4th column (M) come into play in the combinations you want.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 30 Aug 2010 00:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67720#M19381</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-08-30T00:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67721#M19382</link>
      <description>Thanks so much for input!&lt;BR /&gt;
And you´re right it wasn't clear when I now read it, sorry.&lt;BR /&gt;
&lt;BR /&gt;
My data has 11 million, or so, rows. There are more than one input A let's say around 1 million. For each A there are from 1 up to &lt;I&gt;m&lt;/I&gt; entries B, &lt;I&gt;m&lt;/I&gt; is specified in the fourth column. Each entry B has a number, &lt;I&gt;n&lt;/I&gt;:1-6 specified in the third column, of the characteristic (classification) X (the two letter combination in the fifth column).&lt;BR /&gt;
&lt;BR /&gt;
The &lt;B&gt;all combinations&lt;/B&gt; statement was wrong, I agree. What I want to do is to list the combinations of characteristics of the different B's belonging to each A. &lt;BR /&gt;
&lt;BR /&gt;
In the example I gave the entry A has two different B each with 3 classifications. Each classification of B1 can be combined with the 3 classifications of B2, a total of 9 classification-combinations.&lt;BR /&gt;
&lt;BR /&gt;
Still unclear? Let me know before spending time on proposing solutions and I'll try to rephrase.&lt;BR /&gt;
&lt;BR /&gt;
Again, many thanks for time spent!&lt;BR /&gt;
Johan</description>
      <pubDate>Mon, 30 Aug 2010 09:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67721#M19382</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-08-30T09:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67722#M19383</link>
      <description>It sounds like you are look for a cartesian join on a list of some values.  I put together a quick example using the SHOES table in SASHELP.  Is this the direction that you are look for?&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select *&lt;BR /&gt;
  from sashelp.shoes;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create table Region as&lt;BR /&gt;
    select distinct Region&lt;BR /&gt;
	from sashelp.shoes;&lt;BR /&gt;
&lt;BR /&gt;
  create table Product as&lt;BR /&gt;
    select distinct Product&lt;BR /&gt;
	from sashelp.shoes;&lt;BR /&gt;
&lt;BR /&gt;
   select region, product&lt;BR /&gt;
	from Region cross join Product;</description>
      <pubDate>Mon, 30 Aug 2010 11:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67722#M19383</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2010-08-30T11:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67723#M19384</link>
      <description>Thanks for reply!&lt;BR /&gt;
&lt;BR /&gt;
Using sashelp.shoes I think I might be able to state my question more clearly. I want to create a table with the possible combinations of two Subsidiaries for each combination of Region and Product. &lt;BR /&gt;
&lt;BR /&gt;
For Africa and Boot I want the result&lt;BR /&gt;
&lt;BR /&gt;
Addis Ababa Algiers&lt;BR /&gt;
Addis Ababa Cairo&lt;BR /&gt;
Addis Ababa Johannesburg&lt;BR /&gt;
Addis Ababa Khartoum&lt;BR /&gt;
&lt;BR /&gt;
etc.&lt;BR /&gt;
&lt;BR /&gt;
And then similar for Africa and Men's Casual and so on.&lt;BR /&gt;
&lt;BR /&gt;
Johan</description>
      <pubDate>Mon, 30 Aug 2010 12:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67723#M19384</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-08-30T12:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: creating combinatorial output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67724#M19385</link>
      <description>Hello JFroberg,&lt;BR /&gt;
&lt;BR /&gt;
Could you please execute the following code and let me know whether it fits your needs or not? Watch out: I did not check if all cases are taken into account but I think it could be a good starting point.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes_1;&lt;BR /&gt;
	by region product subsidiary;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data shoes_2;&lt;BR /&gt;
	set shoes_1;&lt;BR /&gt;
	by region product subsidiary;&lt;BR /&gt;
&lt;BR /&gt;
	id = _N_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	create table shoes_3 as&lt;BR /&gt;
		select distinct&lt;BR /&gt;
				t1.region, t1.product,&lt;BR /&gt;
				trim(left(t1.subsidiary)) || ' ' || trim(left(t2.subsidiary)) as Combinations&lt;BR /&gt;
		from    (select id, region, product, subsidiary from shoes_2) t1&lt;BR /&gt;
		,       (select id, region, product, subsidiary from shoes_2) t2&lt;BR /&gt;
		where   t1.region = t2.region&lt;BR /&gt;
		and		t1.product = t2.product&lt;BR /&gt;
		and 	t1.subsidiary &amp;gt;= t2.subsidiary&lt;BR /&gt;
		and     t1.id   &amp;gt; t2.id;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
I hope it helps.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Florent.</description>
      <pubDate>Tue, 31 Aug 2010 15:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/creating-combinatorial-output/m-p/67724#M19385</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2010-08-31T15:18:19Z</dc:date>
    </item>
  </channel>
</rss>

