<?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: Do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236638#M43360</link>
    <description>&lt;P&gt;The exactly number is&amp;nbsp;&lt;SPAN&gt;50.063.860&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Nov 2015 17:29:12 GMT</pubDate>
    <dc:creator>DartRodrigo</dc:creator>
    <dc:date>2015-11-26T17:29:12Z</dc:date>
    <item>
      <title>Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236610#M43341</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code sent to me by Reeza:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data random;
    array s(60) s1-s60 (60*0);
    array p(6) p1-p6;
    do i=1 to 6;
        do while(p(i)=.);
            p(i)=floor(rand('uniform')*60+1);
            if s(p(i))=0 then s(p(i))=1;
            else p(i)=.;
         end;
     end;
keep p1-p6;
call sortn(of p(*));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code create six random numbers from 1 to 60 without duplicating them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now i need a loop to create 60 lines with diferente possibilities, the sequence (can't,may not) duplicate&lt;/P&gt;
&lt;P&gt;What i mean: if the sequence is: 1,2,3,4,5,6 the next line may not duplicate, so it can be any other sequence,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1,2,3,4,5,7 or&amp;nbsp;13,24, 25,30,57,58&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rodrigo&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236610#M43341</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T16:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236611#M43342</link>
      <description>Does order matter?</description>
      <pubDate>Thu, 26 Nov 2015 16:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236611#M43342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-26T16:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236612#M43343</link>
      <description>&lt;P&gt;No, order doesn't metter but what metter is: if one sequence exists, it can not be duplicated.&lt;/P&gt;
&lt;P&gt;That's all, thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236612#M43343</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T16:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236615#M43344</link>
      <description>&lt;P&gt;I'm not sure that you understood Reeza's question the same way as I did: Would you regard the two sequences 1,2,3,4,5,6 and 1,2,3,4,&lt;STRONG&gt;6,5&lt;/STRONG&gt; as duplicates (because they contain the same numbers and "order doesn't matter")?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236615#M43344</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T16:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236618#M43345</link>
      <description>&lt;P&gt;Oh yes, this can't happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236618#M43345</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T16:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236620#M43346</link>
      <description>I'm not sure I see an easy clear way to do this. I'd generate a large sample, ie if I need 60, generate 100. Remove duplicates and then take the top 60.</description>
      <pubDate>Thu, 26 Nov 2015 16:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236620#M43346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-26T16:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236622#M43347</link>
      <description>&lt;P&gt;Hum, it's ok but what i need is sixty different possibilities of sequences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236622#M43347</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T16:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236623#M43348</link>
      <description>&lt;P&gt;No problem: As Reeza wrote, you create 100 sequences and then remove (possible) duplicates and then select 60 of these. I am just writing a code example for you.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236623#M43348</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T16:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236626#M43350</link>
      <description>&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp(keep=r x1-x6);
array x[60];
seed=3141592653;
do i=1 to 60;
  x[i]=i;
end;
do n=1 to 100;
  call rancomb(seed, 6, of x[*]);
  r=ranuni(577215);
  output;
end;
drop i n;
run;

proc sort data=temp nodupkey;
by x1-x6;
run;

proc sort data=temp;
by r;
run;

data want;
set temp(obs=60 drop=r);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236626#M43350</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T16:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236628#M43352</link>
      <description>Nice!&lt;BR /&gt;One small suggestion, you can initialize the array in the array statement, and remove the first loop. &lt;BR /&gt;&lt;BR /&gt;array x[60] (1:60);&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Nov 2015 16:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236628#M43352</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-26T16:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236631#M43354</link>
      <description>&lt;P&gt;Thanks, Reeza. I was looking at Example 1 in the online help for CALL RANCOMB, where they initialize their array the inelegant way:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;array x x1-x5 (1 2 3 4 5);&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236631#M43354</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T17:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236632#M43355</link>
      <description>&lt;P&gt;Amazing man, that't exactly what i need, but if i would need&amp;nbsp;&lt;SPAN&gt;50.063.860 (&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://communities.sas.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;just asking !&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How much should i need to create&amp;nbsp;to get the top&amp;nbsp;50.063.860 ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236632#M43355</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T17:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236634#M43356</link>
      <description>&lt;P&gt;Just a mathematical side note: The probability that the NODUPKEY sort step will have to eliminate any duplicates is less than 1 in 10000 (at least in theory). So, the probability that the algorithm fails because of more than 40 duplicates must be minuscule.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236634#M43356</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T17:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236635#M43357</link>
      <description>&lt;P&gt;Is that 50 million?&lt;/P&gt;
&lt;P&gt;EDIT: That's 60 choose 6 - ie all possible combinations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want that, there's other, faster ways to obtain it than this method.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236635#M43357</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-26T17:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236636#M43358</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236636#M43358</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T17:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236637#M43359</link>
      <description>&lt;P&gt;That's the number of possibilities of a Raffle game.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236637#M43359</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T17:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236638#M43360</link>
      <description>&lt;P&gt;The exactly number is&amp;nbsp;&lt;SPAN&gt;50.063.860&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236638#M43360</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T17:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236639#M43361</link>
      <description>&lt;P&gt;It's exactly the number of possible combinations of 6 out of 60 (binomial coefficient).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need all, you wouldn't create random combinations, but just all, systematically.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236639#M43361</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-26T17:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236641#M43362</link>
      <description>Ok....so do you have a question?</description>
      <pubDate>Thu, 26 Nov 2015 17:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236641#M43362</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-26T17:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236642#M43363</link>
      <description>&lt;P&gt;No Reeza,&lt;/P&gt;
&lt;P&gt;Thanks again guys, amazing answers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 17:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/236642#M43363</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-26T17:34:43Z</dc:date>
    </item>
  </channel>
</rss>

