<?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 Adding conditions to the output of a negative binomial simulated data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526293#M143303</link>
    <description>&lt;P&gt;I have the following simulation code to produce 1000 sets of data similar to "work.final" where the independent variables do not change in all the 1000 sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I would like to add another condition. For each of the 1000 datasets, the frequency of the value 10, which is a simulated value of y should be 20%, the same way...the frequency of value 15 should be 10%.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NumSamples = 1000; 
data s_new;
call streaminit(6578);
set work.final; 
do SampleID=1 to &amp;amp;NumSamples; 
   mu = exp(1.5360 + 0.0140*x1 - 0.1016*x2 + 0.6216*x3);
   k = 1/0.5345;
   p = 1/(1+0.5345*mu);
   y = rand('negbinomial', p, k);
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jan 2019 06:50:22 GMT</pubDate>
    <dc:creator>john1111</dc:creator>
    <dc:date>2019-01-11T06:50:22Z</dc:date>
    <item>
      <title>Adding conditions to the output of a negative binomial simulated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526293#M143303</link>
      <description>&lt;P&gt;I have the following simulation code to produce 1000 sets of data similar to "work.final" where the independent variables do not change in all the 1000 sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I would like to add another condition. For each of the 1000 datasets, the frequency of the value 10, which is a simulated value of y should be 20%, the same way...the frequency of value 15 should be 10%.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NumSamples = 1000; 
data s_new;
call streaminit(6578);
set work.final; 
do SampleID=1 to &amp;amp;NumSamples; 
   mu = exp(1.5360 + 0.0140*x1 - 0.1016*x2 + 0.6216*x3);
   k = 1/0.5345;
   p = 1/(1+0.5345*mu);
   y = rand('negbinomial', p, k);
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 06:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526293#M143303</guid>
      <dc:creator>john1111</dc:creator>
      <dc:date>2019-01-11T06:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adding conditions to the output of a negative binomial simulated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526304#M143305</link>
      <description>&lt;P&gt;Do you want those frequencies to be &lt;STRONG&gt;exactly&lt;/STRONG&gt; 20 and 10% or will something like this following do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NumSamples = 1000; 
data s_new;
call streaminit(6578);
do SampleID=1 to &amp;amp;NumSamples; 
   mu = exp(1.5360 + 0.0140*x1 - 0.1016*x2 + 0.6216*x3);
   k = 1/0.5345;
   p = 1/(1+0.5345*mu);
   y = rand('negbinomial', p, k);
   a=rand('Uniform');
   if a&amp;lt;0.2 then y=10;
   else if 0.2&amp;lt;=a&amp;lt;=0.3 then y=15;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 08:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526304#M143305</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-11T08:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding conditions to the output of a negative binomial simulated data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526371#M143334</link>
      <description>&lt;P&gt;This would not work with the model I'm using on the simulated data. I previously tried rounding off some values of y (as shown below) to achieve the percentage...but I noticed that it was proving very difficult to get the exact percentage. I would really appreciate any incite that would get me the exact frequency of 10 and 15 to 20% and 10% respectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (5 &amp;lt;= y &amp;lt;= 12) &amp;amp; rand("Bernoulli", 0.2) then
      y10 = round(y, 10);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 14:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-conditions-to-the-output-of-a-negative-binomial-simulated/m-p/526371#M143334</guid>
      <dc:creator>john1111</dc:creator>
      <dc:date>2019-01-11T14:10:00Z</dc:date>
    </item>
  </channel>
</rss>

