<?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: Create all possible combination of one variable by group of another variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199868#M49933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks Xia, very helpful&lt;/P&gt;&lt;P&gt;thanks all&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2015 06:22:25 GMT</pubDate>
    <dc:creator>mich</dc:creator>
    <dc:date>2015-04-21T06:22:25Z</dc:date>
    <item>
      <title>Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199863#M49928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two columns, the first is the group, the second is the name of an entity withing that group.&lt;/P&gt;&lt;P&gt;Group&amp;nbsp;&amp;nbsp; Entity&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod3&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod4&lt;/P&gt;&lt;P&gt;B...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to transform it to a dataset with 3 columns, the first is the group and the second and the third contains all possible combinations of Entities(2 by 2) within that group&lt;/P&gt;&lt;P&gt;Group&amp;nbsp;&amp;nbsp; Entity1&amp;nbsp;&amp;nbsp; Entity2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod3&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod3&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod4&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2 .............&lt;/P&gt;&lt;P&gt;B...........&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 07:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199863#M49928</guid>
      <dc:creator>mich</dc:creator>
      <dc:date>2015-04-20T07:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199864#M49929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would something like;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input group $ Entity $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod1&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod3&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod2&lt;/P&gt;&lt;P&gt;B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prod4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; A.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B.ENTITY as ENTITY2&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE A&lt;/P&gt;&lt;P&gt;&amp;nbsp; left join HAVE B&lt;/P&gt;&lt;P&gt;&amp;nbsp; on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.GROUP=B.GROUP&lt;/P&gt;&lt;P&gt;&amp;nbsp; and&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input(strip(tranwrd(B.ENTITY,"Prod","")),best.) &amp;gt; input(strip(tranwrd(A.ENTITY,"Prod","")),best.)&lt;/P&gt;&lt;P&gt;&amp;nbsp; where&amp;nbsp;&amp;nbsp; ENTITY2 is not null;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 08:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199864#M49929</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-20T08:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199865#M49930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input group $ Entity $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;A Prod1&lt;/P&gt;&lt;P&gt;A Prod2&lt;/P&gt;&lt;P&gt;A Prod3&lt;/P&gt;&lt;P&gt;B Prod2&lt;/P&gt;&lt;P&gt;B Prod4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; A.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B.ENTITY as ENTITY2&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE A, Have B&lt;/P&gt;&lt;P&gt;&amp;nbsp; where a.group=b.group and a.entity&amp;lt;b.entity&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 10:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199865#M49930</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-04-20T10:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199866#M49931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hash will also do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Group $&amp;nbsp; Entity $;&lt;BR /&gt;datalines;&lt;BR /&gt;A Prod1&lt;BR /&gt;A Prod2&lt;BR /&gt;A Prod3&lt;BR /&gt;B Prod2&lt;BR /&gt;B Prod4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;if _n_=1 then do;&lt;BR /&gt; declare hash h (dataset:"have(rename=entity=entity2)", multidata:"Y");&lt;BR /&gt; h.definekey("group");&lt;BR /&gt; h.definedata("entity2");&lt;BR /&gt; h.definedone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;set have;&lt;BR /&gt;length entity2 $ 10;&lt;/P&gt;&lt;P&gt;rc=h.find(key:group);&lt;/P&gt;&lt;P&gt;do while(rc=0);&lt;BR /&gt; if entity gt entity2 then output;&lt;BR /&gt; if rc ne 0 then call missing(entity2);&lt;BR /&gt; rc=h.find_next();&lt;BR /&gt; &lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;drop rc;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 11:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199866#M49931</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2015-04-20T11:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199867#M49932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Or this way:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input group $ Entity $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;A Prod1&lt;/P&gt;&lt;P&gt;A Prod2&lt;/P&gt;&lt;P&gt;A Prod3&lt;/P&gt;&lt;P&gt;B Prod2&lt;/P&gt;&lt;P&gt;B Prod4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt; by group;&lt;/P&gt;&lt;P&gt; length e1 e2 $ 100;&lt;/P&gt;&lt;P&gt; array x{99999} $ 100 _temporary_;&lt;/P&gt;&lt;P&gt; if first.group then n=0;&lt;/P&gt;&lt;P&gt; n+1;x{n}=Entity;&lt;/P&gt;&lt;P&gt; if last.group then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to n-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do j=i+1 to n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e1=x{i};e2=x{j};output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; drop n Entity i j;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Xia Keshan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2015 12:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199867#M49932</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-04-20T12:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199868#M49933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks Xia, very helpful&lt;/P&gt;&lt;P&gt;thanks all&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 06:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/199868#M49933</guid>
      <dc:creator>mich</dc:creator>
      <dc:date>2015-04-21T06:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create all possible combination of one variable by group of another variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/280170#M59027</link>
      <description>This is very helpful. Thank you.</description>
      <pubDate>Sat, 25 Jun 2016 19:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-all-possible-combination-of-one-variable-by-group-of/m-p/280170#M59027</guid>
      <dc:creator>BellaLuna</dc:creator>
      <dc:date>2016-06-25T19:38:20Z</dc:date>
    </item>
  </channel>
</rss>

