<?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 Simulate lotto number combinations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203342#M50752</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I am trying to simulate combinations based on 5 coordinates (datset below):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coord;&lt;/P&gt;&lt;P&gt;input x 1. y 1.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;32&lt;/P&gt;&lt;P&gt;55&lt;/P&gt;&lt;P&gt;91&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every combination must begin with (1,1) and end with (1,1) i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt; (3,2)-&amp;gt; (5,5)-&amp;gt; (9,1)-&amp;gt; (1,4)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and all combinations must be unique and finally that there can't be the above route and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt;(1,4)-&amp;gt; (9,1)-&amp;gt; (5,5)-&amp;gt; (3,2)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as both routes are the same but in opposite directions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this in sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Aug 2015 08:18:42 GMT</pubDate>
    <dc:creator>Hugo123</dc:creator>
    <dc:date>2015-08-20T08:18:42Z</dc:date>
    <item>
      <title>Simulate lotto number combinations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203342#M50752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I am trying to simulate combinations based on 5 coordinates (datset below):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coord;&lt;/P&gt;&lt;P&gt;input x 1. y 1.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;32&lt;/P&gt;&lt;P&gt;55&lt;/P&gt;&lt;P&gt;91&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every combination must begin with (1,1) and end with (1,1) i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt; (3,2)-&amp;gt; (5,5)-&amp;gt; (9,1)-&amp;gt; (1,4)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and all combinations must be unique and finally that there can't be the above route and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1,1) -&amp;gt;(1,4)-&amp;gt; (9,1)-&amp;gt; (5,5)-&amp;gt; (3,2)-&amp;gt; (1,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as both routes are the same but in opposite directions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this in sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 08:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203342#M50752</guid>
      <dc:creator>Hugo123</dc:creator>
      <dc:date>2015-08-20T08:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate lotto number combinations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203343#M50753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do expect the output data set to look like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 16:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203343#M50753</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-20T16:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate lotto number combinations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203344#M50754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How many points ( pairs ) are you going to be using.&lt;/P&gt;&lt;P&gt;The following creates a text ordered pair variable and permutes them. Uniqueness I'm not sure quite what your rules may be. Note that if you are using many pairs that the number of records for output goes up as N!.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data coord;&lt;BR /&gt;input x 1. y 1. ;&lt;BR /&gt;length coord $ 8;&lt;BR /&gt;coord=catt(x,',',y);&lt;BR /&gt;retain start ;&lt;BR /&gt;if _n_= 1 then start= coord;&lt;BR /&gt;datalines;&lt;BR /&gt;11&lt;BR /&gt;32&lt;BR /&gt;55&lt;BR /&gt;91&lt;BR /&gt;14&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* flip the column to a row to get the ordered pairs in one record to permute later*/&lt;/P&gt;&lt;P&gt;proc transpose data=coord out=coordtrans;&lt;BR /&gt;by start;&lt;BR /&gt;var coord;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* you could trop some of the variables n, nfact, j. also the COL1 or start will have your first pair&lt;/P&gt;&lt;P&gt;so you also have it available as an end */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data next;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set coordtrans;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; array c Col2-col5; /* change the 5 to the number of pairs used*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; n=dim(c);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; nfact=fact(n);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do j=1 to nfact;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call lexperm(j,&amp;nbsp; of c&lt;LI&gt;);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/LI&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 20:52:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203344#M50754</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-20T20:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate lotto number combinations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203345#M50755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is called all permutations not combinations.&lt;/P&gt;&lt;P&gt;Want data step code or IML code ?&lt;/P&gt;&lt;P&gt;Suggest you post it at IML forum, since it is question about simulating data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data coord;
input x 1. y 1.;
datalines;
11
32
55
91
14
;
run;
proc sql noprint;
 select count(*) into : n
&amp;nbsp; from coord
&amp;nbsp;&amp;nbsp; where x ne 1 or y ne 1;
 select quote(cats(x,y)) into : list separated by ' '
&amp;nbsp; from coord
&amp;nbsp;&amp;nbsp; where x ne 1 or y ne 1;
quit;

data _null_;
array x{&amp;amp;n} $2 (&amp;amp;list);
n=dim(x);
nfact=fact(n);
do i=1 to nfact;
 change=allperm(i, of x{*});
 put i 5. +2 '11' +2 x{*} '11';
end;
run;





&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Aug 2015 02:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simulate-lotto-number-combinations/m-p/203345#M50755</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-08-21T02:05:54Z</dc:date>
    </item>
  </channel>
</rss>

