<?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: The Birthday Paradox in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159422#M31065</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like a fun problem. If anyone wants to solve it by using SAS/IML, here are some basics on vectorizing teh computations in the Birthday paradox: &lt;A href="http://blogs.sas.com/content/iml/2012/04/09/vectorized-computations-and-the-birthday-matching-problem/" title="http://blogs.sas.com/content/iml/2012/04/09/vectorized-computations-and-the-birthday-matching-problem/"&gt; Vectorized computations and the birthday matching problem - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Jun 2014 16:48:45 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2014-06-30T16:48:45Z</dc:date>
    <item>
      <title>The Birthday Paradox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159420#M31063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;The birthday paradox states that in any group of 23 people there is a 50% chance that two of them share a birthday. The BBC recently published an &lt;A href="http://www.bbc.com/news/magazine-27835311" style="color: #557799;"&gt;article&lt;/A&gt; that shows 16 of the 32 World Cup teams, each consisting of 23 players, have shared birthdays, thus demonstrating the paradox precisely. Today’s exercise asks you to recreate their calculation.&lt;/P&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;You can obtain the same listing of player birthdays that the BBC used from &lt;A href="http://resources.fifa.com/mm/document/tournament/competition/02/36/33/44/fwc_2014_squadlists_neutral.pdf" style="color: #557799;"&gt;FIFA&lt;/A&gt;. Another source is the player rosters at &lt;A href="http://en.wikipedia.org/wiki/2014_FIFA_World_Cup_squads" style="color: #557799;"&gt;WikiPedia&lt;/A&gt;.&lt;/P&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;Your task is to demonstrate that the 2014 World Cup rosters honor the birthday paradox.&lt;/P&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #555555; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;"&gt;SOURCE: &lt;A href="http://programmingpraxis.com/2014/06/20/birthday-paradox-2/" title="http://programmingpraxis.com/2014/06/20/birthday-paradox-2/"&gt;Birthday Paradox | Programming Praxisdox&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 05:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159420#M31063</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2014-06-28T05:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: The Birthday Paradox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159421#M31064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below is my solution, I encourage you to attempt to solve it yourself before looking over what I have done, however, it is necessary to point out one set of items I needed to address:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Apparently Wikipedia has some of the birthday's for players incorrect, at least according to the BBC/FIFA data, I adjusted them to match with the following:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14039341564629474" jivemacro_uid="_14039341564629474"&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;update foo&lt;/P&gt;
&lt;P&gt;set bday='15MAR1984'd , mon=3 , day=15 , year=1984&lt;/P&gt;
&lt;P&gt;where nat='Algeria' and name='Medhi Lacen';&lt;/P&gt;
&lt;P&gt;update foo&lt;/P&gt;
&lt;P&gt;set bday='23JUN1984'd , mon=6 , day=23 , year=1984&lt;/P&gt;
&lt;P&gt;where nat='Chile' and name='José Manuel Rojas';&lt;/P&gt;
&lt;P&gt;update foo&lt;/P&gt;
&lt;P&gt;set bday='01JUN1984'd , mon=6 , day=1 , year=1984&lt;/P&gt;
&lt;P&gt;where nat='Chile' and name='Jean Beausejour';&lt;/P&gt;
&lt;P&gt;update foo&lt;/P&gt;
&lt;P&gt;set bday='19FEB1991'd , mon=2 , day=19 , year=1991&lt;/P&gt;
&lt;P&gt;where nat='Germany' and name='Christoph Kramer';&lt;/P&gt;
&lt;P&gt;delete from foo&lt;/P&gt;
&lt;P&gt;where nat='Croatia' and name='Milan Badelj'; *out due to injury, replaced by Ivan Mocinic;&lt;/P&gt;
&lt;P&gt;insert into foo&lt;/P&gt;
&lt;P&gt;set nat='Croatia'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , name='Ivan Mocinic'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , mon=4&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , day=30&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , year=1993&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , bday='30APR1993'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , caps=0;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I found it easier to use the following Wikipedia link to collect my data: &lt;A href="http://en.wikipedia.org/w/api.php?format=json&amp;amp;action=query&amp;amp;titles=2014_FIFA_World_Cup_squads&amp;amp;prop=revisions&amp;amp;rvprop=content" title="http://en.wikipedia.org/w/api.php?format=json&amp;amp;action=query&amp;amp;titles=2014_FIFA_World_Cup_squads&amp;amp;prop=revisions&amp;amp;rvprop=content"&gt;http://en.wikipedia.org/w/api.php?format=json&amp;amp;action=query&amp;amp;titles=2014_FIFA_World_Cup_squads&amp;amp;prop=revisions&amp;amp;rvprop=content&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;filename u url '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://en.wikipedia.org/w/api.php?format=json&amp;amp;action=query&amp;amp;titles=2014_FIFA_World_Cup_squads&amp;amp;prop=revisions&amp;amp;rvprop=content';"&gt;http://en.wikipedia.org/w/api.php?format=json&amp;amp;action=query&amp;amp;titles=2014_FIFA_World_Cup_squads&amp;amp;prop=revisions&amp;amp;rvprop=content';&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data foo;&lt;/P&gt;&lt;P&gt;format bday date9.;&lt;/P&gt;&lt;P&gt;length nat name $ 40;&lt;/P&gt;&lt;P&gt;retain one 1 nat no ;&lt;/P&gt;&lt;P&gt;infile u dlm='=|[](){}' recfm=s lrecl=1000000 column=col start=col;&lt;/P&gt;&lt;P&gt;if no=23 then call missing(nat);&lt;/P&gt;&lt;P&gt;if missing(nat) then do;&lt;/P&gt;&lt;P&gt;input @'\n===' nat : $32. @;&lt;/P&gt;&lt;P&gt;if countw(nat)&amp;gt;3 then stop;&lt;/P&gt;&lt;P&gt;input @'{{nat fs start}}' @;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;input @'no=' no : @'pos=' pos $2. @'name=' name :$40. @'age2' (_n_ _n_ _n_ _n_) (: ??) +(-22) @;&lt;/P&gt;&lt;P&gt;if missing(_n_) then input @'df=y' @'|' (year mon day) (:) @;&lt;/P&gt;&lt;P&gt;else input @'age2|' (_n_ _n_ _n_) (:) (year mon day) (:) +(-10) @;&lt;/P&gt;&lt;P&gt;bday=mdy(mon , day , year);&lt;/P&gt;&lt;P&gt;input @'caps=' caps : +5 club :$128. @'clubnat=' clubnat $3. @'\n' @@;&lt;/P&gt;&lt;P&gt;name=htmldecode(prxchange('s/\\u(.{4})/&amp;amp;#x$1;/',-1,name));&lt;/P&gt;&lt;P&gt;club=htmldecode(prxchange('s/\\u(.{4})/&amp;amp;#x$1;/',-1,club));&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;/*Wikipedia bday's incorrect? set to match BBC data */&lt;/P&gt;&lt;P&gt;update foo&lt;/P&gt;&lt;P&gt;set bday='15MAR1984'd , mon=3 , day=15 , year=1984&lt;/P&gt;&lt;P&gt;where nat='Algeria' and name='Medhi Lacen';&lt;/P&gt;&lt;P&gt;update foo&lt;/P&gt;&lt;P&gt;set bday='23JUN1984'd , mon=6 , day=23 , year=1984&lt;/P&gt;&lt;P&gt;where nat='Chile' and name='José Manuel Rojas';&lt;/P&gt;&lt;P&gt;update foo&lt;/P&gt;&lt;P&gt;set bday='01JUN1984'd , mon=6 , day=1 , year=1984&lt;/P&gt;&lt;P&gt;where nat='Chile' and name='Jean Beausejour';&lt;/P&gt;&lt;P&gt;update foo&lt;/P&gt;&lt;P&gt;set bday='19FEB1991'd , mon=2 , day=19 , year=1991&lt;/P&gt;&lt;P&gt;where nat='Germany' and name='Christoph Kramer';&lt;/P&gt;&lt;P&gt;delete from foo&lt;/P&gt;&lt;P&gt;where nat='Croatia' and name='Milan Badelj'; *out due to injury, replaced by Ivan Mocinic;&lt;/P&gt;&lt;P&gt;insert into foo&lt;/P&gt;&lt;P&gt;set nat='Croatia'&lt;/P&gt;&lt;P&gt;&amp;nbsp; , name='Ivan Mocinic'&lt;/P&gt;&lt;P&gt;&amp;nbsp; , mon=4&lt;/P&gt;&lt;P&gt;&amp;nbsp; , day=30&lt;/P&gt;&lt;P&gt;&amp;nbsp; , year=1993&lt;/P&gt;&lt;P&gt;&amp;nbsp; , bday='30APR1993'd&lt;/P&gt;&lt;P&gt;&amp;nbsp; , caps=0;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=foo nway noprint;&lt;/P&gt;&lt;P&gt;class nat mon day;&lt;/P&gt;&lt;P&gt;var caps;&lt;/P&gt;&lt;P&gt;output out=n(where=(_freq_&amp;gt;1))&lt;/P&gt;&lt;P&gt;idgroup( max(caps) out[2](name bday)=)/autolabel autoname;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Some teams have multiple pairs, we choose one only;&lt;/P&gt;&lt;P&gt;data n;&lt;/P&gt;&lt;P&gt;set n;&lt;/P&gt;&lt;P&gt;by nat;&lt;/P&gt;&lt;P&gt;if first.nat;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=n;&lt;/P&gt;&lt;P&gt;var nat name: bday:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 05:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159421#M31064</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2014-06-28T05:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: The Birthday Paradox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159422#M31065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like a fun problem. If anyone wants to solve it by using SAS/IML, here are some basics on vectorizing teh computations in the Birthday paradox: &lt;A href="http://blogs.sas.com/content/iml/2012/04/09/vectorized-computations-and-the-birthday-matching-problem/" title="http://blogs.sas.com/content/iml/2012/04/09/vectorized-computations-and-the-birthday-matching-problem/"&gt; Vectorized computations and the birthday matching problem - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2014 16:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159422#M31065</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-06-30T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: The Birthday Paradox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159423#M31066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS seems to agree that the cutoff is 23 people.&amp;nbsp; However, the percentage comes in slightly different than that in the article.&amp;nbsp; Test program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; prob = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do i=1 to 25;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prob = prob * (365 - i) / 365;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put i= prob=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this program, i is the number of people being added to the starting group of 1 person.&amp;nbsp; So the group of 23 people is reached when i=22.&amp;nbsp; PROB is the probability that all people in the group have different birthdays.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2014 18:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159423#M31066</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-06-30T18:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: The Birthday Paradox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159424#M31067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes. the perm() comes up with the same number, the prob is the the probability that at least 2 person sharing birthday in a group of 23:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;prob=1-perm(365,23)/365**23;&lt;/P&gt;&lt;P&gt;put prob=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jun 2014 19:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-Birthday-Paradox/m-p/159424#M31067</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-06-30T19:11:50Z</dc:date>
    </item>
  </channel>
</rss>

