<?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: Generate Poker Hands in SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145078#M38555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have great news for you. The SAS University Edition includes SAS/IML and is free!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sas.com/en_us/software/university-edition.html" title="http://www.sas.com/en_us/software/university-edition.html"&gt;Free Statistical Software, SAS University Edition | SAS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS University Edition is for personal use, but it is not limited to academia. That is, you don't have to be an enrolled student to access it. Note that this is intended for learning purposes only, so don't use it for paid work. Enjoy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jun 2014 18:23:27 GMT</pubDate>
    <dc:creator>StatsGeek</dc:creator>
    <dc:date>2014-06-19T18:23:27Z</dc:date>
    <item>
      <title>Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145066#M38543</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'm trying to build a program that generates poker game results based on predetermined assumptions about the players. I'm trying to come up with a simple enough algorithm that ranks the hands of players and allocates chips to the best hand. In Texas Holdem there are 2,598,960 unique poker hands but this can be reduced to 7462 distinct poker hand values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple of initial questions. The program will allocate two distinct poker cards from a deck - i've coded them such that 13H is the Ace of Hearts for example. I was going to have a table with the 52 card values and have the cards generated based on the rand function that picks a value between 1 and 52, however, it just occurred to me that when the program allocated a hand to the next player &lt;STRONG&gt;it can't repeat either of the cards allocated to the previous player&lt;/STRONG&gt;. The data set I'm thinking will look someting like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="126" style="border: 1px solid rgb(0, 0, 0); width: 602px; height: 78px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 3&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 4&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 5&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player 6&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Shared Card 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Shared Card 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Shared Card 3&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;13H&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;02C&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;09S&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;07S&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;02D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;06H&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;03D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Once the cards are allocated (so all cards are unique as mentioned above), the algorithm then needs to lookup a table so each player is given a value between 1 and 7462 and the chips are allocated based on the highest hand value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to be able to run this algorithm 1000s of times so I can derive a distribution of profit based on the assumptions entered into the alogorithm so speed is important. I've spent a couple of hours on this so far and I'm having some trouble getting started as I'm not sure of a function that restricts the random function from repeating the same value and I'm also concerned that If I have a table that has every possible poker hand that the program will perform very slowly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthew &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 17:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145066#M38543</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-17T17:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145067#M38544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this perhaps? This generates a number of data sets specified by the parameter Runs, for given number of Players which better be less than 25. The sets are named sequentially as hand1, hand2 etc. with a player identifier, his two dealt cards as card1 and card2 and 4 common cards named common1 through 4.&lt;/P&gt;&lt;P&gt;%macro holdem(Runs=,players=);&lt;BR /&gt;%do i = 1 %to &amp;amp;runs;&lt;BR /&gt;data cards;&lt;BR /&gt;length rank $ 2 suit $1 card $ 3;;&lt;BR /&gt;do rank='A','1','2','3','4','5','6','7','8','9','10','J','Q','K';&lt;BR /&gt;&amp;nbsp; do suit = 'C','D','H','S';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; card= cats(rank,suit);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; rand= ranuni(546); &lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;drop rank suit;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=cards; by rand;run;&lt;BR /&gt;%let p = &amp;amp;players;/* number of players*/&lt;BR /&gt;data deal;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set cards;&amp;nbsp; /*after resort on the random value*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain counter ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter +1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; player = mod(counter,&amp;amp;p)+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter gt (&amp;amp;p*2) then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; common= 1;/* the common cards*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; player = .;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if counter gt (&amp;amp;p*2 + 4) then stop;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=deal; by player;run;&lt;BR /&gt;proc transpose data=deal(where=(player ne .)) prefix=card&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=players;&lt;BR /&gt;by player;&lt;BR /&gt;var card;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=deal(where=(player = .)) prefix=common&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=common;&lt;BR /&gt;by player;&lt;BR /&gt;var card;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table hand&amp;amp;i as&lt;BR /&gt;select a.player, a.card1, a.card2, b.common1,b.common2,b.common3,b.common4&lt;BR /&gt;from players as a , common as b&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%holdem(Runs=3,players=4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its up to you to combine/rank the card combinations and assign your values. Options would be to include the run counter in the hand set, add ",&amp;amp;i as RunCounter" after the b.common4 in the last step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want all of the datasets combined&lt;BR /&gt;data allhand;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set hand: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;should do it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 19:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145067#M38544</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-17T19:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145068#M38545</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;&lt;STRONG style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;do rank='A','1','2','3','4','5','6','7','8','9','10','J','Q','K';&lt;/STRONG&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;in this you are creating 56 cards, &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;i guess it should like : &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;do rank='A','2','3','4','5','6','7','8','9','10','J','Q','K';&lt;/SPAN&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 05:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145068#M38545</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2014-06-18T05:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145069#M38546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your detailed and helpful reply. I've worked through the code and I now understand the logic. The only puzzling thing is that when I execute the macro, my hand1, 2 and 3 are the same. I went through each step and the first data step doesn't seem to generate a different random set of numbers each time the macro loops. I keep getting .98956 as the first entry in the column rand. Do you know what might be causing this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 09:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145069#M38546</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-18T09:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145070#M38547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;Just following up on my message above re the ranuni function - would you have an idea of why this is happening?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 12:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145070#M38547</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-19T12:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145071#M38548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The repeated runs are likely the fixed seed in the random generator. It's a feature that allows duplication of random sequences and I used that for debugging. So leave the parantheses emtpy in the ranuni call.&lt;/P&gt;&lt;P&gt;Sorry about the A 1 confusion. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 14:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145071#M38548</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-19T14:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145072#M38549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ballardw&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried putting it in ranuni() instead of ranuni(546) and I got an error message saying "The Ranuni function Call does not have enopugh arguments"...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 15:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145072#M38549</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-19T15:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145073#M38550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi brophymj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't call ranuni without arguments. Instead, use ranuni(0).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 15:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145073#M38550</guid>
      <dc:creator>StatsGeek</dc:creator>
      <dc:date>2014-06-19T15:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145074#M38551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use &amp;amp;i in the ranuni. That will generate a different stream for each run.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 15:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145074#M38551</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-19T15:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145075#M38552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given that you want to run the simulation for 1000's of hands, you should consider running the simulation in IML. Using macros to run the simulation using data steps may be time consuming. For example, I ran the above code for 10,000 runs with 9 players. The simulation took 9:56. In contrast, running the simulation under the same conditions in IML with the code shown below took under a second.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nruns = 10000; *Specify number of runs;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nplayers = 9; *Specify number of players;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rank = {A,1,2,3,4,5,6,7,8,9,10,J,Q,K};&lt;/P&gt;&lt;P&gt;&amp;nbsp; suit = {C,D,H,S};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 to 14;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck = deck // concat(strip(rank&lt;J&gt;),suit&lt;I&gt;);&lt;/I&gt;&lt;/J&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; free rank suit;&lt;/P&gt;&lt;P&gt;&amp;nbsp; hands = J(nruns,nplayers+5,'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = 1 to nplayers;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = name || ({player}+strip(char(i)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; name = name || {community1 community2 community3 community4 community5};&lt;/P&gt;&lt;P&gt;&amp;nbsp; mattrib hands colname=name;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do run = 1 to nruns;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; order = j(52,1,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call randgen(order,'uniform');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call sortndx(index,order);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; deck_shuffled = deck[index];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; card=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do player = 1 to nplayers;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hands[run,player] = concat(deck_shuffled[card,],{", "},deck_shuffled[card+1,]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; card=card+2;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hands[run,nplayers+1:nplayers+5] = deck_shuffled[card:card+4]`;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create hands from hands [colname=name];&lt;/P&gt;&lt;P&gt;&amp;nbsp; append from hands;&lt;/P&gt;&lt;P&gt;&amp;nbsp; close hands;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 17:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145075#M38552</guid>
      <dc:creator>StatsGeek</dc:creator>
      <dc:date>2014-06-19T17:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145076#M38553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Strongly recommend the IML approach.&amp;nbsp; Back with data step, I suggest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call streaminit(seed=&amp;lt;insert odd integer value&amp;gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;lt;some code&amp;gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rand=rand('UNIFORM");&lt;/P&gt;&lt;P&gt;&amp;lt;maybe more code&amp;gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Someplace out there is a bunch of notes regarding the superiority of the RAND function to RANUNI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 17:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145076#M38553</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2014-06-19T17:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145077#M38554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately I don't have that feature in the version of sas I use - it's my company's software so I can't get it. I think it's prohibitively expensive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have code for a card evaluator as well i.e. somthing that reads any 5 card hand and allocates a rank so you can determine which player has the best hamnd.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 18:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145077#M38554</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-19T18:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145078#M38555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have great news for you. The SAS University Edition includes SAS/IML and is free!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sas.com/en_us/software/university-edition.html" title="http://www.sas.com/en_us/software/university-edition.html"&gt;Free Statistical Software, SAS University Edition | SAS&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS University Edition is for personal use, but it is not limited to academia. That is, you don't have to be an enrolled student to access it. Note that this is intended for learning purposes only, so don't use it for paid work. Enjoy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 18:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145078#M38555</guid>
      <dc:creator>StatsGeek</dc:creator>
      <dc:date>2014-06-19T18:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145079#M38556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Stephen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I ask, what is IML and how is it different? I will definitely use it if it's faster as I want to simulate 100s of games based on player assumptions regarding players for quick 6 player games i.e. ones that only last 25 minutes or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program will incorporate everything from increasing blinds to probailities of pushing all-in etc. I will start with a simple game and build it up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the coding much different in IML?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, would you have the code or advice for evaluating poker hands?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I play lots of online poker and I'm using this as a way of looking alligning my strategy closer to an optimal approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 19:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145079#M38556</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-06-19T19:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145080#M38557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IML stands for Interactive Matrix Language. As the name implies, it is a matrix language. The beauty of working in a matrix language is that you can work with just the items you want without having to loop through an entire data set. For example, in the code I previously posted I created a vector called deck_shuffled which contained the values for all the cards, shuffled into a random order. If I've already dealt the player cards and want to assign cards for the flop, I can directly grab three values from the vector, put the new values into a vector called flop, and increment the card index:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;flop = deck_shuffled[card:card+2];&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;cards = cards + 3;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This action is rather easy to code after you are accustomed to working with matrices, and it takes virtually no time to run. Remember, this saves us from having to increment through a data set whenever we want to use our data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IML and the associated syntax is different from data step syntax because you are working with matrices rather than with data sets. However, it is very easy to learn. One of the IML developers, Rick Wicklin, has a great book about learning to program in IML (Statistical Programming with SAS/IML Software) as well as another book on simulating data in IML. He's also published a ton of small papers on using IML for various tasks and writes a SAS blog called The Do Loop. I strongly recommend getting his programming book, as it is very well written. You can find information about his books and other publications here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/publishing/authors/wicklin.html" title="http://support.sas.com/publishing/authors/wicklin.html"&gt;SAS Press - Rick Wicklin Author Page&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for evaluating poker hands, I have never written a program for doing so. I notice that Rick suggested in another discussion that you should &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;write a pairwise comparison algorithm to determine whether one hand beats another. That would be my approach as well. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck, and watch out for pocket fives!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 20:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145080#M38557</guid>
      <dc:creator>StatsGeek</dc:creator>
      <dc:date>2014-06-19T20:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Poker Hands in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145081#M38558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="455729" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Here is that article you were looking for: &lt;A href="http://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni/" title="http://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni/"&gt; Six reasons you should stop using the RANUNI function to generate random numbers - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 18:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-Poker-Hands-in-SAS/m-p/145081#M38558</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-07-01T18:36:38Z</dc:date>
    </item>
  </channel>
</rss>

