<?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: How to simulate percentage data in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/344974#M18139</link>
    <description>&lt;P&gt;Thank you for the clarification.&amp;nbsp;From your explanation I withdraw my satement about the response being binomially distributed. Even though&amp;nbsp;0/3, 1/3, 2/3,&amp;nbsp;and 3/3 are the possible outcomes, this is not a sequence of random independent trials with constant probability of success.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2017 13:57:06 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-03-28T13:57:06Z</dc:date>
    <item>
      <title>How to simulate percentage data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340583#M17922</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to simulate a dataset with two treatment groups&amp;nbsp;for&amp;nbsp;an endpoint percentage adherence to drug so that I can&amp;nbsp;investigate the effect of missing data strategies&amp;nbsp;on endpoint calculation.&amp;nbsp; Percentage adherence is calculated&amp;nbsp;from a daily binary variable yes/no over a 28 day period.&amp;nbsp;It is calculated as the&amp;nbsp;percentage of days medication taken within the correct time interval (24 hour) during the 28 days.&amp;nbsp; The mean percentage adherence is assumed to be 40% for the comparator arm and an absolute difference of 20% is anticipated in the&amp;nbsp;new treatment arm.&amp;nbsp;&amp;nbsp;Percentage adherence&amp;nbsp;will be analysed as a&amp;nbsp;continuous normally distributed variable and standard deviation is assumed to be 30%.&amp;nbsp; My question is how can I simulate the repeated binary data at the individual level whilst still making sure that the percentage adherence within&amp;nbsp; each arm follows a normal distribution with mean mu1 &amp;amp; mu2 and standard deviation equal to 30%.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance for any help you can offer on this.&lt;/P&gt;&lt;P&gt;I'm using SAS 9.3.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 20:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340583#M17922</guid>
      <dc:creator>agnesb</dc:creator>
      <dc:date>2017-03-13T20:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to simulate percentage data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340656#M17924</link>
      <description>&lt;PRE&gt;

Better post it IML forum ,it is about data simulation.
And better give an example to describe your question.
&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 05:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340656#M17924</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-14T05:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to simulate percentage data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340723#M17931</link>
      <description>&lt;P&gt;It sounds like you want to simulate a binary response with a two-factor explanatory variable. Look at the article &lt;A href="http://blogs.sas.com/content/iml/2014/06/25/simulate-logistic-data.html" target="_self"&gt;"Simulating data for a logistic regression model"&lt;/A&gt;&amp;nbsp;to get started. The main idea is that you use RAND("Bernoulli", p) &amp;nbsp;where p is the probability of taking the medicine. All you need to do is generate the data for n1 patients with p1=0.4 and n2 patients with p2=0.2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A&amp;nbsp;statistical clarification: It sounds like you are looking for a PROPORTION, not a mean. You want the PROPORTION to be 0.4 for the&amp;nbsp;control group and 0.2 for the new treatment group. The adherence of individual subjects will BINOMIALLY distributed, not normally distributed (although you can use the normal approximation for large samples.) &amp;nbsp;If that is correct, then you don't get to choose the standard deviation: in a binomial experiment, the standard deviation is sqrt(n*p*(1-p)). It is determined by the proportion and the sample size.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let p1 = 0.4;
%let n1 = 50;
%let p2 = 0.2;
%let n2 = 50;
data Study;
format patientID Z3.;
call streaminit(1234);
Treatment = "Control     ";
do i = 1 to &amp;amp;n1;
   PatientID + 1;
   do day = 1 to 28 ;
      TookMed = rand("Bernoulli", &amp;amp;p1);
      output;
   end;
end;
Treatment = "Experimental";
do i = 1 to &amp;amp;n2;
   PatientID + 1;
   do day = 1 to 28 ;
      TookMed = rand("Bernoulli", &amp;amp;p2);
      output;
   end;
end;
run;

proc freq data=Study;
tables TookMed*Treatment / nocum norow;
run;

proc means data=Study;
class Treatment;
var TookMed;
run;

proc sgpanel data=Study;
where PatientID in (10 20 30 40 60 70 80 90);
panelby PatientID Treatment/ columns=4 onepanel;
scatter x=day y=TookMed;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 10:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/340723#M17931</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-03-14T10:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to simulate percentage data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/344947#M18134</link>
      <description>Hi Rick,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your helpful response. I came back to this problem again&lt;BR /&gt;yesterday and the simulated data very much helped me visualise the problem.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;To give clarity with respect to using the mean adherence, we have a scenario&lt;BR /&gt;where in one treatment group patients are asked to take multiple drugs in a&lt;BR /&gt;24 hour period and so for each day daily adherence would yield a percentage&lt;BR /&gt;and not a 0 or 1. So for example, if a patient is required to take 3 drugs&lt;BR /&gt;in a 24 hour period then, if they take one this yields a daily percentage of&lt;BR /&gt;33.34%, 2 then 66.67% and so on. The interest lies in calculating the mean&lt;BR /&gt;daily adherence for each patient. This is why we originally approached the&lt;BR /&gt;problem as a continuous variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Lynn&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 28 Mar 2017 12:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/344947#M18134</guid>
      <dc:creator>agnesb</dc:creator>
      <dc:date>2017-03-28T12:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to simulate percentage data</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/344974#M18139</link>
      <description>&lt;P&gt;Thank you for the clarification.&amp;nbsp;From your explanation I withdraw my satement about the response being binomially distributed. Even though&amp;nbsp;0/3, 1/3, 2/3,&amp;nbsp;and 3/3 are the possible outcomes, this is not a sequence of random independent trials with constant probability of success.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 13:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-simulate-percentage-data/m-p/344974#M18139</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-03-28T13:57:06Z</dc:date>
    </item>
  </channel>
</rss>

