<?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: Generate two-dimensional array with random binomial data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565915#M158952</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

array col(5);

do nrows=1 to 100;

    do i=1 to dim(col);

           col(i) = rand('binomial', 0.1);

      end;

     output;

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depends a bit on what you mean by&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want the probability to be equal in all columns, say p=0.1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Random usually means that you won't have equal distributions, but the probability should be 0.1 across all observations anyways, dependent on sample size of course.&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267481"&gt;@Dinurik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear SAS Programmers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I generate an array and fill it with random binomial data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say, I need an array with 100 rows and 5 columns, and I want the probability to be equal in all columns, say p=0.1.&lt;/P&gt;
&lt;P&gt;My current code (sorry, if it's totally stupid) is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Table (keep=aids);&lt;BR /&gt;call streaminit(4321);&lt;BR /&gt;array p[5] _temporary_ (repeat(0.1, 5));&lt;BR /&gt;do i = 1 to 500;&lt;BR /&gt;aids = rand("Table", of p[*]);&lt;BR /&gt;output;&lt;BR /&gt;end; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, the repeat function in the array does not work (because it probably shouldn't be there). But when I replace it with (0.1, 0.1, 0.1, 0.1, 0.1) the code produces a single variable with 500 entries instead of arranging the results in an array.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2019 16:29:59 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-06-13T16:29:59Z</dc:date>
    <item>
      <title>Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565914#M158951</link>
      <description>&lt;P&gt;Dear SAS Programmers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I generate an array and fill it with random binomial data?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say, I need an array with 100 rows and 5 columns, and I want the probability to be equal in all columns, say p=0.1.&lt;/P&gt;&lt;P&gt;My current code (sorry, if it's totally stupid) is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Table (keep=aids);&lt;BR /&gt;call streaminit(4321);&lt;BR /&gt;array p[5] _temporary_ (repeat(0.1, 5));&lt;BR /&gt;do i = 1 to 500;&lt;BR /&gt;aids = rand("Table", of p[*]);&lt;BR /&gt;output;&lt;BR /&gt;end; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, the repeat function in the array does not work (because it probably shouldn't be there). But when I replace it with (0.1, 0.1, 0.1, 0.1, 0.1) the code produces a single variable with 500 entries instead of arranging the results in an array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565914#M158951</guid>
      <dc:creator>Dinurik</dc:creator>
      <dc:date>2019-06-13T16:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565915#M158952</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

array col(5);

do nrows=1 to 100;

    do i=1 to dim(col);

           col(i) = rand('binomial', 0.1);

      end;

     output;

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depends a bit on what you mean by&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I want the probability to be equal in all columns, say p=0.1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Random usually means that you won't have equal distributions, but the probability should be 0.1 across all observations anyways, dependent on sample size of course.&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267481"&gt;@Dinurik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear SAS Programmers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I generate an array and fill it with random binomial data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say, I need an array with 100 rows and 5 columns, and I want the probability to be equal in all columns, say p=0.1.&lt;/P&gt;
&lt;P&gt;My current code (sorry, if it's totally stupid) is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Table (keep=aids);&lt;BR /&gt;call streaminit(4321);&lt;BR /&gt;array p[5] _temporary_ (repeat(0.1, 5));&lt;BR /&gt;do i = 1 to 500;&lt;BR /&gt;aids = rand("Table", of p[*]);&lt;BR /&gt;output;&lt;BR /&gt;end; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all, the repeat function in the array does not work (because it probably shouldn't be there). But when I replace it with (0.1, 0.1, 0.1, 0.1, 0.1) the code produces a single variable with 500 entries instead of arranging the results in an array.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565915#M158952</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565922#M158958</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot. I tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;call streaminit(4321);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;array col(5);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do nrows=1 to 100;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to dim(col);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col(i) = rand('Bernoulli', 0.1);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any resource/article, that you could refer me to so I can teach myself on this topic?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565922#M158958</guid>
      <dc:creator>Dinurik</dc:creator>
      <dc:date>2019-06-13T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565927#M158962</link>
      <description>&lt;P&gt;Simulating data or just generate data step logic?&lt;/P&gt;
&lt;P&gt;For simulating data, Rick Wicklins blog and book are the best references:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.amazon.ca/Simulating-Data-SAS-Rick-Wicklin/dp/1612903320" target="_blank"&gt;https://www.amazon.ca/Simulating-Data-SAS-Rick-Wicklin/dp/1612903320&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267481"&gt;@Dinurik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any resource/article, that you could refer me to so I can teach myself on this topic?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 16:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565927#M158962</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T16:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565937#M158968</link>
      <description>&lt;P&gt;Thanks so much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What about data step logic? Data step completely throws me off, so I would really appreciate any recommendation of what to read =).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565937#M158968</guid>
      <dc:creator>Dinurik</dc:creator>
      <dc:date>2019-06-13T17:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565948#M158976</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;may have better suggestions. I'm an older user (before StackOverflow, FB or Twitter) so learned via reading the documentation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which I would actually highly recommend.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1lw46l098rlqsn1948oua32fnsl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1lw46l098rlqsn1948oua32fnsl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/565948#M158976</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-13T17:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Generate two-dimensional array with random binomial data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/566187#M159076</link>
      <description>&lt;P&gt;Wonderful, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 14:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-two-dimensional-array-with-random-binomial-data/m-p/566187#M159076</guid>
      <dc:creator>Dinurik</dc:creator>
      <dc:date>2019-06-14T14:50:48Z</dc:date>
    </item>
  </channel>
</rss>

