<?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: Can this question be answered using the code below in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890307#M39599</link>
    <description>&lt;P&gt;"Simulate" usually does not involve pdf or cdf. I would imagine it involves the RAND function, such as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x=RAND('BINOMIAL', 0.15, 1000);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Aug 2023 21:50:29 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-08-21T21:50:29Z</dc:date>
    <item>
      <title>Can this question be answered using the code below</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890304#M39598</link>
      <description>&lt;PRE&gt;Data _null_;
a1=pdf("binomial",60,0.5,100);
a2=1-cdf("binomial",59,0.5,100);
put a1 a2;
run;
&lt;/PRE&gt;
&lt;P&gt;I am trying to get a simple binomial function without having to give a option of above or below a certain number I am very lost &lt;BR /&gt;THis is the question that I am trying to answer, I don't need the answer just some more clues on how to do it. &lt;BR /&gt;For a particular infectious disease, 15% of non-vaccinated individuals will become infected with the disease in one year versus &lt;BR /&gt;5% of vaccinated individuals. Simulate a virtual randomized trial in which you vaccinate 1000 individuals with the real vaccine and &lt;BR /&gt;1000 individuals with a placebo vaccine and follow the groups for one year. (Hint: Generate values from random binomial functions &lt;BR /&gt;with N=1000, p=.15 and N=1000, p=.05; then subtract). How many more infections occurred in the placebo group than in the vaccine group in this single virtual trial?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 21:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890304#M39598</guid>
      <dc:creator>Silver77</dc:creator>
      <dc:date>2023-08-21T21:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can this question be answered using the code below</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890307#M39599</link>
      <description>&lt;P&gt;"Simulate" usually does not involve pdf or cdf. I would imagine it involves the RAND function, such as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x=RAND('BINOMIAL', 0.15, 1000);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Aug 2023 21:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890307#M39599</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-21T21:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can this question be answered using the code below</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890315#M39600</link>
      <description>&lt;P&gt;Depending on the purpose of the exercise and what comes next there are two, at least, ways to approach this.&lt;/P&gt;
&lt;P&gt;One way is to create group total of occurrences. An approach:&lt;/P&gt;
&lt;PRE&gt;data group;
   status='Vaccination';
   disease = rand('Binomial',0.05,1000);
   output;
   status='Placebo';
   disease = rand('Binomial',0.15,1000);
   output;
run;&lt;/PRE&gt;
&lt;P&gt;And you might look at the results:&lt;/P&gt;
&lt;PRE&gt;Proc print data=group noobs;
   var status disease;
run;&lt;/PRE&gt;
&lt;P&gt;Another approach would be to simulate individual records with vaccination status and disease result for each. The Bernoulli distribution is a single event trial. Binomial distribution is the result of multiple Bernoulli trials.&lt;/P&gt;
&lt;P&gt;So perhaps:&lt;/P&gt;
&lt;PRE&gt;data individuals;
   Status='Vaccination';
   do id=1 to 1000;
      disease = rand('Bernoulli',0.05);
      output;
   end;
   Status='Placebo';
   do id=1001 to 2000;
      disease = rand('Bernoulli',0.15);
      output;
   end;
run;
proc means data=individuals sum;
   class status;
   var disease;
run;&lt;/PRE&gt;
&lt;P&gt;Which approach is "better" really comes in what is next. Consider if you want to also include another random factor such as age, ethnicity, or hair color. To use the group approach you would have to have some idea of the rate for those along with the vaccination status.&lt;/P&gt;
&lt;P&gt;But if I am given some other information such as 20% of the population is category 1, 30% is category 2 and 50% is category 3 we can create a random sample of individuals using one of the other random functions:&lt;/P&gt;
&lt;PRE&gt;data individuals;
   Status='Vaccination';
   do id=1 to 1000;
      disease = rand('Bernoulli',0.05);
      category = rand('Table',0.2,0.3,0.4);
      output;
   end;
   Status='Placebo';
   do id=1001 to 2000;
      disease = rand('Bernoulli',0.15);
      category = rand('Table',0.2,0.3,0.4);
      output;
   end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2023 00:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890315#M39600</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-22T00:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can this question be answered using the code below</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890455#M39612</link>
      <description>&lt;P&gt;Thank you this was very helpful&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 18:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-this-question-be-answered-using-the-code-below/m-p/890455#M39612</guid>
      <dc:creator>Silver77</dc:creator>
      <dc:date>2023-08-22T18:39:30Z</dc:date>
    </item>
  </channel>
</rss>

