<?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: Combinations of binary indicator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348920#M273485</link>
    <description>&lt;P&gt;Thanks, it's a nice function. But the problem is I have n=2 (0 or 1) but k=3 which doesn't work for ALLCOMB.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 22:50:30 GMT</pubDate>
    <dc:creator>kaushik_patra</dc:creator>
    <dc:date>2017-04-10T22:50:30Z</dc:date>
    <item>
      <title>Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348838#M273482</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I would like to generate all possible combinations of three variables each with values 0 or 1 e.g. following using a data step&lt;/P&gt;&lt;P&gt;000&lt;/P&gt;&lt;P&gt;001&lt;/P&gt;&lt;P&gt;010&lt;/P&gt;&lt;P&gt;100&lt;/P&gt;&lt;P&gt;011&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;110&lt;/P&gt;&lt;P&gt;111&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what will be a good way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348838#M273482</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-10T19:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348843#M273483</link>
      <description>&lt;P&gt;Check out &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#n0rag3bzl2l7dsn16xc6bwufqg5a.htm" target="_self"&gt;the ALLCOMB function&lt;/A&gt; in SAS. &amp;nbsp;Designed just for such a thing!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348843#M273483</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-04-10T19:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348846#M273484</link>
      <description>&lt;P&gt;These combinations are just a sequence of binary numbers.&amp;nbsp; You don't need any data to do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do i=0 to 7;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; result = put(i, binary3.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348846#M273484</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-10T19:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348920#M273485</link>
      <description>&lt;P&gt;Thanks, it's a nice function. But the problem is I have n=2 (0 or 1) but k=3 which doesn't work for ALLCOMB.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 22:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348920#M273485</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-10T22:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348923#M273486</link>
      <description>&lt;P&gt;Thanks, this is a nice little trick. I will have to have 3 different columns for all combinations of 0 or 1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348923#M273486</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-10T23:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348924#M273487</link>
      <description>&lt;P&gt;A not terribly bright solution&lt;/P&gt;
&lt;PRE&gt;data _null_;
    do i='0','1';
      do j='0','1';
         do k='0','1';
            comb=cats(i,j,k);
            put comb=;
         end;
      end;
   end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348924#M273487</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-10T23:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348926#M273488</link>
      <description>Thanks. The need is to have three distinct columns rather than a single column with all possible combinations.&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348926#M273488</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-10T23:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348927#M273489</link>
      <description>&lt;P&gt;For three it is simple.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  do a=0,1; do b=0,1; do c=0,1;
    output;
  end; end; end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348927#M273489</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-10T23:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348931#M273490</link>
      <description>Great! This has promise. If I have two arrays&lt;BR /&gt;P = (0 1) and x = (x1 x2 x3) where each of x takes values 0 or 1, how would you do it?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348931#M273490</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-10T23:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348934#M273491</link>
      <description>&lt;P&gt;Not sure what you are talking about at this point. &amp;nbsp;If you have four variables named P, X1 , X2, and X3 then you could build all combinations using similar DO loops. &amp;nbsp;If you have two tables and want to join them to produce all possible combinations then PROC SQL does a good job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table want as
  select *
  from P, X
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really have two vectors and what to manipulate them then use PROC IML. You can do lots of matrix manipulation using a language designed to work with matrices.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 00:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348934#M273491</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-11T00:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348936#M273492</link>
      <description>Thanks, I have the following data -&lt;BR /&gt;Data a;&lt;BR /&gt;Array p[2] (0 1);&lt;BR /&gt;Array x[3];&lt;BR /&gt;I would like the data step operations to produce 8 rows with the unique combinations.&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Apr 2017 00:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348936#M273492</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-11T00:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348942#M273493</link>
      <description>&lt;P&gt;So maybe something like this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  array p[2] _temporary_ (0 1);
  array x[3];
  do _n_=0 to dim(p)**dim(x)-1;
     do i=1 to dim(x);
       x(i)=p(1+mod(int(_n_/(dim(p)**(i-1))),dim(p))) ;
     end;
     output;
  end;
  drop i ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 03:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348942#M273493</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-11T03:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combinations of binary indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348947#M273494</link>
      <description>This is cool. I have devised a similar solution (but less technical) based on Astounding's proposal.&lt;BR /&gt;&lt;BR /&gt;data a;&lt;BR /&gt;&lt;BR /&gt;array p[2] _temporary_;&lt;BR /&gt;&lt;BR /&gt;array x[3];&lt;BR /&gt;&lt;BR /&gt;do i=1 to dim(p)**dim(x);&lt;BR /&gt;&lt;BR /&gt;result = put(i, binary3.);&lt;BR /&gt;&lt;BR /&gt;do j=1 to 3;&lt;BR /&gt;&lt;BR /&gt;x[j]=substr(result,j,1);&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;output;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;drop i j;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Apr 2017 01:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combinations-of-binary-indicator/m-p/348947#M273494</guid>
      <dc:creator>kaushik_patra</dc:creator>
      <dc:date>2017-04-11T01:37:19Z</dc:date>
    </item>
  </channel>
</rss>

