<?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: Simulating conditional probabilities in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356867#M83737</link>
    <description>&lt;P&gt;Rick, while I agree, I thought it was reasonable to back into the p(B|^A) by looking at the condition that the overall p(B) was 0.3. &amp;nbsp;That's how I came up with the 0.25. &amp;nbsp;If I'm proven wrong, it won't be the first time.&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2017 13:09:42 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-08T13:09:42Z</dc:date>
    <item>
      <title>Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356650#M83634</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I would like to simulate two events A and B knowing their conditional probabilities as follow&lt;/P&gt;&lt;P&gt;P(A) =0.2&lt;/P&gt;&lt;P&gt;P(B)=0.3&lt;/P&gt;&lt;P&gt;P(A and B) =0.1&lt;/P&gt;&lt;P&gt;I remember that P(A or B) = P(A) + P(B) - P(A and B)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I incorporate the probability of the joint event (A and B) in the simulation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 20:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356650#M83634</guid>
      <dc:creator>SimRock</dc:creator>
      <dc:date>2017-05-06T20:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356658#M83641</link>
      <description>&lt;P&gt;You don't. &amp;nbsp;You just assign A and B randomly, and the distribution should work itself out. &amp;nbsp;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;A_flag = (ranuni(12345) &amp;lt; 0.2);&lt;/P&gt;
&lt;P&gt;B_flag = (ranuni(67893) &amp;lt; 0.3);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the flags are assigned randomly, their joint distribution should match your expectations. &amp;nbsp;And you can change the initial seeds if you need additional simulations. &amp;nbsp;To check the distributions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=want;&lt;/P&gt;
&lt;P&gt;tables a_flag * b_flag / list;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 23:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356658#M83641</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-06T23:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356680#M83649</link>
      <description>&lt;P&gt;Your question is ambiguous.&lt;/P&gt;
&lt;P&gt;Give an example &amp;nbsp;to explain your data simulation question .&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 02:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356680#M83649</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-07T02:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356742#M83678</link>
      <description>&lt;P&gt;Your formula is not exactly relevant to the task your describe.&amp;nbsp; From the infor you provided, you want to determine the probabiliy of (1) A only, (2) B only, (3) neither.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given P(A)=.2, P(B)=.3, and P(A&amp;amp;B)=.1, you know how to fill out a 2*2 crosstab (A=0 or 1 by B=0 or 1).&amp;nbsp; Let's say you have 100 observations then your table has the following starting points, given the probabilities you cite:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp; A=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A=1&amp;nbsp;&amp;nbsp; |&amp;nbsp; total&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;B=0&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;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;B=1&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;10&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;-----------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;total&amp;nbsp; |&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; 100&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can conclude that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; P(A=1,B=0) = P(A) - P(A&amp;amp;B) = .2 - .1 = .1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (N=10)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; P(B=0,B=1) = P(B) - P(A&amp;amp;B) = .3 - .1 = .2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (N=20)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; P(A=0,B=0)&amp;nbsp; = 1 - P(A&amp;amp;B) - P(A=1,B=0) - P(A=0,B=1) = 1 - .1 - .1 - .2 = .6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;generating this table with the italicized values calculated per above&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp; A=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A=1&amp;nbsp;&amp;nbsp; |&amp;nbsp; total&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;B=0&amp;nbsp;&amp;nbsp; &amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;60&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;70&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;B=1&amp;nbsp;&amp;nbsp; &amp;nbsp;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;-----------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;total&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;80&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp; 100&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can now map the range of 0-1 to the above 4 cell, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; [0.0-0.6]&amp;nbsp; ==&amp;gt; A=0,B=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; (0.6-0.7]&amp;nbsp; ==&amp;gt; A=1,B=0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; (0.7-0.9]&amp;nbsp; ==&amp;gt; A=0,B=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; (0.9-1.0] ==&amp;gt;&amp;nbsp; A=1,B=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program uses that non-independent table to generate 100 observations using the association you describe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t;
  retain P_AandB .1  P_A .2  P_B .3
         P_Aonly P_Bonly P_neither . ;

  if _N_=1 then do;
    P_Aonly =P_A - P_AandB;
    P_Bonly =P_B - P_AandB;
    P_neither  = 1 - P_AandB - P_Aonly - P_Bonly;	
	put (p_:) (=);
  end;

  samp_size=100;

  do N=1 to samp_size;
    A=0; B=0;
    u=ranuni(10598156);
	if      U &amp;lt;= P_neither then;
	else if U &amp;gt;P_neither + P_Aonly + P_Bonly then do; A=1; B=1; end;
	else if U &amp;lt;= P_neither + P_Aonly then A=1;
	else B=1;
	output;
  end;
run;

proc freq; table A*B;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 20:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356742#M83678</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-07T20:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356746#M83681</link>
      <description>&lt;P&gt;I'm going to amend my earlier answer. &amp;nbsp;Although much of the problem is still not clear (do you even have a data set to work with?), the basic principles and math apply in any case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If pA=0.2 and pB=0.3, their joint A&amp;amp;B distribution would be 0.06 if selected randomly. &amp;nbsp;Therefore, to raise the hit rate to 0.1 from 0.06, pB&amp;nbsp;needs to be higher when A=1. &amp;nbsp;Since pB is fixed at 0.3, however, pB&amp;nbsp;needs to be lower when A=0. &amp;nbsp;The math is actually pretty easy ... you can see the probabilities that I used here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;do replication = 1 to 10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;A_flag = (ranuni(12345) &amp;lt; 0.2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if A_flag=1 then B_flag = (ranuni(67893) &amp;lt; 0.5);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else B_flag = (ranuni(97531) &amp;lt; 0.25);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have an original data set (and it's not clear that you do), this gives you 10 versions of the data set with different A and B values, where each version conforms to the conditions you specified. &amp;nbsp;"Conforms" means on average ... each replication may be slightly off.&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 23:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356746#M83681</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-07T23:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356807#M83715</link>
      <description>&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;A comment to your second answer, using 3 different calls of RANUNI with 3 different seeds:&lt;/P&gt;&lt;P&gt;It is only possible to set the seed for the RANUNI (and other functions in the same family) once in each datastep. The seed is set in the first call to RANUNI, and the compiler disregards the parameters for the later calls. You can try for yourself:&lt;/P&gt;&lt;PRE&gt;data test;
  do _N_=1 to 10;
  a=ranuni(12345);
  b=ranuni(45678);
  output;
  end;
run;
data test2;
  set test;
  a2=ranuni(12345);
  b2=ranuni(4);
run;&lt;/PRE&gt;&lt;P&gt;With this program you will see that not only are all the A2 values equal to the A values, the B2 values are allso all equal to the B values. On the other hand, if you switch the two lines in the final datastep:&lt;/P&gt;&lt;PRE&gt;data test2;
  set test;
  b2=ranuni(4);
  a2=ranuni(12345);
run;&lt;/PRE&gt;&lt;P&gt;You will see that not only are all the B2 values different from the B values, the A2 values differ from the A values as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Søren&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 08:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356807#M83715</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-05-08T08:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356833#M83731</link>
      <description>&lt;P&gt;For more information about Soren's response. see &lt;A href="http://blogs.sas.com/content/iml/2012/01/30/random-number-seeds-only-the-first-seed-matters.html" target="_self"&gt;"Random number seeds: Only the first seed matters."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 11:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356833#M83731</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-05-08T11:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356840#M83733</link>
      <description>&lt;P&gt;Thanks. You learn something new every day (at least on a good day).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding my solution, it should work regardless ... as long as the random number generated changes each time RANUNI is called. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the original problem, it's still not clear whether it is a programming problem or an algebra problem (why did I use 0.5 and 0.25, for example). &amp;nbsp;We'll have to wait to find out what is really needed here.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 12:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356840#M83733</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-08T12:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356855#M83735</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The title of this post uses the term "conditional probability," but your question (which needs to be clarified) does not use the conditional probability.&amp;nbsp;If you are interested in conditional probabilities, use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P(B|A) = P(A and B) / P(A) = 0.1 / 0.2 = 0.5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if the simulation process is "draw A, then draw B conditional on A," you need knowledge of P(B| ^A).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can review the rules of probability at&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stattrek.com/probability/probability-rules.aspx?Tutorial=AP" target="_blank"&gt;http://stattrek.com/probability/probability-rules.aspx?Tutorial=AP&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and the rules of conditional probability at&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Conditional_probability" target="_blank"&gt;https://en.wikipedia.org/wiki/Conditional_probability&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 12:48:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356855#M83735</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-05-08T12:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356867#M83737</link>
      <description>&lt;P&gt;Rick, while I agree, I thought it was reasonable to back into the p(B|^A) by looking at the condition that the overall p(B) was 0.3. &amp;nbsp;That's how I came up with the 0.25. &amp;nbsp;If I'm proven wrong, it won't be the first time.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 13:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356867#M83737</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-08T13:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Simulating conditional probabilities in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356870#M83738</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;, your code is fine. I missed it because I was studying&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;'s simulation from the joint probability.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My preference would be to modify Astounding's code&amp;nbsp;slightly to use RAND, but the logic is the same:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Cond;
do i = 1 to 1000;
   A = rand("Bernoulli", 0.2);
   if A then   B = rand("Bernoulli", 0.5);
   else        B = rand("Bernoulli", 0.25);
   output;
end;

proc freq data=Cond; /* check empirical distribution */
table A B A*B;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 May 2017 13:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulating-conditional-probabilities-in-SAS/m-p/356870#M83738</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-05-08T13:29:26Z</dc:date>
    </item>
  </channel>
</rss>

